A simple yet powerful Python utility for resizing images with flexibility. Resize images to exact dimensions or maintain aspect ratio using the high-quality Pillow library.
- Exact Dimension Resizing: Set precise width and height values
- Aspect Ratio Preservation: Specify only width or height to maintain proportions
- High-Quality Output: Uses Lanczos resampling for superior results
- Simple Command-Line Interface: Easy to use with straightforward commands
- Python 3.x
- Pillow library
-
Clone the repository:
git clone https://github.com/ahnaf-hossain2/Image-Resizer-Tool.git cd Image-Resizer-Tool
-
Install Pillow:
pip install Pillow
Navigate to the project directory:
cd path/to/Image-Resizer-Tool
python resize_image.py <input_path> <output_path> <width> <height>
Example:
python resize_image.py input.jpg resized_output.jpg 800 600
python resize_with_aspect_ratio.py <input_path> <output_path> [--width <width>] [--height <height>]
Examples:
-
Resize based on width (height calculated automatically):
python resize_with_aspect_ratio.py input.jpg resized_output.jpg --width 800
-
Resize based on height (width calculated automatically):
python resize_with_aspect_ratio.py input.jpg resized_output.jpg --height 600
- Resizes images to exact dimensions specified by the user
- Uses Pillow's
Image.resize()
method withLANCZOS
resampling algorithm - May alter the aspect ratio if target dimensions don't match the original ratio
- Intelligently preserves the original aspect ratio of the image
- Calculates the missing dimension based on the provided one
- Ensures images look natural without stretching or distortion
Argument | Description |
---|---|
input_path |
Path to the source image |
output_path |
Path where the resized image will be saved |
width |
Target width in pixels (integer) |
height |
Target height in pixels (integer) |
Argument | Description |
---|---|
input_path |
Path to the source image |
output_path |
Path where the resized image will be saved |
--width |
Target width in pixels (optional) |
--height |
Target height in pixels (optional) |
Image | Dimensions | Description |
---|---|---|
Original | 1920×1080 | Source image |
Exact Resize | 800×600 | Fixed dimensions (may alter aspect ratio) |
Aspect Ratio Preserved | 800×450 | Width set to 800, height calculated automatically |
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- GitHub Repository: https://github.com/ahnaf-hossain2/Image-Resizer-Tool
- Report Issues: https://github.com/ahnaf-hossain2/Image-Resizer-Tool/issues