|Problems? Is your data what you think it is?|
Re: PerlMagick: How to Calculate an image size in milimiters?by Arguile (Hermit)
|on Jun 03, 2003 at 21:53 UTC||Need Help??|
The $image->Get( 'y-resolution' ) returns the number of pixels. Think of them as the ‘dots’ in <acronym title="Dots Per Inch">DPI</acronym>.
To determine the printable size from this without rescaling, you’d divide by the DPI to get the size in inches. I’ll leave the imperial -> metric conversions to you.
If you plan to resample an image ‘to-fit’ what you’d want is to determine the factor by which to resize. To do this you’d take the maximum paper size times the dpi, then divide by the image size.
The above however doesn't take into acount which dimension we need to fit to scale. If you want to maintain the aspect ratio you’d need to figure out which dimension to scale to, easiest would be to figure out both and take the min. factor.
You could also choose to switch orientation so that the highest pixel count always went along the longest page dimension.
8.5" x 11" is not A4 , it’s letter. I just used those dimensions for convenience. As for faxes, I think they can be 150DPI as well, but it would pay to check.