I'm trying to convert some PDFs to jpegs using imagemagick . I'm working on win 10, 64 with python 3.62 - 64 bit and wand 0.4.4. I've been able to get wand working with ImageMagick-6.9.9-Q16-HDRI. I've set the Path and MAGICK_HOME env vars to
E:\ImageMagick-6.9.9-Q16-HDR
This allow:
from wand.image import Image
to work.
My script:
import os
magick_home=os.getcwd() + os.sep + "E:\ImageMagick-6.9.9-Q16-HDR"
os.environ["PATH"] += os.pathsep + magick_home + os.sep
os.environ["MAGICK_HOME"] = magick_home
os.environ["MAGICK_CODER_MODULE_PATH"] = magick_home + os.sep + "modules" + os.sep + "coders"
from wand.image import Image
.....
file_path = os.path.dirname(os.path.abspath(__file__))+os.sep+"myfile.pdf"
image_pdf = Image(filename=file_path, resolution=300)
image_jpeg = image_pdf.convert('jpeg')
I'm getting:
File "ocr_test.py", line 38, in <module>
image_pdf = Image(filename=file_path, resolution=300)
File "e:\Myenv\lib\site-packages\wand\image.py", line 2744, in __init__
self.read(filename=filename, resolution=resolution)
File "e:\Myenv\lib\site-packages\wand\image.py", line 2822, in read
self.raise_exception()
File "e:\Myenv\lib\site-packages\wand\resource.py", line 222, in raise_exception
raise e
wand.exceptions.MissingDelegateError: no decode delegate for this image format `PDF' @ error/constitute.c/ReadImage/504
How can I get this working?
EDIT:
Following your advice, I followed https://glenbambrick.com/2017/01/10/pdf-to-jpg-conversion-with-python-for-windows/ and installed ghostscript 9.22 - 32 bit. (I understand that the 64 bit won't work PythonMagick can't find my pdf files) I've set both Path and MAGICK_HOME env vars to contain:
E:\ImageMagick-6.9.9-Q16-HDR;E:\gs9.22\bin
I ran:
$ E:/ImageMagick-6.9.9-Q16-HDRI/convert --version
Version: ImageMagick 6.9.9-23 Q16 x64 2017-11-12 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps raw rsvg tiff webp xml zlib
I don't see gs or gslib. What should I do next?