Example #1
0
#
# 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)
Example #2
0
w = imgpbm.writer("out-icon.pbm")
w.width, w.height, w.format = width, height, imgformat.pbmbitmap
w.write(mono_data)
del w

print "- Re-read pbm image"
r = imgpbm.reader("out-icon.pbm")
checkreader(r, mono_data)

print "- Dither grey to mono and write"
try:
    from imgop import dither
except ImportError:
    print "** skipped (no ditherer)"
    dither = None
if dither:
    r = imgpgm.reader("in-grey-t2b.pgm")
    w = imgpbm.writer("out-mono-t2b.pbm")
    d = dither(r.read(), r.width, r.height, r.format, imgformat.pbmbitmap)
    w.width, w.height, w.format = r.width, r.height, imgformat.pbmbitmap
    w.write(d)

print "- Read PBM file as PGM and write"
r = imgpgm.reader("in-icon.pbm")
w = imgpgm.writer("out-icon.pgm")
w.width, w.height, w.format = r.width, r.height, r.format
w.write(r.read())

if warning:
    sys.exit(1)
Example #3
0
"""Module to handle conversion between in-core image formats."""