Mercurial > ec-dotfiles
comparison bin/recompress @ 95:a5324d2cc0eb
Updated documentation.
author | Edho Prima Arief <edho@myconan.net> |
---|---|
date | Thu, 14 Jul 2011 00:50:23 +0700 |
parents | 9790bc126ea6 |
children | 9be628347dce |
comparison
equal
deleted
inserted
replaced
94:9790bc126ea6 | 95:a5324d2cc0eb |
---|---|
2 | 2 |
3 import sys, os | 3 import sys, os |
4 from PIL import Image | 4 from PIL import Image |
5 | 5 |
6 | 6 |
7 # return codes: | 7 # Raises a generic exception (exception.Exception) if input is not a PNG file. |
8 # 0 = ok | |
9 # 1 = error opening file (not an image, not a file, unreadable or whatever) | |
10 # 2 = error saving file (no write permission) | |
11 # 3 = not a png file | |
12 def repng(filename): | 8 def repng(filename): |
13 im = Image.open(filename) | 9 im = Image.open(filename) |
14 if im.format == "PNG": | 10 if im.format == "PNG": |
15 im.save(filename, "PNG", optimize=1) | 11 im.save(filename, "PNG", optimize=1) |
16 else: | 12 else: |