A python CLI tool to resize images while conserving folder hierarchy and preserving original ones in a different folder.
Project description
Photo Resizer CLI + GUI
Table of Contents
Description
Photo Resizer is a CLI (command-line interface) tool which takes a folder full of photos and resizes each photo recursively depending on the extensions chosen. It does this while conserving folder hierarchy without having to organize each photo again.
All photos are checked if they are valid or corrupted before the resizing as well as after, to make sure any photos are resized correctly.
A filter is also available for searching for photos, meaning it's possible to only resize photos which the size is higher or below the specified. More details below.
All original photos are copied to a different folder which can be configured, also cloning the existent folder hierarchy. If any image fails to resize, this photo will remain in the original folder.
At the start, a safety question is displayed to make sure the path inserted is the correct one as it will be permanently modified. This safety question can be disabled.
An option to shut down the device is also available as it can be useful to leave the process running for a long time without worrying.
When all is finished, an output file will be created with statistics and relevant information, such as:
- list of images resized;
- display original size and resized size of each image;
- display all photos' original size and resized size;
- display how much size was resized between all photos;
- total number of photos resized, increased, unsuccessful and found;
- warning if the photo size increased instead of decreased;
GUI
Guide coming soon...
Some images for current interface:
Output file example
... (hidden)
[2023-04-05 17:44:13.979793]
The following photo was resized: C:\Users\<username>\Desktop\example\1subfolder\anothersubfolder\1680170906941
-The original photo size was: 1.98 MB
-The resized photo size is: 2.04 MB
[WARNING] Size increased!
[2023-04-05 17:44:14.209180]
The following photo was resized: C:\Users\<username>\Desktop\example\1subfolder\anothersubfolder\1680170908790
-The original photo size was: 699.66 KB
-The resized photo size is: 258.03 KB
[2023-04-05 17:44:14.211177]
Final Statistics:
Size of all original photos: 9.29 MB
Size of all resized photos: 4.67 MB
Space in disk saved: 4.63 MB
- Total number of photos with reduced size: 6
- Total number of photos with increased size: 1
- Total number of photos unsuccessfully reduced: 0
- Total number of photos found: 7
Folder example
The original folder full of images to be resized:
Content of original folder before resize with pictures' original size:
Both the original folder and the folder created after all is finished, which contains all original images:
Display of both folders containing exactly the same hierarchy:
Content of original folder after resize with pictures' reduced size at 55% quality and the output file:
Features
Feature |
---|
resize photos in bulk conserving folder hierarchy |
resize photos depending on specific extension |
resize photos recursively within folders |
checking of invalid or corrupted photos |
filter photos to resize depending on their size |
all original photos are preserved in another folder in case of something going wrong |
creation of a final output file containing relevant information about the process |
existence of a safety question |
option of shutting down the device when the resizing process is finished |
configurations provided will be save for easier usage of the command |
Any new features are very welcomed.
Future features
Nothing at the moment.
Prerequisites
Python 3 must be installed.
Installation
pip --no-cache-dir install phulize
or,
pip3 --no-cache-dir install phulize
Usage
Command (shortcut) | Command (full) | Required | Default value | Description |
---|---|---|---|---|
-r | --run | REQUIRED to start the resizing | --- | If specified, the resizing will start running using user-defined configurations. |
-p | --path | REQUIRED to resize photos | empty | Absolute path of the folder containing images to be resized. |
-e | --extensions | REQUIRED to resize photos | empty | Insert the extensions of all the images that should be resized. |
-q | --quality | OPTIONAL | 55 | The desired quality of the image. An original image has 100% quality, meaning that anything below this value will reduce the size of the images. |
-f | --folder | OPTIONAL | _ORIGINAL | The name or path of the folder which will contain all original photos already resized. |
-hi | --higher | OPTIONAL | 0 | The size in Bytes of any image that should be resized. Any images' size higher than this value will be resized. |
-b | --below | OPTIONAL | 0 | The size in Bytes of any image that should be resized. Any images' size below this value will be resized. |
--- | --safety-question/--no-safety-question | OPTIONAL | True | Enable or disable the safety question |
--- | --shutdown/--no-shutdown | OPTIONAL | False | Enable or disable the shutting down device when process is finished. |
Before
- If possible, make a backup of the folder to be resized, in case anything goes wrong. This will ensure no data is lost.
- It's recommended that a trial is made first (with dummy images), to check the best quality to use.
After
- Make sure to check the output file for any unexpected outcomes, regarding if it resized correctly, as expected, or not.
- Make sure to check the images resized, to make sure there is no loss. The program itself checks if an image is or becomes corrupted after resizing, but make sure
Important
- The quality of the image to be resized, by default, is 50%, meaning all images to resize will have, approximately, 50% less quality than the original image. This can be change, adding the '--quality' argument with a number between 0 and 100.
- If the file image has the name in the following format: "IMG__", the date is going to be added to the converted image's date-created metadata. This means the metadata of the image is going to be correct in the date_created field. Before this improvement, the date_created would be the date the file was converted since it creates a new file.
Any additional help can be provided if the following command is run:
phulize --help
or,
phulize -h
Running the previous command is also useful to make sure the package was downloaded correctly.
Example of an initial command, could be:
phulize -p "C:\Users\<username>\Desktop\example" -q 60 -e jpg png
This will configure the path of the folder containing images to resize, the quality those images should have and the extensions to search for and resize.
Any configuration can also be individually inserted:
phulize -q 50
phulize -f "CONVERTED"
The following command corresponds to only resizing images that have a size higher than 1MB:
phulize -hi 1048576
The opposite is also true (resizing images that have a size lower than 1MB):
phulize -b 1048576
To disable the previous filters ('--hi' or '--b'), one can simply set them to 0 (zero):
phulize -b 0
The previous configuration can be seen in a file, with the content just like the following:
below: 0
extensions:
- .jpg
- .png
folder: CONVERTED
higher: 1048576
path: C:\Users\<username>\Desktop\example
quality: 50
Usage of boolean arguments:
phulize --safety-question
phulize --no-safety-question
phulize --shutdown
phulize --no-shutdown
To run the resizing after all configurations are done:
phulize --run
Support
If any problems occurs, feel free to open an issue.
License
Status
Currently maintaining it.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file phulize-1.1.2.tar.gz
.
File metadata
- Download URL: phulize-1.1.2.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd39bf29d396af03f3eb49c148ad2eced9fff8d8cf2f5f4d9bef03f9828d3b17 |
|
MD5 | 1aee356c838a5c70b9dcb1ffe8820f84 |
|
BLAKE2b-256 | 01131218df4f846ac98de6bcd25a7a843c5ac69f2286d6857f565204d2d556dc |
File details
Details for the file phulize-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: phulize-1.1.2-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8742a5830d81be944bf4a6cebad6224605a8377aa6c7c5e370fa6a94dcc1776 |
|
MD5 | c80b4b09713fe6750744c17d3e72316b |
|
BLAKE2b-256 | d3413cde527dd3450c346c32e966153987d279cb855dafc0c3446c2d7c27a915 |