access tga image size

H

haddock

hi all

Is it possible to access the size (with and height) of a .tga image in
python? From the documentation I would say no, but I'm pretty new to
python...

if the answer really is no, has someone a suggestion how else I could
write a little script that computes the total area of a large nuber of
image files in a folder? I should check texturespace for 3D Models,
and would like to avoid copy pasting them all into Photoshop...

thanks for your trouble

haddock
 
L

Larry Bates

You will need to get and install a copy of
PIL (Python Imaging Library) available at:

http://www.pythonware.com/products/pil/index.htm

then in Python:

import Image

filepath='<insert filename path here>'
im=Image.open(filepath)
height, width=im.size
print "%s-height=%i, width=%i" % (filepath, height,
width)

or for all files in a directory

import glob
import Image

filepathlist=glob.glob(r"c:\images\*.tga")
for filepath in filepathlist:
im=Image.open(filepath)
height, width=im.size
print "%s-height=%i, width=%i" % (filepath, height,
width)


Larry Bates
Syscon, Inc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top