in reply to creating thumbnails

Here is a nice thumbnail creating script for jpgs.
#!/usr/bin/perl # by Merlyn use strict; use Image::Magick; my $im = Image::Magick->new; umask 0022; my @names = @ARGV ? @ARGV : grep { -f and -B } <*>; for (@names) { if (/ /) { my $old = $_; tr, ,_,s; $_ .= ".jpg" unless /\.jpg$/; !-e and rename $old, $_ or next; warn "renaming $old to $_\n"; } next if /\.thumb\.jpg$/; my $thumb = "$_.thumb.jpg"; next if -e $thumb; undef @$im; my $ret; $ret = $im->Read($_) and warn($ret), next; $ret = $im->Scale( geometry => '100x100' ) and warn($ret), next; $ret = $im->Write($thumb) and warn($ret), next; warn "thumbnail made for $_\n"; }

Replies are listed 'Best First'.
•Re: Re: creating thumbnails
by merlyn (Sage) on Dec 28, 2003 at 17:21 UTC
Re: Re: creating thumbnails
by zentara (Cardinal) on Dec 29, 2003 at 18:23 UTC
    Sorry Merlyn, I don't claim posted code is my own, I just save and catagorize any useful script I see. This is one of the best.
      Hi! is there a way to read / get thumbnails from jpegs? I think exif thumbnail, because loading a large image may take a lot of time. and if there is already a thumbnail stored in the exif then it might greatly lessen the time of create a thumbnail.
        good idea..... start working on it... you have a genius level idea there

        P.S. my further ideas on this is that the thumbnails can be packaged separately in a simple single file database, like with Storable for example..... that way you only need to create the thumbs once, and you can include them as part of a resource file with the app.

        As far as including the thumbnails in the exif info, maybe there is enough room in there, but it almost seems like you may as well develope your own file format..... like jpegs that allow information riders to be concated onto the end of the image, before the EOF..... maybe separated by a few chr 01's,.... maybe you could include a sound bite too... :-)


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku