9

I'm writing a django/python application and I need to convert PDF files uploaded by the user to JPEGs (files are scans)

I'm trying to use wand, with an ImageMagick backend (on OSX) and I keep getting the following error:

MissingDelegateError at /user_docs/upload/certificate/
no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/501

My current test code is as simple as:

with wandImage(filename='/Users/username/Pictures/telechargement.pdf') as img:
    img.format = 'jpeg'
    img.save(filename='/Users/username/Pictures/bzzz.jpeg')

Some information:

  1. The file exists (I verify with os.path.exists)
  2. I can convert the file from PDF to JPG on the command line using convert
  3. I tried to set DYLD_LIBRARY_PATH to include the ImageMagick lib directory
  4. identify -list configure | grep DELEGATES returns

DELEGATES bzlib fftw fontconfig freetype gs jpeg jng lcms2 lzma mpeg png tiff x11 xml zlib

Anyone has an idea?

Thanks

1 Answers1

2

OK, Found it! As always the key is RTFM:

http://docs.wand-py.org/en/0.4.0/guide/install.html#install-imagemagick-on-mac

I was missing the:

$ export MAGICK_HOME=/opt/local
BlitZ
  • 12,038
  • 3
  • 49
  • 68
  • 2
    The `MAGICK_HOME` environment variable is very important, see Anthony's [Hints & Tips](https://www.ict.griffith.edu.au/anthony/info/graphics/imagemagick.hints) document for additional info. – emcconville Jul 17 '15 at 15:47
  • Both links given are dead. The doc for installing ImageMagick is now found at [https://imagemagick.org/script/download.php](https://imagemagick.org/script/download.php). I can't find Anthony's Hints and Tips. – MDickten Nov 22 '22 at 10:07