ImageMagic library not without reason is called magic, it can handle image operations like scale,resize,rotate,filter,clip and 1000+ others.

# PDF -> JPEG

Here is simple CLI command to extract one page from PDF file and save it as JPEG image

convert -density 300 doc.pdf[160] page.jpg

Where

  • 300 is DPI, more better quality
  • [160] is page number, starting from zero. Can be list [0,1,2] or range [1-10]
  • page.jpg is output file, image type is based on extension
Easy!

# Backwards, JPEG -> PDF

If you need to generate PDF from set of images you can try these commands

convert *.jpg foo.pdf
convert -page A4 red.jpg  -gravity center -format pdf out.pdf