Skip to content

Instantly share code, notes, and snippets.

@Resousse
Created May 5, 2020 16:54
Show Gist options
  • Save Resousse/1f1e7aef5e775f7e245c13b01c8f88b4 to your computer and use it in GitHub Desktop.
Save Resousse/1f1e7aef5e775f7e245c13b01c8f88b4 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# pip install pdf2image
from pdf2image import convert_from_path
import sys
if len(sys.argv) < 2:
print("Donner un fichier a convertir en argument")
sys.exit()
fichier = sys.argv[1][:-4]
pages = convert_from_path(sys.argv[1])
cpt = 1
for page in pages:
if len(pages) == 1:
target = fichier + '.jpg'
else:
target = fichier + '_' + "{:03d}".format(cpt) + ".jpg"
page.save(target, 'JPEG')
cpt += 1
print (fichier + " : " + str(len(pages)) + " pages")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment