Query texture size - pixels

Is there any way I can query the size of a texture file using MEL? In other words, I have a file node and I would like to know the pixel dimension of that image.

--JeffD

Here's one way. May not be the best.

Included in the dev kit examples is a command plugin that will return the resolution of an image. I think it's called iffInfoCmd.

  • Matthew Durante

You can use the .outSizeX and .outSizeY attr on the file node to get the size in pixles.

string $xSize = getAttr ("file1.outSizeX");

I have had some problems with this reporting back the wrong size when the texture is higher than it is wide. Usually it give the x value for y and y for x in these cases.
When I need to really know I'm getting the right values I use a system call to imageMagick.

Hope that helps
--g

Great tip. I am a bit concerned about it reporting back the wrong size, though.

Great tip on ImageMagick! It looks like it is going to do some other things I need to do in my script also. I'm downloading it now!

--JeffD

yeah ImageMagick rocks, it's just too bad the system calls are so damn slow!
Also keep in mind that Maya ships with some imageMagick tools...
imconvert and imgcvt are both build off of imageMagick.

--g

Yeah, I noticed those in the Maya bin while searching my machine for conflicts on the default command names.

My head is spinning with all the new stuff I could do with this suite of tools.

Thanks again.

--JeffD