Ghostscript, PDF vers Jpeg - erreur fatal
Bonjour,
Après avoir mise en place la conversion de fichier de PDF en Jpeg, sous Python 2.7, nous avons souhaiter profiter d'une migration de nos serveurs pour 'enfin' passer à python3. Les premiers résultats sont très concluants, notamment sur la vitesse d’exécution.:D
Mais je bug sur Ghostscript. Installation via Anaconda3.
1. Installation de Ghosscript 9.53.3; https://www.ghostscript.com/download/gsdnld.html
2. Installation du module:
Code:
<base> conda install ghostscript
A ce stade, le module reste introuvable lors de son import "import ghostscript", malgré qu'il soit bien affiché comme 'installé' dans l'interface graphique d'Anaconda. Je l'ai réinstallé avec
Code:
pip install ghostscript
là "import ghostscript" fonctionne.
3.Je reprend mon code python2, je corrige la syntaxe en python3, je test. Là, j'ai une 'erreur fatale' que je ne comprend pas et dont toutes les pistes trouvées sur le net ne m'aide malheureusement pas.:aie:
Mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| import ghostscript,locale
#------definition fonction----
def pdf2jpeg(pdf_input_path, jpeg_output_path):
args = ["pef2jpeg", # actual value doesn't matter
"-dNOPAUSE",
"-sDEVICE=jpeg",
"-r300", #dpi
"-sOutputFile=" + jpeg_output_path,
pdf_input_path]
encoding=locale.getpreferredencoding()
args=[a.encode(encoding) for a in args]
print (args)
GS = ghostscript.Ghostscript(*args)
GS.exit()
# ghostscript.Ghostscript(*args)1 # solution 2 => erreur fatale aussi
# with ghostscript.Ghostscript(*args) as g:
# ghostscript.cleanup() # solution 3 => erreur fatale aussi
#---test---
pdf_input_path =r"L:\...\ouverturePDF.pdf"
jpeg_output_path =r"L:\...\test IMAGE.jpg"
pdf2jpeg(pdf_input_path, jpeg_output_path) |
le message d'erreur:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Traceback (most recent call last):
File "\\srv_fichiers\.....\Module_py3\Mon_ghostscript_temp.py", line 64, in <module>
pdf2jpeg(pdf_input_path, jpeg_output_path)
File "\\srv_fichiers\.....\Module_py3\Mon_ghostscript_temp.py", line 48, in pdf2jpeg
GS = ghostscript.Ghostscript(*args)
File "C:\ProgramData\Anaconda3\lib\site-packages\ghostscript\__init__.py", line 171, in Ghostscript
return __Ghostscript(__instance__, args,
File "C:\ProgramData\Anaconda3\lib\site-packages\ghostscript\__init__.py", line 74, in __init__
rc = gs.init_with_args(instance, args)
File "C:\ProgramData\Anaconda3\lib\site-packages\ghostscript\_gsprint.py", line 273, in init_with_args
raise GhostscriptError(rc)
GhostscriptError: Fatal |
quelqu'un as-t-il déjà rencontré cette erreur (en python 3), svp?
Merci de votre aide.