Hello, lately I’ve been trying to adapt my pipeline to PIL, which could be downloaded here:
http://www.pythonware.com/products/pil/
It’s a much cleaner and more efficient solution for texture manipulation such as cutting, pasting, extending, etc… on textures which we do a lot of. I’ve found convertSolidTx
to be too clunky (slow, buggy and a memory hog, especially on really huge textures).
I’m running Maya 2009 and have dowloaded PIL version:
Python Imaging Library 1.1.6 for Python 2.5
Seeing that Maya 2009 is using Python 2.5.1, it would make sense that this version should work in theory. I load the libraries, and at first glance, it seems fine, e.g. in Maya Python Script Editor …
from PIL import Image
myImage = Image.open(“c:/temp/testSource.bmp”)
print myImage.format, myImage.size, myImage.mode
BMP (694, 1126) RGB
… so far so good, but when I do other simple things like first trying to show the image …
myImage.show()
Error: (0, ‘Error’)
Traceback (most recent call last):
File “<maya console>”, line 1, in <module>
File “C:\Python25\Lib\site-packages\PIL\Image.py”, line 1349, in show
_showxv(self, title, command)
File “C:\Python25\Lib\site-packages\PIL\Image.py”, line 1913, in _showxv
file = image._dump(format=format)
File “C:\Python25\Lib\site-packages\PIL\Image.py”, line 434, in _dump
self.save(file, format)
File “C:\Python25\Lib\site-packages\PIL\Image.py”, line 1305, in save
save_handler(self, fp, filename)
File “C:\Python25\Lib\site-packages\PIL\BmpImagePlugin.py”, line 236, in _save
ImageFile._save(im, fp, [(“raw”, (0,0)+im.size, 0, (rawmode, stride, -1))])
File “C:\Python25\Lib\site-packages\PIL\ImageFile.py”, line 489, in _save
s = e.encode_to_file(fh, bufsize)
IOError: (0, ‘Error’)
… and most importantly, trying to save it out …
myImage.save(“c:/temp/testDestination.bmp”)
Error: (0, ‘Error’)
Traceback (most recent call last):
File “<maya console>”, line 1, in <module>
File “C:\Python25\Lib\site-packages\PIL\Image.py”, line 1305, in save
save_handler(self, fp, filename)
File “C:\Python25\Lib\site-packages\PIL\BmpImagePlugin.py”, line 236, in _save
ImageFile._save(im, fp, [(“raw”, (0,0)+im.size, 0, (rawmode, stride, -1))])
File “C:\Python25\Lib\site-packages\PIL\ImageFile.py”, line 489, in _save
s = e.encode_to_file(fh, bufsize)
IOError: (0, ‘Error’)
… which first lead me to believe it’s a binary incompatibility between Maya’s Python (2.5.1) and PIL’s (2.5). However, when trying to do the exact same commands from standalone Python 2.5.4 (downloaded from python.org), it all works fine.
It’s kinda “half-working” in Maya it seems… does PIL completely work at all in Maya for anyone? If so, hope you wouldn’t mind lettin me in on the “secret sauce”. :):
Otherwise, I’m open to any other suggestions on libraries, classes, etc… anyone can point to for good, robust image-manipulation within Maya (even c++).
Thx for any feedback.