wand.exceptions.CorruptImageError
Posted: 2019-01-14T08:02:00-07:00
Hi, I would like some help to read files with wand in python. When I tried to open some files on wand the code gives me the following error:
raise e
wand.exceptions.CorruptImageError: unable to read image data `C:/Users/DSM/AppData/Local/Temp/magick-2964IqBjfCX3xNAi1' @ error/pnm.c/ReadPNMImage/1346
But I can convert the file through command lines (convert file.pdf file.jpg) using imagemagick.
My code in python:
def pdf_image(file, dir):
"""Convert pdf on image"""
name = re.sub('pdf', 'png', file.filename)
with Img(file=file, resolution=300) as img:
img.compression_quality = 99
img.save(filename=dir+'\'+name)
Is anyone have some thoughts about a solution?
Thank you in advance
raise e
wand.exceptions.CorruptImageError: unable to read image data `C:/Users/DSM/AppData/Local/Temp/magick-2964IqBjfCX3xNAi1' @ error/pnm.c/ReadPNMImage/1346
But I can convert the file through command lines (convert file.pdf file.jpg) using imagemagick.
My code in python:
def pdf_image(file, dir):
"""Convert pdf on image"""
name = re.sub('pdf', 'png', file.filename)
with Img(file=file, resolution=300) as img:
img.compression_quality = 99
img.save(filename=dir+'\'+name)
Is anyone have some thoughts about a solution?
Thank you in advance