Forum Documentation

Print Image Size

Ben
How is it, exactly, that Prince determines the size of a graphic? It seems dependent on the DPI but I can't really figure it out. When I open the graphic in Macromedia Fireworks, there is a property called "Print Dimensions," but I know Prince isn't using these, because the dimensions I've set are much larger than the ones that are output.
mikeday
Unless you specify an explicit size for an image using the width/height properties, Prince will determine the intrinsic size from the image resolution (DPI), which can be overridden using the prince-image-resolution property:

prince-image-resolution: 300dpi;        /* set an explicit DPI */
prince-image-resolution: normal;        /* 1 image pixel maps to 1px unit */
prince-image-resolution: auto, normal;  /* auto-detect, fallback to normal */
prince-image-resolution: auto, 96dpi;   /* auto-detect, fallback to 96dpi */

Not all images have an internal resolution set, so sometimes you may need to specify an explicit resolution. Alternatively, specifying a resolution of "normal" means that an image that is 100 pixels wide will be the same size on the page as a block that is 100px units wide.

I'm not sure about the "Print Dimensions" property in Macromedia Fireworks; it is possible that it could be setting some Macromedia-specific image metadata that Prince does not know about rather than setting the DPI value -- is there a separate setting for DPI/resolution? It could be setting the DPI in a way that Prince does not understand; if you send us a test image that exhibits odd behaviour we can try and see what is going on.
Ben
Yeah the Fireworks "Print Dimensions" are separate from the DPI. When you change these dimensions, the DPI does not change at all, nor does the regular Width and Height dimensions. I have no idea what these other Dimensions are (they are listed right along with the regular dimensions, however, so it leads me to believe they are somewhat important... atleast to Fireworks).
Yeah I have a large xml that is crashing Prince. Rather, it is freezing it. This is in regards to the question I was asking about for the topic "Error Log" under How Do I...?
GC Warning: Repeated allocation of very large block (appr. size 7061504):
May lead to memory leak and poor performance.

However, I do not get this error anymore for whatever reason, but Prince does freeze during the transform. I know it has something to do with the graphics. But the problem is so vague I have not been able to write a bug report about it yet. I am still searching.
The issue is fixed, however, when I resize the image to be something smaller. The problem is strange, however, because it only exists under certain conditions which I have not been able to pinpoint. If I just translate some XML with the image by itself, it works fine regardless. Prince only freezes when the image is used within a large block of xml (like 15000 lines). And even then....?
Sorry for a long answer with no conclusion, but I will let you know what I find out.
mikeday
May I ask how big is the image, and what format? (TIFF/PNG/JPEG/GIF)
mikeday
Ah, I think we have identified the image handling problem that is causing both the warning messages and the freezing.

It should be fixed in the new release :D
Ben
Wow you guys are real good. It's like you fixed a problem I wasn't even able to describe. Well that's good. I have been on quasi-vacation the past week or so, so I'm sorry I wasn't able to get back to you at a convenient time. I'd be very interested in running this xml through the next prince release to see the results.
THANKS PRINCE TEAM!
Ben
PS - I got your e-mail Mike, thank you!
PPS - In the beta4 Prince release, we just found out the problem could be avoided by changing all the png graphics to jpeg. Don't know if this helps to know?
Ben
Michael-
The new Prince RC fixed the problem, thank you very much! Your team does a great job!
Ben
Anonymous
Is there any way to specify the dpi for background images, or does it only work for inline ones?
mikeday
There is no way to specify the resolution of background images at this time; I think that we would need to add a new property, 'prince-background-image-resolution', that would be treated equivalently to the image-resolution property but apply to the background image of the current element.

I will add it to the roadmap for the next release :)
mikeday
We have added support for the prince-background-image-resolution property to Prince 6.0 rev 3, available now. Thanks for raising the issue! :)
ppkrauss
No effect on PDF size changing prince-image-resolution, it is a bug?

mikeday
Specifying prince-image-resolution and prince-background-image-resolution only affects the default DPI of images, ie. makes them physically bigger or smaller on the page, it does not affect the number of pixels in the image, so the PDF file size will be the same.

Currently if you want to reduce PDF file size you can recompress JPEG images at a lower quality level with the prince-image-magic property. (Or convert PNG images to JPEG, in the latest builds).

In future releases of Prince we may provide the ability to rescale images to make them smaller.
ppkrauss
Thanks @mikeday (!). Perhaps what user need at prince command is only a "ImageDownsampleThreshold" option (see gs).

@Ben, if you prefer to use one good PDF as source for other downsampled PDFs, an external tool like Ghostscript (gs), is a good alternative. See this "How to" for downsample images within PDF.

Edited by ppkrauss