2
# $URL: http://pypng.googlecode.com/svn/trunk/code/pipcat $
5
# http://www.python.org/doc/2.4.4/lib/module-itertools.html
12
"""Concatenate the list of images. All input images must be same
13
height and have the same number of channels. They are concatenated
14
left-to-right. `out` is the (open file) destination for the
15
output image. `l` should be a list of open files (the input
19
l = map(lambda f: png.Reader(file=f), l)
21
map(lambda r: r.preamble(), l)
22
# The reference height; from the first image.
24
# The total target width
26
for i,r in enumerate(l):
27
if r.height != height:
28
raise Error('Image %d, height %d, does not match %d.' %
29
(i, r.height, height))
31
pixel,info = zip(*map(lambda r: r.asDirect()[2:4], l))
34
w = png.Writer(width, height, **tinfo)
36
for row in itertools.izip(*pixel):
37
yield itertools.chain(*row)
38
w.write(out, itercat())
41
return cat(sys.stdout, map(lambda n: open(n, 'rb'), argv[1:]))
43
if __name__ == '__main__':