pytroll/aggdraw

aggdraw.Draw for PIL image (python 3)

s-cork opened this issue · 7 comments

aggdraw.Draw(img) for python 3 TypeError: bad 'mode' attribute (expected string) - This seems to happen when the argument is a PIL Image

@mrcork Do you have a minimum code example that fails? What OS are you running this on and how did you install aggdraw and PIL (pip, conda, etc)?

Using PIL install with conda (have tried PIL 3.x up to 4.x)
I've installed aggdraw using git clone with this repository
macOS

I might be doing something wrong but:

from PIL import Image
import aggdraw

im = Image.new("RGBA",(100,100))
d = aggdraw.Draw(im)

Gives the above error

What if you use "RGB" instead of "RGBA"? It looks like all the tests in aggdraw use "RGB". I'll have to look in to why RGBA isn't allowed.

Just tried this with python 3.6 via conda on OSX High Sierra and your example code above worked for me.

I'm on Yosemite - maybe that's the issue...

You can see the code that is failing here: https://github.com/pytroll/aggdraw/blob/master/aggdraw.cxx#L592

What do you get if you run print(im.mode, type(im.mode))?

I think I had a different version of aggdraw - the pip uninstall wasn't quite enough. Have now reinstalled and is now working. Thanks for your patience