From c4d7c7ed4a101cbd67161485a05b0bac85fd271e Mon Sep 17 00:00:00 2001 From: Murat Onur Yildirim Date: Sun, 2 Oct 2022 13:16:12 +0200 Subject: [PATCH 1/2] create readme.md --- scripts/tiff_converter/readme.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 scripts/tiff_converter/readme.md diff --git a/scripts/tiff_converter/readme.md b/scripts/tiff_converter/readme.md new file mode 100644 index 0000000..71832f3 --- /dev/null +++ b/scripts/tiff_converter/readme.md @@ -0,0 +1,7 @@ +# TIFF to PNG/JPEG +A simple script converts TIFF files to (i).png and (ii).jpeg + +## Usage +* Dependency: +* Pillow +* Use `python3 -m pip install --upgrade Pillow` From 587f5512199b6420dfbf41aafb084fadc49dddf6 Mon Sep 17 00:00:00 2001 From: Murat Onur Yildirim Date: Sun, 2 Oct 2022 13:16:38 +0200 Subject: [PATCH 2/2] create script.py --- scripts/tiff_converter/script.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/tiff_converter/script.py diff --git a/scripts/tiff_converter/script.py b/scripts/tiff_converter/script.py new file mode 100644 index 0000000..893ba4c --- /dev/null +++ b/scripts/tiff_converter/script.py @@ -0,0 +1,27 @@ +import os +from PIL import Image + + +def tiff_to_jpeg(): + path = os.getcwd() + for root, dirs, files in os.walk(path): + for name in files: + if os.path.splitext(os.path.join(root, name))[1].lower() == ".tiff": + outfile = os.path.splitext(os.path.join(root, name))[0] + ".jpg" + im = Image.open(os.path.join(root, name)).convert('RGB') + im.thumbnail(im.size) + im.save(outfile, "JPEG", quality=90) + print('.tiff file(s) are converted to .jpeg') + + +def tiff_to_png(): + + path = os.getcwd() + for root, dirs, files in os.walk(path): + for name in files: + if os.path.splitext(os.path.join(root, name))[1].lower() == ".tiff": + outfile = os.path.splitext(os.path.join(root, name))[0] + ".png" + im = Image.open(os.path.join(root, name)).convert('RGB') + im.thumbnail(im.size) + im.save(outfile, "PNG", quality=90) + print('.tiff file(s) are converted to .png')