Forum Moderators: coopster

Message Too Old, No Replies

GD image library scripting, chromatic problems

loss of color quality

         

Montbazin

9:08 am on Jan 23, 2006 (gmt 0)

10+ Year Member



I am using the following functions in a script to reduce weight of JPEG images uploaded to a web site:

$img1=imageCreateFromJpeg($ffile);
$img2 = imageCreate($x2,$y2);
imageCopyResized($img2,$img1,0,0,0,0,$x2,$y2,$x1,$y1);
imageJPEG($img2,"$ffolder/$ffname",$qual);
imageDestroy($img1);
imageDestroy($img2);

As a result I obtain a quite reasonable reduction in weight of the image, but my problem is that the images become quite colorless and grayish. Is there some way to correct this?
thanks...
roberto

jatar_k

5:12 pm on Jan 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



take a look at the page for imagecreate [php.net], they recommend using imagecreatetruecolor [php.net]. See if that makes a difference.

Montbazin

6:38 pm on Jan 23, 2006 (gmt 0)

10+ Year Member



I have tried
imagecreatetruecolor()
but it didn't work because the don't have GD2 on my hosting server

jatar_k

6:45 pm on Jan 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hmmm, not sure what else to suggest

have you tried playing with the quality to see if that makes any difference?

Montbazin

8:26 pm on Jan 23, 2006 (gmt 0)

10+ Year Member



yesy te funny thing is that when I put the quality to 100%, the result is still very bad. It tends to favorize the dominant color. If I try with a picture which has a good color balance, the result is better.

Montbazin

11:51 pm on Jan 23, 2006 (gmt 0)

10+ Year Member



I have tried
imagecreatetruecolor()
on a different server implemented with GD2 and it seems to be the solution.
The function
imagecreate()
I had used before only handles 256 colors, but seems unable to make proper mean values in order to approach all colors.

Thanks for your help
roberto