Page 1 of 1

Convert PDF -> PNG with the right size

Posted: 2011-03-30T10:02:49-07:00
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

Re: Convert PDF -> PNG with the right size

Posted: 2011-03-30T10:25:34-07:00
by magick
Try this command:
  • convert -density 400 MyImage.pdf -resize 25% MyImage.png

Re: Convert PDF -> PNG with the right size

Posted: 2011-03-31T01:06:29-07:00
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).

Re: Convert PDF -> PNG with the right size

Posted: 2011-03-31T10:03:41-07:00
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