Getting Pillow working on GHPython

Hi guys!

As posted here I’m desperately trying to write 16bit/channel images using GHPython. There would be no problem if System.Drawing had correctly implemented the method to save 16bit/channel images…but that is not the case (please read the linked post for more details).

I’m trying to avoid a big workaround trying to use Pillow in GHPython but I got no luck. I’ve properly installed Pillow in my python 2.7 distribution and it worked find in console (importing the module and using it), the problem comes when importing it in GHPython:

from PIL import Image

im = Image.open("C:\R.jpg")
## print im.format, im.size, im.mode

im2 = Image.new("RGB", (512, 512), "white")
im2.save("G:\A.jpg")

This gives me:

Runtime error (ImportException): cannot import _imaging from PIL

I’ve double checked: I’m running Rhino 5 32bits, Python 2.7 32bits and the installed Pillow library is 32bit.

Has anyone try to get Pillow working? If the answer is yes: did you succeed? I would be open to a .NET library that writes 16bit/channel images…after all, I could use some VB.NET/C# code to the image creation process and Python for the rest.

Thanks in advance.

Ángel.
Sevilla, Spain.

Hi Ángel, I answered there, for what I could find.

1 Like

I’ve got PIL working on my Windows 7 computer (only after my IT guy did a bunch tinkering). It imports fine when I write a python script via IDLE. When I try to import it into ghpython, I get this error: Runtime error (ImportException): No module named PIL

My regular python script is able to access this library (PIL=Python Imaging Library), why can’t ghpython? I am not familiar with how libraries and modules stored and access. Is there a way to point ghpython to the folder where PIL resides?

1 Like