PDF to PNG > Problems with DPI

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
anbr
Posts: 3
Joined: 2016-07-01T02:04:13-07:00
Authentication code: 1151

PDF to PNG > Problems with DPI

Post by anbr »

Hi everybody!

I try to convert several PDFs (which consist of vector graphics ) to PNG-Files with the following code on command-line:

Code: Select all

mogrify -density 300 -format png *.pdf 
The size of the arising PNGs is correct, but unfortunaltely the resolution ist not (96 dpi instead of 300). I tried to add the command -resample 300 at different positions in the code as I read that the order matters, but I couldn't figure it out. Could you please give me some advice?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: PDF to PNG > Problems with DPI

Post by GeeMack »

anbr wrote:Could you please give me some advice?
Can you fill us in on which version of IM you're using and what OS you're working on?
anbr
Posts: 3
Joined: 2016-07-01T02:04:13-07:00
Authentication code: 1151

Re: PDF to PNG > Problems with DPI

Post by anbr »

Sorry, didn't think of that..

I'm running Fedora 18 and using ImageMagick 6.7.7-5. Actually I never cared about that before and was just happy that ImageMagick was already installed on this OS.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: PDF to PNG > Problems with DPI

Post by GeeMack »

anbr wrote:... just happy that ImageMagick was already installed on this OS.
Yep, IM is always good. Your 6.7.x... version is pretty old, so I don't know if it will help (or if it will even work), but you might try adding "-units PixelsPerInch" to your command ahead of the "-density 300" setting.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PDF to PNG > Problems with DPI

Post by snibgo »

As you are reading PDFs, another variable is the version of Ghostscript. Eg, I use 9.15 which is fairly recent.
snibgo's IM pages: im.snibgo.com
anbr
Posts: 3
Joined: 2016-07-01T02:04:13-07:00
Authentication code: 1151

Re: PDF to PNG > Problems with DPI

Post by anbr »

Thanks! Adding -units PixelsPerInch worked, even with my outdated version. So the PNG is the same pixel size as before but now the resolution is set to the specified value. Respectively, nearly the specified value (some applications shows 299 instead of 300) which I guess is due to the somewhere internal usage of pixels per centimeter.

Thank you for your efforts! :)
Post Reply