Using Python's Imaging Library I want to create a PNG file.
I would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page.
Is the resolution encoded in the image?
If so, how do I specify it?
And even if it is, does this have any relevance when it goes to the printer?
Divide the length of the photo in pixels, by the size you want to print it in in inches to find the ppi. For example, if you have a photograph that is 1800 pixels x 1200 pixels you can print it at 6” x 4” and have a high quality print as you'll be printing at 300ppi.
If an image is 4500 x 3000 pixels it means that it will print at 15 x 10 inches if you set the resolution to 300 dpi, but it will be 62.5 x 41.6 inches at 72 dpi. While the size of your print does change, you are not resizing your photo (image file), you are just reorganizing the existing pixels.
Start by choosing "File" and then "Print," and clicking the "Position and Size" settings. Usually, the default option is "Scale to Fit Media," which prints to the page margins. Deselect it, then manually enter scale, height and width values that equal the full size of your paper. Click "Print" to print your image.
The best way to know if your image is good for printing is by using a photo editing software like photoshop. Look your image settings and make sure that the resolution is at least 300 pixels per inch at the final size that it will be used.
As of PIL 1.1.5, there is a way to get the DPI:
im = ... # get image into PIL image instance
dpi = im.info["dpi"] # retrive the DPI
print dpi # (x-res, y-res)
im.info["dpi"] = new dpi # (x-res, y-res)
im.save("PNG") # uses the new DPI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With