Remove pngsuite options from gen
#!/usr/bin/env python
# gen
-"""gen [options] [pngsuitename]
+"""gen [options]
Generate a PNG test image on stdout.
"""
@@ -12,7 +12,6 @@ import math
import sys
import png
-import pngsuite
# Below is a big stack of test image generators.
# They're all really tiny, so PEP 8 rules are suspended.
@@ -111,28 +110,6 @@ def generate(options, args):
psize += 1
return i
- def pngsuite_image(name):
- """
- Create a test image by reading an internal copy of the files
- from the PngSuite. Returned in flat row flat pixel format.
- """
-
- if name not in pngsuite.png:
- raise NotImplementedError("cannot find PngSuite file %s (use -L for a list)" % name)
- r = png.Reader(bytes=pngsuite.png[name])
- w,h,pixels,meta = r.asDirect()
- # LAn for n < 8 is a special case for which we need to rescale
- # the data.
- if meta['greyscale'] and meta['alpha'] and meta['bitdepth'] < 8:
- factor = 255 // (2**meta['bitdepth']-1)
- def rescale(data):
- for row in data:
- yield map(factor.__mul__, row)
- pixels = rescale(pixels)
- meta['bitdepth'] = 8
- arraycode = 'BH'[meta['bitdepth']>8]
- return w, h, array(arraycode, itertools.chain(*pixels)), meta
-
# The body of test_suite()
size = (256,256)
@@ -165,13 +142,8 @@ def generate(options, args):
kwargs["green"] = None
kwargs["blue"] = None
options.alpha = bool(options.alpha)
- if not args:
+
pixels = test_rgba(size, options.bitdepth, **kwargs)
- else:
- w,h,pixels,meta = pngsuite_image(args[0])
- size = (w,h)
- for k in ['bitdepth', 'alpha', 'greyscale']:
- setattr(options, k, meta[k])
writer = png.Writer(size[0], size[1],
bitdepth=options.bitdepth,
@@ -190,9 +162,6 @@ def main(argv=None):
import re
parser = OptionParser()
- parser.add_option('-L', '--list',
- default=False, action='store_true',
- help="print list of named test images")
parser.add_option('-p', '--patterns',
default=False, action='store_true',
help="print list of patterns")
@@ -222,12 +191,6 @@ def main(argv=None):
(options, args) = parser.parse_args(args=argv[1:])
- if options.list:
- names = list(pngsuite.png)
- names.sort()
- for name in names:
- print name
- return
if options.patterns:
names = list(PATTERN)
names.sort()
