From 616b2902a0df202001aa1746139b6ef6a4096482 Mon Sep 17 00:00:00 2001 From: yaras Date: Sun, 14 Feb 2016 15:42:39 +0100 Subject: [PATCH] Initial version --- converter.py | 23 +++++++++++++++++++++++ readme.md | 20 ++++++++++++++++++++ requirements.txt | 2 ++ setup.py | 14 ++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 converter.py create mode 100644 readme.md create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/converter.py b/converter.py new file mode 100644 index 0000000..2ebf2ce --- /dev/null +++ b/converter.py @@ -0,0 +1,23 @@ +from PIL import Image +from PIL import features +import os + +def convert(inputFile, outputFile): + im = Image.open(inputFile).convert("RGB") + im.save(outputFile, "jpeg") + + print('Converted {} to {}'.format(inputFile, outputFile)) + +def main(): + for f in os.listdir('.'): + if f.upper().endswith('.WEBP'): + outputFile = f[:-5] + '.jpg' + + if os.path.exists(outputFile): + print('Warning! {} not converted, because {} already exsits'.format(f, outputFile)) + else: + convert(f, outputFile) + +if __name__ == '__main__': + print ('WEBP:', features.check_module('webp')) + main() diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..f756f74 --- /dev/null +++ b/readme.md @@ -0,0 +1,20 @@ +# WEBP Converter + +Script for converting WEBP to JPG. + +## Version + +0.1.0 + +## Run + +Start `converter` in directory containing WEBP files. + +## Build from source + +```sh +virtualenv env +env\Scripts\activate +pip install -r requirements.txt +python setup.py build +``` diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..989aadf --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +cx-Freeze==4.3.4 +Pillow==3.1.1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1a41459 --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +from cx_Freeze import setup, Executable + +includefiles = [] +includes = [] +excludes = [] +packages = ["PIL.Image", "PIL.WebPImagePlugin"] + +setup( + name = "WEBP Converter", + version = "0.1.0", + description = "This is my program", + options = {'build_exe': {'includes': includes, 'excludes': excludes, 'packages': packages, 'include_files': includefiles}}, + executables = [Executable("converter.py")] + )