bpy and PIL / Pillow crash I posted this on BA but I'm posting it here as well.

I'm looking into manipulating images with Pillow in custom node trees. If I install Pillow and copy the PIL directory from 

C:\Python34\Lib\site-packages

to 

\bin\2.73\python\lib\site-packages

then I can import PIL just fine. I can save .png image files, but saving to any other image format type crashes Blender. 

But if I run Python 3.4 in a command prompt, I can import PIL (the one from my C:\Python34 installation), and read, modify and save to any of the supported image formats. 

The problematic code:

import bpy
import os
from extensions_framework import util as efutil
from PIL import Image, ImageEnhance, ImageFile

def realpath( path):
    return os.path.realpath( efutil.filesystem_path( path))

brightness = 2.0
# Use an image loaded into Blender.
img = bpy.data.images['preview.jpg']
orig = Image.open( realpath( img.filepath))
ImageFile.MAXBLOCK = max( orig.size) ** 2

# Brighten the image.
enhancer = ImageEnhance.Brightness(orig)
bright = enhancer.enhance(brightness)

# Save the new image.
img_path = ( os.path.sep).join( realpath( img.filepath).split( os.path.sep)[:-1])
img_name = realpath( img.filepath).split( os.path.sep)[-1][:-4]  # Remove '.jpg' from end
new_img = os.path.join( (os.path.sep).join( realpath( img.filepath).split( os.path.sep)))

# The following line crashes Blender.
# But if the string is changed to "_mod.png", it works.
bright.save( os.path.join( img_path, img_name + "_mod.jpg"))


What could the problem be? Why can't I do this from within Blender without it crashing?
I am using Pillow successfully on MacOSX but maybe not in the cleanest way.

In a nutshell, I'm using Blender's own python34 and I add a path to the proper version of Pillow in my script


Download Pillow for python34 and extract it in a folder – on MacOS, macport &amp; pip automatically take care of that for me
Take the path to Pillow within that folder
In your python script before you import Pillow, add the code below


Python

import sys
path_to_pillow = 'C:/somewhere_on_your_disk/pillow/'
sys.path.append(path_to_pillow)
from PIL import Image


I'll try to run your code and see if it works on my side.

Could you copy the error you're getting when using PIL with Blender ?