I want to test some basic image processing from Maya via Python.
I’ve installed Python 2.7 and the PIL-package - and then copied the PIL folder to
X:\Autodesk\Maya2014\Python\Lib\site-packages\
Now I’m trying to multiply each pixel in an image by 1.2 using the below code:
from PIL import Image
im = Image.open(r"X: he\path est.tga")
im.point(lambda i: i * 1.2)
im.save(r"X: he\path est.tga")
However, this raises an error:
Error: The _imaging C module is not installed
…so I added another import and then tries to run the script:
from PIL import _imaging
…but then I get the error: # ImportError: DLL load failed: %1 is not a valid Win32 application.
Also, just doing a global import doesn’t fix it:
import PIL
…which suggests that maybe “the problem might be that the module found by Python isn’t compatible with the Python interpreter”
And that would suck because as most of us know, Autodesk use their own versions of Python in Maya -_-
I’ll be damned. That’s just plain idiotic comming from Autodesk.
Ok, that does explain the problem - but it doesn’t help me because I have no idea how to compile, decompile or recompile stuff.
ive been trying for the past hour or so, but realized trying to compile with 2012 isnt going to work And my 2010 express doesnt have a 64bit compiler so im SOL until i can get a real 2010 version.
In my scripts that use PIL, I usually use some standalone modules executed with os.system. I want these modules to work whether or not the user has Maya, but I know that’s not an option in all cases. If you’re just playing with PIL, though, that’s a good way to get started.
So is this a valid method? I was able to import PIL, Image and _imaging in Maya doing this, but I haven’t played with it much. I’m on OSX.
[QUOTE=TheMaxx;23443]ive been trying for the past hour or so, but realized trying to compile with 2012 isnt going to work And my 2010 express doesnt have a 64bit compiler so im SOL until i can get a real 2010 version.
Sorry[/QUOTE]
You should be able to compile it with the Windows 7 SDK. Although some components which use VS projects may be tricky to compile because you have to do it from the command line with msbuild. Definitely try to build it first without any addons like littleCMS, Freetype and whatever else. I think that shouldn’t be too difficult. zlib should also be fairly straight forward to build with the Win 7 SDK only.
That seems to be working for me so far, maybe it’s a bit of hack, though.[/QUOTE]
There must be some other reason you get this working because it’s not a pathing problem.
To confirm this, I appended the path to the PIL folder like in your example, and then tried running my Python code that multiplies the pixels.
Result: same error as before.
So somehow you have an _imaging module that is compatible with Maya 2014
EDIT: On a side note: Does this issue mean that if one is to develop a public tool using PIL, you have to include the following PIL “versions” in the download for said tool?:
PIL 1.1.7 for Python 2.7 - compiled in VS2010 (x86) - For Maya 2014 users using the x86 version of the app
PIL 1.1.7 for Python 2.7 - compiled in VS2010 (x64) - For Maya 2014 users using the x64 version of the app
PIL 1.1.7 for Python 2.6 - For Maya 2013 users and below
…or am I mistaken?
EDIT2: It seems that another TA (Christian Åkesson) has already compiled PIL for Maya 2014 x64. Check this out: http://christianakesson.com/2013/4615
No more error messages, but the code I wrote in the OP doesn’t seem to work. No multiplication is done on the pixels! Tried pretty much everything on http://effbot.org/imagingbook/introduction.htm so either the modules are not working or my code is wrong.
[QUOTE=Nightshade;23448] EDIT: On a side note: Does this issue mean that if one is to develop a public tool using PIL, you have to include the following PIL “versions” in the download for said tool?:
PIL 1.1.7 for Python 2.7 - compiled in VS2010 (x86) - For Maya 2014 users using the x86 version of the app
PIL 1.1.7 for Python 2.7 - compiled in VS2010 (x64) - For Maya 2014 users using the x64 version of the app
PIL 1.1.7 for Python 2.6 - For Maya 2013 users and below[/QUOTE]
Yes it does, but I think you can compile your tool and it’s extensions into a single .exe… I dunno I have never tried that…
[QUOTE=haiddasalami;23453]I have used py2exe to get a single exe. Took bit of digging around to get it to work but it does :D[/QUOTE]
A follow up question on this matter:
Say that I want this tool to be -for- Maya (ie: it loads up in Maya, and uses Maya commands to build a UI for said tool), would it then be easier to just take all those PIL Python files - and the rest of the stuff my tool uses - and make a Maya plugin for it?
I’ve never done any compiling of any sort, but eventually want to learn how to compile plugins for Maya that the user then can just install via some say, open-source installer or something. (I like user-friendlyness!)
[QUOTE=RobertKist;23446]You should be able to compile it with the Windows 7 SDK. Although some components which use VS projects may be tricky to compile because you have to do it from the command line with msbuild. Definitely try to build it first without any addons like littleCMS, Freetype and whatever else. I think that shouldn’t be too difficult. zlib should also be fairly straight forward to build with the Win 7 SDK only.[/QUOTE]I tried, but i think my 2010 installed is boned as the sdk wont install. I’ll see if i can get a full version and build some of these things, im sure this wont be the last.The lfd site is nice until it comes to the maya bins, then youre boned