sys.exit(1) if d <> wtddata: print "** (warning) data changed" warning = 1 for i in range(len(d)): if d[i] <> wtddata[i]: print " First at byte", i print ` wtddata[i : i + 4] `, ` d[i : i + 4] ` break # # Part one - Test ppm reader/writer # print "- Read ppm original image" r = imgppm.reader("in-rgb-t2b.ppm") width, height = r.width, r.height rgb_t2b_data = r.read() del r print "- Write ppm original image" w = imgppm.writer("out-rgb-t2b.ppm") w.width, w.height, w.format = width, height, imgformat.rgb w.write(rgb_t2b_data) del w print "- Write ppm upsidedown image" w = imgppm.writer("out-rgb-b2t.ppm") w.width, w.height, w.format = width, height, imgformat.rgb_b2t w.write(rgb_t2b_data) del w
"""A minimal module to write Mac 24-bit RGB PICT files on any machine"""
# # Test script to test various image modules. # import sys sys.path.append('..') import imgformat import imgppm import imgpgm import imgpbm import imgtiff try: import imgsgi except ImportError: imgsgi = None import imgjpeg import imggif warning = 0 def checksize(r): if (r.width, r.height) != (width, height): print '** W/H change: wanted', (width, height), 'got', (r.width, r.height) sys.exit(1) def checkreader(r, wtddata): global warning checksize(r) d = r.read() if len(d) <> len(wtddata): print '** Datalength change: wanted', len(wtddata), 'got', len(d)