1
#! /usr/local/bin/python
3
# The Python Imaging Library.
6
# a utility to identify image files
8
# this script identifies image files, extracting size and
9
# pixel mode information for known file formats. Note that
10
# you don't need the PIL C extension to use this module.
13
# 0.0 1995-09-01 fl Created
14
# 0.1 1996-05-18 fl Modified options, added debugging mode
15
# 0.2 1996-12-29 fl Added verify mode
16
# 0.3 1999-06-05 fl Don't mess up on class exceptions (1.5.2 and later)
17
# 0.4 2003-09-30 fl Expand wildcards on Windows; robustness tweaks
21
import getopt, glob, sys
25
if len(sys.argv) == 1:
26
print "PIL File 0.4/2003-09-30 -- identify image files"
27
print "Usage: pilfile [option] files..."
29
print " -f list supported file formats"
30
print " -i show associated info and tile data"
31
print " -v verify file headers"
32
print " -q quiet, don't warn for unidentified/missing/broken files"
36
opt, args = getopt.getopt(sys.argv[1:], "fqivD")
37
except getopt.error, v:
41
verbose = quiet = verify = 0
48
print "Supported formats:"
59
Image.DEBUG = Image.DEBUG + 1
62
# expand wildcards where necessary
63
if sys.platform == "win32":
66
if glob.has_magic(file):
67
out.extend(glob.glob(file))
73
for file in globfix(args):
76
print "%s:" % file, im.format, "%dx%d" % im.size, im.mode,
78
print im.info, im.tile,
85
print "failed to verify image",
86
print "(%s:%s)" % (sys.exc_type, sys.exc_value)
89
print file, "failed:", v
93
print file, "failed:", "unexpected error"
94
traceback.print_exc(file=sys.stdout)