PNG to PDF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
adam.w.knox

PNG to PDF

Post by adam.w.knox » 2010-08-03T17:29:41-07:00

Hello I am trying to compile several PNG images to PDF.
The original images are 72ppi, and I would like the pdf to be as well.
I'd like to have a quality of 80 or 90%

I was using the code

Code: Select all

convert image1.png image2.png image3.png output.pdf
When I went to look at the output.pdf the resolution was a bit wonky. 75% zoom was the natural resolution of the image, and 100% zoom on the pdf was pixelated.
I tried tossing in different code snippets

Code: Select all

-quality 100
-density 72x72
-resize 100%
I tried these in different combinations and they all produced different problems with the new pdf.

Am I missing a parameter?

Any help would be greatly appreciated, I've been scowering the web but this has been a bit over my head.

Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: PNG to PDF

Post by Drarakel » 2010-08-03T21:45:24-07:00

First check if your images really get read as 72 ppi ("identify -verbose image" should show about 28.35 PixelsPerCentimeter when it's PNG).
Then: What software do you use to view the PDF? If it's something like Adobe Reader, then you might have to set the viewing resolution in the preferences to 72 ppi.

adam.w.knox

Re: PNG to PDF

Post by adam.w.knox » 2010-08-04T10:39:48-07:00

Drarakel wrote:First check if your images really get read as 72 ppi ("identify -verbose image" should show about 28.35 PixelsPerCentimeter when it's PNG).
Then: What software do you use to view the PDF? If it's something like Adobe Reader, then you might have to set the viewing resolution in the preferences to 72 ppi.
28.35, it looks like it is being read correctly.
I am using evince on Ubuntu. Document Viewer 2.30.3 I couldn't find any viewing resolution preferences.

immortal26

Re: PNG to PDF

Post by immortal26 » 2010-08-04T11:03:41-07:00

Give this a shot and see what happens:

Code: Select all

convert image1.png image2.png image3.png -quality 100 -units PixelsPerInch -density 72x72 output.pdf

adam.w.knox

Re: PNG to PDF

Post by adam.w.knox » 2010-08-04T11:41:33-07:00

Same issue. The image has a width of 1020px but once it is converted to pdf and viewed at 100% the width is larger than my screen (1280px).

Maybe the issue is with my pdf viewer? That seems strange though

immortal26

Re: PNG to PDF

Post by immortal26 » 2010-08-04T12:00:26-07:00

That's what I'm thinking.
What PDF viewer are using?
Have you tried viewing it with adobe acrobat reader?

It almost sounds like it's zooming to your screen resolution :P

adam.w.knox

Re: PNG to PDF

Post by adam.w.knox » 2010-08-04T13:59:21-07:00

immortal26 wrote:That's what I'm thinking.
What PDF viewer are using?
Have you tried viewing it with adobe acrobat reader?

It almost sounds like it's zooming to your screen resolution :P
I am using eVince (Document Viewer) on Ubuntu. It come pre-installed. I haven't been able to test the pdf and see how it looks through Adobe.

When I viewed the pdf I made sure (triple checked) that the zoom was set to 100% and then I started zooming out to get to what I know the width ought to be.

User avatar
fmw42
Posts: 25752
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PNG to PDF

Post by fmw42 » 2010-08-04T15:01:48-07:00

I am not an expert on PDF files, but I don't think they have any natural resolution themselves as they are vector format. So you have to set the reading in density when you open the file. The images within do however have a natural density or resolution.

When I do:

convert zelda3.png lena2.png -quality 100 -units PixelsPerInch -density 72x72 tmp.pdf

and open tmp.pdf in Mac PREVIEW it enlarges to fill the size of the window as I enlarge the window.

If I open it in Adobe Acrobat Reader, there is an internal Acrobat Reader parameter you can set in the preferences to set the default display resolution so that it opens with that resolution/density. But if you change it, the pdf page (image) gets larger or smaller.

Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: PNG to PDF

Post by Drarakel » 2010-08-04T20:19:01-07:00

Your eVince viewer is probably using 96dpi when displaying the PDFs at 100% (and 72dpi at 75%, as 72/96=75%). But even if you can't change that, you shouldn't worry. The PDFs itself are fine.
Of course, if you don't mind about changing the print size, then you can 'fool' eVince by changing the resolution value before creating the PDF:

Code: Select all

convert -units PixelsPerInch image1.png image2.png image3.png -density 96 output.pdf

Post Reply