in reply to Making jpg thumbnails
Perhaps use the Imager module since you can not use Image::Magick. It doesn't look like anyone else has recommended that yet.
Here is some sample code for resizing a JPEG with Imager.
#!/usr/bin/perl -w use Imager; use strict; my $file = "something.jpg"; my $thumb_file = "something_thumb.jpg"; my $image = Imager->new() or die "Can't create Imager object"; $image->open(file => $file) or die $image->errstr; # You could also pass qtype => 'preview' to scale() to # supposedly make a smaller thumbnail (filesize wise) my $thumbnail = $image->scale(ypixels => 100) or die $image->errstr; # You could pass fd => fileno(STDOUT), instead of the file # parameter if you need to print to STDOUT. If you do so # make sure to binmode STDOUT, and disable buffering ($|++) $thumbnail->write(file => $thumb_file, type => 'jpeg') or die $thumbnail->errstr;
Also, as other people have said, if you need to generate the thumbnails on the fly, at least do some caching of them. Check if a thumbnail exists and perhaps even compare the timestamps of the thumbnail and the actual image so that you only have to generate the thumbnail when it is absolutely necessary.
When I was originally playing around with Imager I found it to be a bit slower than Image::Magick. Unfortunately I do not have any benchmarks... but it is something to keep in mind.
Hope that helps. Good luck with your application.
|
|---|