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