tags:

views:

209

answers:

4

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?

+1  A: 

Printers have various resolutions in which they print. If you select a print resolution of 200 DPI for instance (or if it's set as default in the printer driver), then a 200 pixel image should be one inch in size.

Spikolynn
It's DOTS per inch, you need multiple dots to get proper (color)depth.
MSalters
+3  A: 

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
kylebrooks
nice! i'll try it out.
carrier
some PNGs don't have a DPI property - you'd have to set it to the "default" of (72, 72).
kylebrooks
A: 

Much is going to depend on the software you're using to print. If you're placing the image in a Word document, it will scale according to the DPI, up to the width of your page. If you're putting it on a web page, the DPI will not matter at all.

Mark Ransom
+1  A: 

Both image print size and resolution are relevant to printing an image of a specific scale and quality. Bear in mind that if the image is then included with a desktop publishing workspace (Word, InDesign) or even a web page, the image is then subject to any specified resolution in the parent document -- this won't necessarily alter the relative scale of the image in the case of desktop publishing programs but will alter image quality.

And yes, all images have a resolution property, which answers half your question - I don't know Python...

aesdanae