Forum Moderators: coopster

Message Too Old, No Replies

Generating Thumbnails

How to get better quality thumbnails then with GD?

         

Vali

4:04 pm on Jun 22, 2006 (gmt 0)

10+ Year Member



Hi

This may have been asked before, but can’t find any the posts, so here it goes.

I have a site where people can upload images, and create thumbnails. Problem is using the GD library the thumbnail quality is quite low, and pixilated.

Is there a way to get better quality from the resize? If so using what components and so on? (Would prefer using things that come with the default installation.)

Also, how can a thumbnail be done from a gif image (animated or not) and from swf flash moves?

Message back

Vali

whoisgregg

6:25 pm on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using imagecopyresized [php.net] or imagecopyresampled [php.net]? I've not had poor results using imagecopyresampled.

If you are using imagecopyresampled and still are not happy with the results, you may want to take a look at imagemagick [imagemagick.org].

whoisgregg

6:31 pm on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



how can a thumbnail be done from a gif image

Same as from a JPEG... just use imagecreatefromgif [php.net] instead of imagecreatefromjpeg [php.net] and output the resampled version using imagegif [php.net] instead of imagejpeg [php.net].

From [us2.php.net...]

Note: GIF support was removed from the GD library in Version 1.6, and added back in Version 2.0.28. This function is not available between these versions.

Vali

7:51 pm on Jun 22, 2006 (gmt 0)

10+ Year Member



Hi

I have the latest GD library, so think the GIF is in there.

I'm using imagecopyresized right now, I'll try the imagecopyresampled. Only problem I found about it is that it can take a while to do... (2.2 seconds from the manual) so I can't really have it wait that long.

Any ideas of imagemagick is faster then that?

Vali

whoisgregg

9:27 pm on Jun 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The 2.2 seconds quoted in the comment on the manual page is only if the original image is 3000x2000 pixels. That's pretty freakin' huge. His method of speeding up the process is quite novel.

If you have people uploading pictures of that size, the upload itself is probably taking quite a few seconds already, so the extra couple at the end for processing shouldn't matter too much.

Vali

3:09 pm on Jun 23, 2006 (gmt 0)

10+ Year Member



Hey

I made the script resize the image first to 500x500 or something (the fast way) then the slow way to 100x100. Seams to work, and the quality is much better.

Thank you

[edited by: coopster at 3:15 pm (utc) on June 23, 2006]
[edit reason] careful with the name calling please ;-) [/edit]

eeek

7:19 pm on Jun 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I use this and it works well:

$thumb=imagecreatetruecolor($x*$sf, $y*$sf);
imagecopyresized($thumb, $img, 0, 0, 0, 0, $x*$sf, $y*$sf, $x, $y);

$sf is the scale factor I've calculated.