[eluser]gRoberts[/eluser]
hi all,
right, i'm using the image library and resize to generate thumbnails, and it seems that if the image is smaller then the given width and height, that it resizes it bigger.
I tried putting in some code to check, but it's just prooven buggy.
Code:
public function generate($source, $output, $width, $height) {
$size = getimagesize($source);
if($size[0] < $width && $size[1] < $height) {
copy($source, $output);
return;
}
$config['image_library'] = 'GD2';
//$config['library_path'] = '/usr/bin/X11';
$config['source_image'] = $source;
$config['maintain_ratio'] = TRUE;
$config['create_thumb'] = false;
$config['new_image'] = $output;
$config['quality'] = 100;
$config['width'] = (int)$width;
$config['height'] = (int)$height;
$this->base->image_lib->initialize($config);
if(!$this->base->image_lib->resize())
die($this->base->image_lib->display_errors());
}
I have tried using an if/or on the width/height of the image. But I had an image that was wider then the given width, but shorter then the given height. This in turn copied the image.
Basically i need to resize images whilst maintaining the ratio, to the size i've given, but if the image is already smaller then the height or width then I would like it to handle it correctly.
Has anyone had this problem before?
Thank you all in advance!
Gavin