Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Fix this HTML-ish image sizer

by FunkyMonk (Chancellor)
on Jun 18, 2007 at 18:02 UTC ( [id://621841]=note: print w/replies, xml ) Need Help??


in reply to Fix this HTML-ish image sizer

You need to divide by whichever ratio is the greatest:

rescale( 1000, 1234 ); rescale( 100, 1000 ); sub rescale { my ( $height, $width ) = @_; my $maxh = "600"; my $maxw = "800"; if ($height > $maxh || $width > $maxw) { my $hratio = $height / $maxh; my $wratio = $width / $maxw; my $ratio = $hratio > $wratio ? $hratio : $wratio; my $newh = $height / $ratio; my $neww = $width / $ratio; printf "H=%d W=%d ratios: old=%0.2f new =%0.2f\n", $newh, $neww, $height / $width, $newh / $neww; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://621841]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-03-28 09:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found