~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to build/pypng/pipcat

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# $URL: http://pypng.googlecode.com/svn/trunk/code/pipcat $
 
3
# $Rev: 77 $
 
4
 
 
5
# http://www.python.org/doc/2.4.4/lib/module-itertools.html
 
6
import itertools
 
7
import sys
 
8
 
 
9
import png
 
10
 
 
11
def cat(out, l):
 
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
 
16
    image files).
 
17
    """
 
18
 
 
19
    l = map(lambda f: png.Reader(file=f), l)
 
20
    # Ewgh, side effects.
 
21
    map(lambda r: r.preamble(), l)
 
22
    # The reference height; from the first image.
 
23
    height = l[0].height
 
24
    # The total target width
 
25
    width = 0
 
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))
 
30
        width += r.width
 
31
    pixel,info = zip(*map(lambda r: r.asDirect()[2:4], l))
 
32
    tinfo = dict(info[0])
 
33
    del tinfo['size']
 
34
    w = png.Writer(width, height, **tinfo)
 
35
    def itercat():
 
36
        for row in itertools.izip(*pixel):
 
37
            yield itertools.chain(*row)
 
38
    w.write(out, itercat())
 
39
 
 
40
def main(argv):
 
41
    return cat(sys.stdout, map(lambda n: open(n, 'rb'), argv[1:]))
 
42
 
 
43
if __name__ == '__main__':
 
44
    main(sys.argv)