From 9da3beab8304eeb3634cb6a8ab5723ad39090e19 Mon Sep 17 00:00:00 2001 From: Pradnya Bhondivale Date: Sun, 16 Nov 2025 23:13:51 +0530 Subject: [PATCH] Add Image Resizer script (resize_image.py) using Pillow --- scripts/README.md | 3 +++ scripts/resize_image.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 scripts/README.md create mode 100644 scripts/resize_image.py diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..3beb1b4 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,3 @@ +# scripts +resize_image.py — Resize images using Pillow +Usage: python resize_image.py input.jpg output.jpg 300 300 diff --git a/scripts/resize_image.py b/scripts/resize_image.py new file mode 100644 index 0000000..e9eb973 --- /dev/null +++ b/scripts/resize_image.py @@ -0,0 +1,24 @@ +# image_resizer.py +# Resize an image to the given width and height +# Usage: python image_resizer.py input.jpg output.jpg 300 300 + +from PIL import Image +import sys + +def resize_image(input_path, output_path, width, height): + img = Image.open(input_path) + resized = img.resize((width, height)) + resized.save(output_path) + print(f"Image resized successfully and saved as {output_path}") + +if __name__ == "__main__": + if len(sys.argv) != 5: + print("Usage: python image_resizer.py input.jpg output.jpg width height") + sys.exit(1) + + input_file = sys.argv[1] + output_file = sys.argv[2] + width = int(sys.argv[3]) + height = int(sys.argv[4]) + + resize_image(input_file, output_file, width, height)