0

I installed ImageMagick-6.9.9-Q8, set the Path to "C:\Program Files\ImageMagick-6.9.9-Q8" and wanted to run the following code:

from wand.image import Image as wi
import io
pdf = wi(filename = "sample2.pdf", resolution = 300)

and here I instantly get this error:

---------------------------------------------------------------------------
DelegateError                             Traceback (most recent call last)
<ipython-input-6-3e32bc349c64> in <module>()
      4 
      5 # reading the pdf file
----> 6 pdf = wi(filename = "sample2.pdf", resolution = 300)
      7 # and converting it to jpeg
      8 pdfImage = pdf.convert('jpeg')

~\Anaconda3\lib\site-packages\wand\image.py in __init__(self, image, blob, file, filename, format, width, height, depth, background, resolution)
   2742                     self.read(blob=blob, resolution=resolution)
   2743                 elif filename is not None:
-> 2744                     self.read(filename=filename, resolution=resolution)
   2745                 # clear the wand format, otherwise any subsequent call to
   2746                 # MagickGetImageBlob will silently change the image to this

~\Anaconda3\lib\site-packages\wand\image.py in read(self, file, filename, blob, resolution)
   2820             r = library.MagickReadImage(self.wand, filename)
   2821         if not r:
-> 2822             self.raise_exception()
   2823 
   2824     def close(self):

~\Anaconda3\lib\site-packages\wand\resource.py in raise_exception(self, stacklevel)
    220             warnings.warn(e, stacklevel=stacklevel + 1)
    221         elif isinstance(e, Exception):
--> 222             raise e
    223 
    224     def __enter__(self):

DelegateError: PDFDelegateFailed `The system cannot find the file specified.
' @ error/pdf.c/ReadPDFImage/809

In general I have many issues with Anaconda lateley as it is almost impossible to install any packages. Hope someone could help me with this issue.

Thanks!

Marco
  • 31
  • 2
  • Have you tried typing the full path instead of `sample2.pdf`? – mallet Nov 20 '17 at 21:18
  • 1
    ImageMagick needs Ghostscript to read PDF files. Did you install or have installed Ghostscript and can ImageMagick find it. If it is installed, be sure it is in your anaconda/wand environment PATH, if there is such. Otherwise, you may have to edit the ImageMagick delegates.xml file to put the full path to gs in the sDEVICE parameter. You can see if Ghostscript is installed via: `convert -version` and see if it lists gs or gslib. Or `gs --version`. – fmw42 Nov 20 '17 at 23:43
  • @fmw42 thank you, that was the issue! I had ghostscript installed via pip, but anaconda did not find it, so I reinstalled it in the right folder and it worked perfectly :-) – Marco Nov 21 '17 at 14:09

0 Answers0