From ee973ad78c1752d72be0e9113b264e8a36cf1f9c Mon Sep 17 00:00:00 2001 From: Ricky Putra Date: Sun, 13 Oct 2019 17:31:09 +0800 Subject: [PATCH] add script to compress image --- compress_image/README.md | 15 +++++++++++++++ compress_image/compress.py | 9 +++++++++ 2 files changed, 24 insertions(+) create mode 100644 compress_image/README.md create mode 100644 compress_image/compress.py diff --git a/compress_image/README.md b/compress_image/README.md new file mode 100644 index 0000000..be9985c --- /dev/null +++ b/compress_image/README.md @@ -0,0 +1,15 @@ +## What it does ## + +Compress image using PIL (Pillow) + +## Install ## + +``` +pip install Pillow +``` + +## How to use ## + +``` +python compress.py +``` \ No newline at end of file diff --git a/compress_image/compress.py b/compress_image/compress.py new file mode 100644 index 0000000..8387420 --- /dev/null +++ b/compress_image/compress.py @@ -0,0 +1,9 @@ +import sys +from PIL import Image + +img_src = sys.argv[1] +img_dst = sys.argv[2] +quality = int(sys.argv[3]) + +img = Image.open(img_src) +img.save(img_dst, optimize=True, quality=quality) \ No newline at end of file