Extract images from PDF without resampling, in python?
Question: How might one extract all images from a pdf document, at native resolution and
format? (Meaning extract tiff as tiff, jpeg as jpeg, etc. and without
resampling). Layout is unimportant, I don't care were the source image is
located on the page.

I'm using python 2.7 but can use 3.x if required.


Answer: Often in a PDF, the image is simply stored as-is. For example, a PDF with a
jpg inserted will have a range of bytes somewhere in the middle that when
extracted is a valid jpg file. You can use this to very simply extract byte
ranges from the PDF. I wrote about this some time ago, with sample code:
[Extracting JPGs from
PDFs](http://nedbatchelder.com/blog/200712/extracting_jpgs_from_pdfs.html).

