note
Arguile
<p>The <code>$image->Get( 'y-resolution' )</code> returns the number of pixels. Think of them as the ‘dots’ in <acronym title="Dots Per Inch">DPI</acronym>.</p>
<p>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.</p>
<p>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.</p>
<code>
use constant PAGE_WIDTH => 8; # 8.5" page with 0.5" of equal margins.
use constant DPI => 72; # Fax resolution.
# ...
$scale_factor = ( PAGE_WIDTH * DPI ) / $image->Get( 'y-resolution');
# ...
</code>
<p>The above however doesn't take into acount <em>which</em> 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.</p>
<p>You could also choose to switch orientation so that the highest pixel count always went along the longest page dimension.</p>
<div><strong>Note:</strong><p>8.5" x 11" is <em>not</em> 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.</p></div>
262796
262796