With ImageMagick

With Imager

No ones playing yet w/ GD :)

With GD:

$img->thumb makes it 20% of the original size, many other ways to shrink it and it even can do resampling if you wish :)
see
http://search.cpan.org/~dmuey/GD-Image-Thumbnail-0.01/Thumbnail.pm
for more details.


Below you could:

   my $img = GD::Image->new($_);
   my $thm = $img->thumb;

but I chose the one line way since I wasn't really using $img

might also shorten it by doing:

binmode THM
print THM GD::Image->new($_)->thumb->jpeg;

Not sure if it'd go or not, you'd have to test it

#!/usr/bin/perl

use strict;
use warnings;
use GD::Image::Thumbnail;

for(<*.jpg>) {
   my $thm = GD::Image->new($_)->thumb;
   open THM, '>', "thm$_" or die "open thm$_ failed: $!";
   binmode THM;
   print THM $thm->jpeg;
   close THM;
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to