PIL and Blender

seems like blender cannot import PIL as it it in the site-packages directory and blender import does not par subfolders of it

so I added the pil directory to the import path
but it makes blender crash with a “memory error”:


import Blender
import sys
dirpath=Blender.sys.dirname(Blender.Get('filename')) 
currentpath=dirpath.replace('\\','/')+'/' 

for p in sys.path:                  #will find the site-packages dir, add
if p.find("site-packages")!=-1: #the PIL dir to it and add this to the path
      sys.path.append(p+"\PIL")  <---causes the hanging/crash

did anybody succeded to use PIL in blender ???

appreciate if anyone answer this as it seems nobody replies to my threads
thx

This works for me (Windows XP, Blender 2.35a, Python 2.3, PIL 1.4 I think):

from PIL import Image as pilimage


i = pilimage.new('RGB', (256,256)) 

i.show()

Blender has an module of its own called Image, hence importing from PIL under a different name. I don’t know why you get a crash with your example though.

GREAT !
thx a lot m8 you saved my life
did not know PIL could launch a preview … cool