Created
May 5, 2020 16:54
-
-
Save Resousse/1f1e7aef5e775f7e245c13b01c8f88b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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