Convert PDF -> PNG with the right size

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
Laurent
Posts: 2
Joined: 2011-03-30T09:51:13-07:00
Authentication code: 8675308

Convert PDF -> PNG with the right size

Post by Laurent »

Hi all


I have a PDF file containing one picture (which is very vectorial : it was produced by laTeX/pstrcicks). I'd like to have a PNG from it.

First try :
convert MyImage.pdf MyImage.png

Problem : the image is too small (smaller than the original pdf) and then got ugly when resized.

Second try :
convert MyImage.pdf -resize 200% MyImage.png

Problem : the exit has not the expected quality.


Since PDF is vectorial, it is possible to produce a correct PNG image of arbitrary size, no ?

In fact I can open the PDF in Gimp and ask Gimp to convert the PDF into a 300% image. Gimp takes the vectorial information into account
and exports a big and beautiful PNG picture.

What I would like to do is to convert a PDF into a PNG and impose the size of the png picture without lose of quality.

I hope I've been clear in my explanation. Any help is welcome !

thanks
Laurent
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert PDF -> PNG with the right size

Post by magick »

Try this command:
  • convert -density 400 MyImage.pdf -resize 25% MyImage.png
Laurent
Posts: 2
Joined: 2011-03-30T09:51:13-07:00
Authentication code: 8675308

Re: Convert PDF -> PNG with the right size

Post by Laurent »

convert -density 400 MyImage.pdf -resize 25% MyImage.png
That makes the work even with -resize 300% !
Thanks

It is possible to impose the size of the new picture in centimeters instead of pixels or proportion ? I didn't saw that on the page dedicated to resize
My point is that the picture is created by LaTeX-pstricks and that I know the so-called boundingbox that is given in
centimeters (xsize x ysize).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert PDF -> PNG with the right size

Post by fmw42 »

try adding -units pixelspercentimeter

my nominal computation is 72dpi*4=288 so

convert -density 288 MyImage.pdf -resize 25% MyImage.png

so try

72dpi=72/2.54=28dpc

28*4=112

convert -units pixelspercentimeter -density 112 MyImage.pdf -resize 25% MyImage.png

But you can make the density larger and get a bigger resulting png
Post Reply