Skip to content

Instantly share code, notes, and snippets.

@idcesares
Created August 11, 2021 16:26
Show Gist options
  • Save idcesares/7c5e22bb963dd9d57fdf4e48b55f023e to your computer and use it in GitHub Desktop.
Save idcesares/7c5e22bb963dd9d57fdf4e48b55f023e to your computer and use it in GitHub Desktop.
Convert a PDF file to image using poppler and pdf2image
# Install poppler using chocolatey
# choco install poppler
# Imports
import pdf2image
import os
# Function to convert PDF to image (JPEG)
def to_image(path):
images = convert_from_path(path)
for i in range(len(images)):
images[i].save(path + 'page'+ str(i) +'.jpg', 'JPEG')
# Run
path = "" # Enter path
to_image(path) # Run function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment