4

I'm having issues using these three together. I believe wand is not recognizing the ImageMagick libraries but I'm not sure.

Environment: Python 3.5.1 :: Anaconda 4.0.0 (64-bit) Windows 7

Set up instructions I took:

  1. Installed ImageMagick-6.9.4-Q8 (x64) with the "C/C++ development headers options checked. (Installed to C:\Program Files\ImageMagick-6.9.4-Q8)
  2. Set MAGICK_HOME envar C:\Program Files\ImageMagick-6.9.4-Q8
  3. Installed wand from pip

My code:

import wand
...
with wand.image.Image(filename=source_file, resolution=(RESOLUTION, RESOLUTION)) as img:
...

Traceback:

    Traceback (most recent call last):
  File ".\pdf_convert.py", line 31, in <module>
    ret = pdf2jpg(f, target_file, 2480)
  File ".\pdf_convert.py", line 10, in pdf2jpg
    with wand.image.Image(filename=source_file, resolution=(RESOLUTION, RESOLUTION)) as img:
AttributeError: module 'wand' has no attribute 'image'

From everything I've seen I've followed the right setup instructions. I am using the 64 bit version of ImageMagick with the 64 bit version of Anaconda. This was working with me before until I started using Anaconda (before I was using regular 32 bit Python and 32 bit ImageMagick.)

Is there something I'm missing? Why is wand not working correctly?

DataDude
  • 69
  • 1
  • 7

2 Answers2

2

Try this

from wand.image import Image

with Image(filename=source_file, resolution=(RESOLUTION, RESOLUTION)) as img:
    pass

Is there something I'm missing? Why is wand not working correctly?

I believe it is working as expected, and the original architect did not intend to allow top-package-level shortcuts (i.e. import wand). This kinda makes sense as integrates to IM with , and does not attempt to resolve libraries during setup.py.

You can modify the package to include the module shortcuts your expecting by adding the following.

# wand/__init__.py
import api
import color
import compat
import display
import drawing
import exceptions
import font
import image
import resource
import sequence
import version

But I wouldn't recommend this. The from package.module import Class is a lot more cleaner.

emcconville
  • 23,800
  • 4
  • 50
  • 66
1

If you are using PIL.Image as well then use:

from wand.image import Image as wand_image_Image
import PIL

Aaj Kaal
  • 1,205
  • 1
  • 9
  • 8