in reply to Re: Image Xs and Ys
in thread Image Xs and Ys

Nice! One minor quibble, if $scale == 1, then result is pixels, not inches...

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."

Replies are listed 'Best First'.
Re^3: Image Xs and Ys
by LAI (Hermit) on Jan 30, 2003 at 17:43 UTC

    Whoops, I didn't even notice that.

    Wait... why the hell are you using inches anyway? If you're scaling the image by a factor of 3, let's say, and the image is 120*50 pixels, it'll still be 360*150 pixels. Unless $scale is dpi?

    Which, come to think of it, makes a lot of sense. Oh, I guess that's what you meant in the first place. Never mind me, I'm running low on lifeblood caffeine. But let's say the scale is specified as 1 dot per inch. (big crappy billboards or whatever) Then the measurement should be in inches.

    If this is the case, then the unit of measurement is inches if a dpi is specified, pixels otherwise, and the code is:

    # 'use's and stuff go here my ($scale, $unit) = ($ARGV[0] =~ /^\d+$/) ? (shift,"in") : (1,"px"); for (map {glob} @ARGV) { my ($x,$y,$id) = imgsize($_); print "$_ width=",$x/$scale,"$unit, height=",$y/$scale,"$unit\n"; }

    Update: just a bit of tidying


    LAI
    :eof