title: Convert Pdf to Png with Image Magick tags: #convert #pdf #png #image #imagemagick #magick This uses Image Magick (or [ImageMagick](https://imagemagick.org/index.php)) ```bash convert -density 150 presentation.pdf -quality 90 output-%3d.jpg # all pages convert -density 150 presentation.pdf[0] -quality 90 test.jpg # one page convert -density 150 presentation.pdf[0] -quality 90 -resize 50% test.jpg ``` To force width, use resize and a height larger than needed, e.g. for A4 we can use a height twice the desired width (`-resize` will not stretch to fill, but resize until the image just fits in the box). ```bash convert -density 300 inv1.pdf -resize 1920x3840 -quality 80 inv1-%02d.jpg ``` also ```bash convert -density 300 inv1.pdf -resize 1920x3840 -background white -alpha remove -alpha off %d.png ``` ## Cygwin Make sure you have ghostscript installed. ## Security Error If you get ``` attempt to perform an operation not allowed by the security policy `PDF' ``` then edit `/etc/ImageMagic-6/policy.xml` and find the line ```xml ``` and change it to ```xml ```