CodeIgniter Forums
image manipulation class - resize() maintain_ratio - not always! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: image manipulation class - resize() maintain_ratio - not always! (/showthread.php?tid=35097)



image manipulation class - resize() maintain_ratio - not always! - El Forum - 10-19-2010

[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