>>>>> "John" == John Edwards <[EMAIL PROTECTED]> writes:

John> Try the GD module. Here is some code I have for creating thumbnails
John> (untested as it's stripped down from a bigger script). Thumbnails have a _
John> prepended to them. They're not great thumbs, there is no anti aliasing done
John> on them. For better image handling you'll need to look at the ImageMajick
John> (sp??) module but that's overkill for my needs.

Here's what I use for the zillions of pictures at
        http://www.stonehenge.com/merlyn/Pictures/


    #!/usr/bin/perl
    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";
    }

This creates a thumb that is proportional, but at most 100pxl in
either dimension.  ImageMagick does all the math. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to