Friday, January 23, 2015

how to convert pdf to jpg or png with high quality result with imagemagick

If the pdf file contains only images:

 

convert -density 150 -trim input.pdf -quality 100 -sharpen 0xx1.0
output.jpg

 

But, if the pdf file contains both images and text:

 

convert  -density 288 model-of-the-standing-desk.pdf -background white -flatten -resize 80% model-of-the-standing-desk.png

 

You may also need to add this line:

 

 <policy domain="coder" rights="read | write" pattern="PDF" />

 

inside the file /etc/ImageMagick-7/policy.xml

just before the line:

 

 </policymap>


too.