Welcome Guest, Not a member yet? Register   Sign In
image manipulation class - resize() maintain_ratio - not always!
#1

[eluser]PeteSig[/eluser]
Hi

I'm re-sizing some images & have set the
$config['maintain_ratio'] = TRUE;

if I set a height value & resize, the aspect ratio is maintained.
However, when I set a width value, then the aspect ratio is NOT maintained.

Here's my code, which is pretty much ripped from the user guide, so nothing complicated:
Code:
$config['image_library'] = 'gd2';
$config['source_image'] = $image;
$config['maintain_ratio'] = TRUE;
$config['height'] = 180;
$this->image_lib->initialize($config);
$this->image_lib->resize();
The above works fine.
Code:
$config['image_library'] = 'gd2';
$config['source_image'] = $image;
$config['maintain_ratio'] = TRUE;
$config['width'] = 320;
$this->image_lib->initialize($config);
$this->image_lib->resize();
The above doesn't keep aspect ratio.

Anyone else experienced this?
Is it a bug in CI or in the gd2 image lib, or am I not using it properly again?

Cheers

Pete




Theme © iAndrew 2016 - Forum software by © MyBB