On Wednesday 17 July 2002 12:43 pm, Jay Daniels wrote:
> I need to resize all gif images in a certain directory by pixels. There has
> to an easier way to do this besides opening all images in the Gimp???
>
>
> jay

Hi Jay,

Here's a little perl script I use to create thumbnails for all images in a 
directory.  You could use this as a basis for what you want.  You'll need 
Image Magick and Image::Magick installed.

#!/usr/bin/perl
use strict;

use Image::Magick;

my $im = Image::Magick->new;

umask 0022;

# if passed filenames use them, otherwise do all
my @names = @ARGV ? @ARGV : grep { -f and -B } <*>;

for (@names) {                        # foreach name
  if (/ /) {                          # if name contains a space
    my $old = $_;
    tr, ,_,s;                         # change spaces to _
    $_ .= ".jpg" unless /\.jpg$/;     # append .jpg if missing
    ! -e and rename $old, $_ or next; # skip file if rename fails
    warn "renaming $old to $_\n";
  }
  next if /\.thumb\.jpg$/;            # skip if this is thumbnail
  my $thumb = "$_.thumb.jpg";
  next if -e $thumb;                  # skip if thumbnail exists
  undef @$im;                         # reset (part of) $im
  my $ret;
  $ret = $im->Read($_)                # read file
    and warn($ret), next;             # or fail and skip
  $ret = $im->Scale(geometry => '100x100')
    and warn($ret), next;
  $ret = $im->Write($thumb)
    and warn($ret), next;
  warn "thumbnail made for $_\n";
}
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to