On Tue, May 15, 2001 at 03:27:02PM -0700, Cory Petkovsek wrote:
>
> No bob, it's not only the image size I want. I have a bunch of images improperly
>sized, and I need to know which one. Next phase is to fix them. Then I'll be
>renaming a bunch of them (not using gimp, just perl), and I'll be resizing a whole
>lot of them. I'm working on about 48,000+ images! Yikes!
>
> > Image::Size is available from CPAN or in the libimage-size-perl package.
> >
Imager can do lots of kewl things ...
#! /usr/bin/perl -w
use Imager;
use strict;
register "cory_jpginfo",
"test width and height of image",
"test width and height of image",
"Cory Petkovsek",
"Public Domain",
"5/10/01",
"<Toolbox>/Xtns/Script-Fu/Cory/",
"", # RGB*
[],
sub {
my $dir = shift || '.';
opendir DIR, $dir or die "Can't open directory $dir: $!\n";
my @files= grep /[pP].+\.jpg/, readdir(DIR);
for($i=0; $i<=$#files; $i++){
my $file = "/home/cory/item" . "$files[$i]";
my $img = Imager->new ();
$img->open (file=>"$file", type=>'jpeg')
or warn "failed: ", $img->{ERRSTR}, "\n";;
my $width = $img->getwidth ();
my $height = $img->getheight ();
my ($width, $height) = imgsize($file);
if (($width!=1024) || ($height!=768) ){
print $files[$i].": ".$width."x".$height."\n";
# scale width to 1024 or height to 768, whichever creates
# the smaller pic. Use 'transform' for more control.
my $scaled = $img->scale(xpixels=>1024, ypixels=>768, min);
$scaled->write (file=>"$file-new", type=>'jpeg')
or warn "failed: ", $scaled->{ERRSTR}, "\n";
}
}
return;
};
exit main;