Tag Archives: pdf

Converting a PDF to JPG and back again, without looking terrible

Sometimes you need to convert a pdf to jpg, mess around with it, then recreate a pdf. Here’s the method I use:


convert -density 400 file.pdf -alpha remove file.jpg # this create file-0.jpg, file-1.jpg, etc. Between 300-600 is a good density, alpha remove is needed if there is transparency in the pdf
gimp file-0.jpg
convert -units PixelsPerInch -density 400 -quality 25 $(ls -v file-*.jpg) file.pdf # gimp usually uses a dpi of 72, so need to change resolution back to 400, a high quality = large file

That’s it! Almost. If there’s transparency in the pdf, jpg won’t like it so you’ll need to use png. But PNG doesn’t automatically add numbers, so you need to do:


convert -density 400 ~/Downloads/PBH.PDF pbh-%d.png

Sometimes you need to convert the pngs to jpg before making a pdf. YMMV.