Printing Accurately Scaled Images From A Browser

5 posts by 3 authors in: Forums > CMS Builder
Last Post: September 9, 2015   (RSS)

By gkornbluth - September 5, 2015 - edited: September 5, 2015

Hi All,

I’m trying to accomplish what should be a relatively straight forward thing to do.

I want to print a series of artwork images pulled from an upload field directly from a browser, and need  the prints to be scaled at 1 inch to the foot.

I’ve entered the artwork width (in inches) into the image’s info1 field and the height (in inches) into the image’s info2 field

The math works to change the pixel size of the image, and if downloaded all resulting image, it will print correctly from within any image editing program.  

But, when I try to print the images directly from any browser, it prints smaller, and there  doesn’t seem to be a simple correlation between ppi and print size when print a number of images with different pixel dimensions.

I’ve tried everything I can think of, including trying to use the new image-resolution CSS tag, only to find that it’s not yet supported in any browser.

I’m lost... and hope that someone has dealt with this before, or has an idea how to solve the mystery.

Below is the code that I’ve put together so far.


Thanks,

Jerry Kornbluth

<?php $ppi = 96 // possible browser print resolution ?>
<>php $scale = 12 // scale inches per foot ?>
<?php foreach ($image_uploadsRecords as $record): ?>
<?php foreach ($record['uploads'] as $index => $upload): ?>
<?php $ratio1 = $upload['width']/$upload['info1'] // image pixel width / actual inches ?>
<?php $ratio2 = $upload['height']/$upload['info2'] // image pixel height / actual inches ?>
<?php $ratio3 = $ppi/$ratio1?>
<?php $ratio4 = $ppi/$ratio2?>
<?php $width = (($upload['width']*$ratio3))/$scale ?>
<?php $width = number_format($width, 0) ?>
<?php $height = (($upload['height']*$ratio4))/$scale ?>
<?php $height = number_format($height, 0) ?>
<div align="center"><br /><img src="<?php echo htmlencode($upload['urlPath']) ?>" width="<?php echo $width ?>" height="<?php echo $height ?>" alt="" /><br /><div align="center">
<br /><?php echo $upload['info1'] ?>''W (<?php echo $width ?>px) <?php echo $upload['info2'] ?>''H (<?php echo $height ?>px) at <?php echo $ppi ?>PPI<br />
<?php endforeach ?>
<?php endforeach ?>



The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hey Jerry.  Could you use the PDF generation plugin?

Cheers,

Tim (toledoh.com.au)

Hi Tim,

Thanks for responding.

I tried that but got the same results.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Thanks Greg,

I'll give it a try and post my results.

Didn't know about the custom flags.

Jerry Kornbluth.

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php