I'm using Wand in order to convert the first page from PDF files
into jpg files
and than, apply some processes with another script.
My problem is : Since yesterday, I obtain this error and I don't get any solution. I tried to re-install imagemagick
but none effects.
This is the Traceback message :
Traceback (most recent call last):
File "conversion.py", line 9, in <module>
convert = Image(filename="/Users/valentinjungbluth/Desktop/NAPS_PDF/" + PDF)
File "/usr/local/lib/python2.7/site-packages/wand/image.py", line 2744, in __init__
self.read(filename=filename, resolution=resolution)
File "/usr/local/lib/python2.7/site-packages/wand/image.py", line 2822, in read
self.raise_exception()
File "/usr/local/lib/python2.7/site-packages/wand/resource.py", line 222, in raise_exception
raise e
wand.exceptions.MissingDelegateError: no decode delegate for this image format `' @ error/constitute.c/ReadImage/504
Exception TypeError: TypeError("object of type 'NoneType' has no len()",) in <bound method Image.__del__ of <wand.image.Image: (empty)>> ignored
Do you have some idea about this problem ?
This is my script which let to convert PDF to JPG :
#-*- coding: utf-8 -*-
from wand.image import Image
import os
for PDF in os.listdir ("/Users/valentinjungbluth/Desktop/NAPS_PDF/") : #boucle sur tous les PDF du dossier
convert = Image(filename="/Users/valentinjungbluth/Desktop/NAPS_PDF/" + PDF)
name = PDF.split('.') #Récupération du nom
page = len(convert.sequence)
if page == 1 : #Nombre de page = 1
convert.compression_quality = 100 #Qualité en %
convert.save(filename="/Users/valentinjungbluth/Desktop/PDF_to_JPG/" + name[0] + ".jpg") #Enregistrement en JPEG sous la forme nom.jpg
elif page > 1 : #Nombre de page > 1
for frame in convert.sequence : #Pour chaque page
img_page = Image(image=frame)
img_page.compression_quality = 100 #Qualité en %
img_page.save(filename="/Users/valentinjungbluth/Desktop/PDF_to_JPG/" + name[0] + ".jpg") #Enregistrement en JPEG sous la forme nom.jpg
break
Thank you so much
EDIT :
It works with this simple script :
#-*- coding: utf-8 -*-
from wand.image import Image
import os
with Image(filename="/Users/valentinjungbluth/Desktop/NAPS_PDF/arrow.pdf", resolution=200) as convert :
convert.compression_quality = 150 #Qualité en %
convert.save(filename="/Users/valentinjungbluth/Desktop/PDF_to_JPG/test.jpg") #Enregistrement en JPEG sous la forme nom.jpg
SOLUTION :
On MacOSX, I have a file which is named : .DS_Store I have to delete it or just take .pdf files ! My error came from this .DS_Store file !