PDA

View Full Version : How can I know whether tga is 32bit via mel


cgerchenhp
03-28-2009, 12:01 PM
I want use mel for QA. check the tga file whether is 24 bit or 32 bit.
Can it be done via in mel, or query the file size ?(disk size, not the image size)
Thank you.

cbamber85
03-29-2009, 09:19 AM
You can work it out from the image dimensions and the file size, but as far as I'm aware there is no way of querying image dimensions in MEL (without loading it into Maya first, which I imagine is what you don't want).

There will be a myriad of methods in Python though.

Robert Bateman
03-30-2009, 10:42 AM
You can work it out from the image dimensions and the file size, but as far as I'm aware there is no way of querying image dimensions in MEL (without loading it into Maya first, which I imagine is what you don't want).

Assuming the tga is uncompressed, and assuming the tga doesn't insert text between the header and the image data, and assuming the tga isn't colour mapped, and assuming the tga doesn't use footer information, and assuming there's no offset to the image data, then yes that'll work (but it won't be long until you hit one of the previous caveats so it might not be a great idea).

In theory you could load the 16th byte from the binary header into mel, and check that. However without decent bit manipulation, and without a way of reading unsigned char's, that's more or less impossible.

You could test the image in mel to see if it's 32 or 24 bit, however IIRC in maya MImage loads all images as 32bit, so that's not much use.

So basically, the answer is no....

ewerybody
03-30-2009, 10:44 AM
the difference between 24 and 32bit tga is the alphachannel as far as I know, right?

there is a "fileHasAlpha" attribute at each file texture you put into Maya.
I made a quick check with 2 tgas:
getAttr Untitled_1_1.fileHasAlpha;
// 1 //
getAttr Untitled_2_1.fileHasAlpha;
// 0 //
seems to work. For the filesize you'd have to query the system.

btw: In terms of maya-commands and functions Python has exactly the same possibilities as Mel! Maybe there is a module you can do more filestuff with... Or you actually write a py-plugin! *shrug*

Robert Bateman
03-30-2009, 10:48 AM
the difference between 24 and 32bit tga is the alphachannel as far as I know, right?

there is a "fileHasAlpha" attribute at each file texture you put into Maya.

Wow? They finally got around to fixing that then? For years it just reported true for every image you loaded.

ewerybody
03-30-2009, 12:41 PM
really? I use that attribute for years as well... humm.. maybe thats why it didn't work then ^^

I remember I implemented a check around version 6. Seemed to work for me. :shrug:

Robert Bateman
03-30-2009, 01:17 PM
really? I use that attribute for years as well... humm.. maybe thats why it didn't work then ^^

I remember I implemented a check around version 6. Seemed to work for me. :shrug:

I do recall contacting Alias every single release of Maya to let them know it still didn't work;)

I think i gave up about version 6 or so after I had a number of workarounds in place at the time to avoid the problem. Certainly it was still the case when I wrote my maya notes anyway (which was a few years ago admittedly). IIRC it was because MImage always converted loaded images to 32bit, whether they were 8,16,24, or 32bit or any other format for that matter. As a result, fileHasAlpha always returned true for every image you cared to load into maya. It was a real PITA when writing exporters to grab the image data....

Good to see they did manage to fix that bug. It was so very annoying....

cbamber85
03-30-2009, 01:37 PM
Maybe there is a module you can do more filestuff with...
That is what I meant. Although it's kind of moot now, I never thought of using getAttr!

CGTalk Moderation
03-30-2009, 01:37 PM
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.