summaryrefslogtreecommitdiffstats
path: root/Lib/imghdr.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-10-18 17:09:59 (GMT)
committerGuido van Rossum <guido@python.org>1992-10-18 17:09:59 (GMT)
commit2db91358def94cf8081f27b736988320d14eba39 (patch)
treef73562d6cfd16adf8723bbe702be55d13e2122f5 /Lib/imghdr.py
parent0cb8e8cfc09dd0919882da968c3e95bf070e257d (diff)
downloadcpython-2db91358def94cf8081f27b736988320d14eba39.zip
cpython-2db91358def94cf8081f27b736988320d14eba39.tar.gz
cpython-2db91358def94cf8081f27b736988320d14eba39.tar.bz2
Misc changes and new modules. whrandom is "objectified". SOCKET.py
is moved to the sgi subdirectory.
Diffstat (limited to 'Lib/imghdr.py')
-rw-r--r--Lib/imghdr.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/Lib/imghdr.py b/Lib/imghdr.py
index 981340f..063bfe8 100644
--- a/Lib/imghdr.py
+++ b/Lib/imghdr.py
@@ -35,13 +35,29 @@ def test_gif(h, f):
tests.append(test_gif)
-def test_pnm(h, f):
- # PBM, PGM, PPM (portable {bit,gray,pix}map; together portable anymap)
+def test_pbm(h, f):
+ # PBM (portable bitmap)
if len(h) >= 3 and \
- h[0] == 'P' and h[1] in '123456' and h[2] in ' \t\n\r':
- return 'pnm'
+ h[0] == 'P' and h[1] in '14' and h[2] in ' \t\n\r':
+ return 'pbm'
-tests.append(test_pnm)
+tests.append(test_pbm)
+
+def test_pgm(h, f):
+ # PGM (portable graymap)
+ if len(h) >= 3 and \
+ h[0] == 'P' and h[1] in '25' and h[2] in ' \t\n\r':
+ return 'pgm'
+
+tests.append(test_pgm)
+
+def test_ppm(h, f):
+ # PPM (portable pixmap)
+ if len(h) >= 3 and \
+ h[0] == 'P' and h[1] in '36' and h[2] in ' \t\n\r':
+ return 'ppm'
+
+tests.append(test_ppm)
def test_tiff(h, f):
# TIFF (can be in Motorola or Intel byte order)