Forum Moderators: coopster

Message Too Old, No Replies

Optimizing/Compressing thumbs for web display

gd

         

henry0

8:55 pm on Nov 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an uploader/thumb maker that works fine
but I do not understand why regardless of the compression the thumb ends always with the same image "weight" I tested it from 40 to 90 with the same pic and the thumb does not get optimized.

Am I wrong in thiking that thumb quality translates by
compression?

imagejpeg($thumb, "img/thumbs/t_$filename", 40);

<<< Script excerpt:
$thumb = imagecreatetruecolor($thumb_x,$thumb_y);

//Copy the original image data to it using resampling
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));

//insert in DB thumb's path ####
/*$conn = db_connect();
$sql = "update pics
set path_thumb ='$path_thumb'
where filename='$filename' ";
$result = mysql_query($sql, $conn);
*/
// create and save a thumb ####
imagejpeg($thumb, "img/thumbs/t_$filename", 90);
>>>>

eelixduppy

9:02 pm on Nov 28, 2006 (gmt 0)




quality is optional, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default is the default IJG quality value (about 75).

My guess is that the image files are too small to begin with that changing the qualities of the images isn't going to change the image size by any significant amount. If this is correct, then you should expect better optimization with larger image files or a larger difference in quality; instead of 40 and 90, try something like 10 and 100 and the difference should be noticeable.

Anyway, as I don't have much experience with the quality parameter so I really don't know ;)

henry0

9:16 pm on Nov 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Addendum:
I started testing with 300K image :)
and tested from 100 to 40

<<< EDIT
Hmmm, not too bright! it works OK
I was stupid enough to check my photo program output size
and not checking thumb property in its dir :)
</EDIT>

eelixduppy

9:29 pm on Nov 28, 2006 (gmt 0)



I just tested this on my server and this is what I have as the results:

Original Image: 1.34 MB @ 2136px x 2848px

Now I resized the image with PHP twice, and saved it as two separate files.

Quality 100: 22.2 KB @ 150px x 200px
Quality 40: 2.85KB @ 150px x 200px

[just saw your edit]

Well...glad you got it. I'm going to post these results anyway ;)

[/just saw your edit]