Resizing/Scaling images with Mogrify
| Newsgroups | gmane.comp.video.image-magick.windows |
|---|---|
| Message-ID | <[email protected]> |
Hi
I am trying to determine how I can scale photos by just setting a
width property and having it automatically size the photo uniformly
without distortion to the appropriate, proportional height and am
having trouble, and since the imagemagick.org site has gone away I'm
not sure where to turn. None of my programming buddies have ever used
this stuff either. I hope someone can help. Here's my code where I'm
trying to tell it if the image width is greater than or equal to 1280,
size it down to 40% of its original size, but it doesn't do it.
use File::Find;
use Image::Magick;
my $original_dir = '/home/ezsuite/public_html/photoalbum';
my $resized_dir = '/home/ezsuite/public_html/photoalbum';
my $thumb_dir = '/home/ezsuite/public_html/photoalbum/thumbs';
File::Find::find(\&wanted, $original_dir);
sub wanted {
return if /^\.\.?$/;
my $image = Image::Magick->new;
my $x = $image->Read($_);
warn "$x" if "$x";
if ($image->Get('width') == 1280)
{
$x = $image->Scale('40%');
warn "$x" if "$x";
$x = $image->Write("$resized_dir/$_");
warn "$x" if "$x";
}
File::Find::find(\&thumbs, $original_dir);
}
sub thumbs {
return if /^\.\.?$/;
my $image = Image::Magick->new;
my $x = $image->Read($_);
warn "$x" if "$x";
$x = $image->Scale('50%');
warn "$x" if "$x";
$x = $image->Write("$thumb_dir/$_");
warn "$x" if "$x";
}
unlink "/home/ezpage/public_html/photoalbum/*.JPG";
unlink "/home/ezpage/public_html/photoalbum/*.jpg";
Perhaps I hvae to assign the result of the get width to a variable?
Anyhow, this is how I'm approaching it now, but I'd rather just set
the width to a number and having it do what I said earlier.
Thanks.
Marian
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/nhFolB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
[email protected]
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/