Skip to content

Instantly share code, notes, and snippets.

@reddgr
Created October 7, 2024 11:56
Show Gist options
  • Save reddgr/772a3ac4220eabf1981a3828389f1641 to your computer and use it in GitHub Desktop.
Save reddgr/772a3ac4220eabf1981a3828389f1641 to your computer and use it in GitHub Desktop.
Convert all pages of a PDF into images with Python
# ! pip install pdf2image
# Download Poppler: https://github.com/oschwartz10612/poppler-windows/releases/
# Add the /bin Poppler directory to PATH
from pdf2image import convert_from_path
images=convert_from_path("file_name.pdf",
poppler_path="C:/Users/.../Release-24.08.0-0/poppler-24.08.0/Library/bin") # Your path to Poppler binaries
for i in range(len(images)):
images[i].save('pdf_to_image/page_'+ str(i) +'.jpg', 'JPEG')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment