How to print an image at a certain resolution

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
terryb
Forum Newbie
Posts: 1
Joined: Mon Apr 21, 2008 8:47 pm

How to print an image at a certain resolution

Post by terryb »

Hi everyone,

Here's the scenario. I have a scanned image of a letter size form and I'm writing a PHP script that fills in this form. My problem is this, I scanned the image in at 300 dpi and saved it as a PNG file. I've finished the programming to fill in the form and display the filled in form. My problem now is printing the form. The image is 2892 x 2358 (H x W) which should print out as 9.64" x 7.86" however I'm unable to get Windows or any of the browsers i've tried (IE 6, IE 7, Firefox, Opera) to print it out properly. I think they all assume the image is 72dpi and attempt to print it out as such, resulting in an oversized printout.

I'm stuck. Any ideas?
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: How to print an image at a certain resolution

Post by novice4eva »

you might want to check out image manipulation functions provided by PHP. Here is where you can start, i think there is example there giving the right solution too :wink:
http://www.php.net/imagecopyresampled
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: How to print an image at a certain resolution

Post by onion2k »

novice4eva is wrong. You don't need to resize the image itself. You need to set the print resolution, which is different to the image resolution. As far as I know that can't be done in PHP or in HTML or Javascript. The only solution I know works is to embed the image in a PDF file using a library like FPDF.
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: How to print an image at a certain resolution

Post by novice4eva »

OUCH!! hurts to be wrong, sorry.... :wink:
Post Reply