CodeIgniter Forums
Image library (GD) resize problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Image library (GD) resize problem (/showthread.php?tid=16016)



Image library (GD) resize problem - El Forum - 02-22-2009

[eluser]RaBu[/eluser]
Hi,

I'm trying to re-size a newly uploaded image-file in a controller function, I get no errors and the image get re-sized just fine, but the quality is crap. The image get very dusty and with a low amount of colors (in the blue-, gray-, white-ish scale).


Code:
$imageconfig['image_library'] = 'GD';
$imageconfig['source_image'] = "uploads/".$uploadFiles['0'];
$imageconfig['quality'] = "100%";
$imageconfig['maintain_ratio'] = TRUE;
$imageconfig['width'] = 250;
$imageconfig['height'] = 150;

$this->load->library('image_lib', $imageconfig);

$this->image_lib->resize();

Anyone else have experienced this problem?

Kind regards,
Rasmus


Image library (GD) resize problem - El Forum - 02-22-2009

[eluser]RaBu[/eluser]
Here you can see an example of the re-sized files:

http://rabu.dk/temp/example1.jpg
http://rabu.dk/temp/example2.JPG


Image library (GD) resize problem - El Forum - 02-22-2009

[eluser]brianw1975[/eluser]
Quote:$imageconfig['quality'] = "100%";

did you try and take out the % from 100%?

in the code there is no percent sign, and since text won't convert to an int very easily it'd get converted to 0 i believe.

Code:
class CI_Image_lib {
    
    var $image_library        = 'gd2';      // Can be:  imagemagick, netpbm, gd, gd2
    var $library_path        = '';
    var $dynamic_output        = FALSE;    // Whether to send to browser or write to disk
    var $source_image        = '';    
    var $new_image            = '';
    var $width            = '';
    var $height            = '';
    var $quality            = '90';



Image library (GD) resize problem - El Forum - 02-22-2009

[eluser]RaBu[/eluser]
Yes, I have the exact same problem - even if I completely leave out the "quality" parameter.


Image library (GD) resize problem - El Forum - 02-22-2009

[eluser]pistolPete[/eluser]
Are you sure you are using GD instead of GD2 ?


Image library (GD) resize problem - El Forum - 02-23-2009

[eluser]RaBu[/eluser]
Of course, my phpinfo() says:
GD Version: bundled (2.0.28 compatible)

So changing to GD2 fixed the problem.

Code:
$imageconfig['image_library'] = 'GD2';

Thanks for the pointer Smile


Image library (GD) resize problem - El Forum - 02-24-2009

[eluser]Vijusoft[/eluser]
Thanks a lot,

Same problem in my project get solved.


Image library (GD) resize problem - El Forum - 07-29-2009

[eluser]quexal[/eluser]
I had the same exact problem... even after switching to GD2 it was still doing it!

Solved by adding the line to my config:

$config['quality'] = '90';


Hope this helps someone else running in to this problem.


Image library (GD) resize problem - El Forum - 07-29-2009

[eluser]devbro[/eluser]
I was there done that. basically forget about GD and GD2 if quality of images are important to you. use imagemagick instead.