How to extract images from a pdf and reduce their size

  1. Extract the images into a temporary folder. Twiddle with the quality value to reduce the size.

    1
    2
    3
    4
    5
    6
    7
    8
    convert \
    -verbose \
    -density 150 \
    -trim \
    source-pdf-file.pdf
    -quality 50 \
    -sharpen 0x1.0 \
    image-prefix.jpg
  2. Create the pdf back from all the images.

    1
    convert *.jpg output-file.pdf

I am currently working on LiveForm which makes setting up contact forms on your website a breeze.