diff options
author | Thomas Groman <tgroman@nuegia.net> | 2020-04-20 20:56:28 -0700 |
---|---|---|
committer | Thomas Groman <tgroman@nuegia.net> | 2020-04-20 20:56:28 -0700 |
commit | 508d270a4d78d491bbe1c67c309c404f547da58a (patch) | |
tree | d16e2a906501dcda7b4d268579896f03e125f553 /build/pypng/piprgb | |
parent | f9cab004186edb425a9b88ad649726605080a17c (diff) | |
download | webbrowser-508d270a4d78d491bbe1c67c309c404f547da58a.tar webbrowser-508d270a4d78d491bbe1c67c309c404f547da58a.tar.gz webbrowser-508d270a4d78d491bbe1c67c309c404f547da58a.tar.lz webbrowser-508d270a4d78d491bbe1c67c309c404f547da58a.tar.xz webbrowser-508d270a4d78d491bbe1c67c309c404f547da58a.zip |
added Comm Build System
Diffstat (limited to 'build/pypng/piprgb')
-rw-r--r-- | build/pypng/piprgb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/build/pypng/piprgb b/build/pypng/piprgb new file mode 100644 index 0000000..fbe1082 --- /dev/null +++ b/build/pypng/piprgb @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# $URL: http://pypng.googlecode.com/svn/trunk/code/piprgb $ +# $Rev: 131 $ +# piprgb +# +# Convert input image to RGB or RGBA format. Output will be colour type +# 2 or 6, and will not have a tRNS chunk. + +import png + +def rgb(out, inp): + """Convert to RGB/RGBA.""" + + r = png.Reader(file=inp) + r.preamble() + if r.alpha or r.trns: + get = r.asRGBA + else: + get = r.asRGB + pixels,info = get()[2:4] + w = png.Writer(**info) + w.write(out, pixels) + +def main(argv=None): + import sys + + if argv is None: + argv = sys.argv + if len(argv) > 1: + f = open(argv[1], 'rb') + else: + f = sys.stdin + return rgb(sys.stdout, f) + +if __name__ == '__main__': + main() |