This Python script provides a flexible image resizing solution. It allows users to resize a single image or batch resize multiple images in a folder. The script utilizes the Pillow
library and includes a basic UI using the tkinter
library for user interaction.
- Python 3.x
- Pillow library (
pip install Pillow
)
-
Install Dependencies:
-
Make sure you have Python 3.x installed.
-
Install the Pillow library by running:
pip install Pillow
-
-
Run the Script:
-
Execute the script by running the following command in your terminal or command prompt:
python main.py
-
-
Select Single File or Multiple Files:
- The script will prompt you to choose whether you want to resize a single file or multiple files in a folder.
-
If Resizing a Single File:
- The script will then ask you to select the source image file.
- Next, you will specify the output folder to save the resized image.
- Enter the scaling factor (e.g., 2 for doubling size, -0.5 for halving size).
- Enter the quality (0-100, higher is better).
- The resized image will be saved in the specified output folder.
-
If Resizing Multiple Files:
- The script will prompt you to select the source folder containing multiple images.
- Specify the output folder to save the resized images.
- Enter the scaling factor (e.g., 2 for doubling size, -0.5 for halving size).
- Enter the quality (0-100, higher is better).
- The batch resizing process will be completed, and resized images will be saved in the output folder.
-
Note:
- The script accepts negative values for the scaling factor, allowing users to downscale images as well.
- Adjust the
quality
parameter in thesave
method as needed.
-
Disclaimer:
- Use this script responsibly. Image resizing may result in a loss of quality, and it's essential to consider the trade-off between file size and image quality for your specific use case.
-
Customization and Contributions:
- Feel free to customize the script or contribute improvements.
- If you encounter any issues or have suggestions, please open an issue or submit a pull request.