Overall size of textures in a scene

18 views
Skip to first unread message

Mahmoodreza Aarabi

unread,
Oct 5, 2016, 9:23:14 AM10/5/16
to Python Programming for Autodesk Maya
Hey masters

I have a problem here, i want to get size of all textures that loaded in a scene in maya, paths are loaded from different directories.

there is any idea?

Justin Israel

unread,
Oct 5, 2016, 2:20:37 PM10/5/16
to Python Programming for Autodesk Maya
If you can gather the file nodes in the scene, can you then query their outSize attr values? 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0714d217-2204-44ac-8061-cca64e1af7aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michał Frątczak

unread,
Oct 5, 2016, 2:46:40 PM10/5/16
to Python Programming for Autodesk Maya
What do you mean by size? 
If file size, then use python os.stat() function
If you meant bitmap resolution, then there are multiple options. One trick is to create imagePlane and set it's file name - it should show tex res in its attributes.

for PNGs I had a snippet around:

def get_image_info(data):
    if is_png(data):
        w, h = struct.unpack('>LL', data[16:24])
        width = int(w)
        height = int(h)
    else:
        raise Exception('not a png image')
    return width, height

def is_png(data):
    return (data[:8] == '\211PNG\r\n\032\n'and (data[12:16] == 'IHDR'))

def GetRes(fName):
    data = None
    with open(fName, 'rb') as f:
        data = f.read()

    if is_png(data):
        return get_image_info(data)
    else:
        return (-1, -1)


-michal
Reply all
Reply to author
Forward
0 new messages