MEL: How to check if an image has an alpha channel


#1

Hi people
Does anyone know of a command or a way to query if an image file has an alpha channel or not?

what i want to do is something like:
if (/THE FILE HAS AN ALPHA CHANNEL/) connectAttr -f ($fileNode + “.outTransparency”) ($lambert + “.transparency”);
else //dont do anything
Any ideas?


#2

Hi!
Most efficient way to get that info is:

getAttr IMAGE.fileHasAlpha;

where IMAGE should be replaced with the name of your object/image that should be already loaded as texture.
If return value is 1 there is alpha, if it is 0 there is no alpha.

Hope this helps!


#3

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.