Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: - Scales down images

by merlyn (Sage)
on Jan 22, 2001 at 00:59 UTC ( #53375=note: print w/replies, xml ) Need Help??

in reply to - Scales down images

Boy, are you gonna be surprised to find out that you can replace most of your logic with...
... main code ... $size = "${size}x$size" unless $size =~ /%$/; ... sub shrink { my $name = shift; my $img = Image::Magick->new; $img->Read($name); $img->Mogrify('geometry' => $size); $img->Write($name); }
And then let $size be either "50%" or "72" at the top there. The former will make a half-size picture. The latter will make the largest image that fits into 72x72, while keeping the proportions, as all your code attempts to do.

Yeah, the ImageMagick docs are a real pain to get into, but once you've got the good tricks, it's rather nice.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: - Scales down images
by Vortacist (Pilgrim) on Jan 22, 2001 at 01:51 UTC
    I appreciate the help, and have updated my code accordingly. I would like to mention, though, that I don't think you can use Mogrify in:

    $img->Mogrify('geometry' => $size);

    You have to use Resize in order to get it to work...or at least I did.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://53375]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2018-07-16 06:54 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (333 votes). Check out past polls.