wand.exceptions.CorruptImageError

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
daniely.dsm
Posts: 1
Joined: 2019-01-14T07:45:58-07:00
Authentication code: 1152

wand.exceptions.CorruptImageError

Post by daniely.dsm » 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

Post Reply