Skip to content

Instantly share code, notes, and snippets.

@mittalyashu
Last active October 19, 2019 02:08
Show Gist options
  • Save mittalyashu/e87fbf214376a85b923ff88e2229afd9 to your computer and use it in GitHub Desktop.
Save mittalyashu/e87fbf214376a85b923ff88e2229afd9 to your computer and use it in GitHub Desktop.
Python script to convert pdf file to JPG image
from pdf2image import convert_from_path
pdf_file_path = "path/to/pdf"
first_page = 16
last_page = 24
pages = convert_from_path(pdf_file_path, dpi=200, first_page=first_page, last_page=last_page, size=(3000, None))
page_count = first_page
for page in pages:
page.save("./image/image_"+ str(page_count) + ".jpg", "JPEG")
page_count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment