Skip to main content

A python CLI tool to resize images while conserving folder hierarchy and preserving original ones in a different folder.

Project description

Downloads

Photo Resizer

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;

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: 1

Content of original folder before resize with pictures' original size: 5

Both the original folder and the folder created after all is finished, which contains all original images: 2

Display of both folders containing exactly the same hierarchy: 3

Content of original folder after resize with pictures' reduced size at 55% quality and the output file: 4

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 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.

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

MIT

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

phulize-1.0.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phulize-1.0.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file phulize-1.0.0.tar.gz.

File metadata

  • Download URL: phulize-1.0.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for phulize-1.0.0.tar.gz
Algorithm Hash digest
SHA256 872a7b3e77ed0ac1ce692b01abd69dc7e4b4e0e1d4029020648ce9b0bcc58588
MD5 edebd6bec85ad36353101c2356c68c17
BLAKE2b-256 3b4a06f5b932f78c356346ba55430972689c431e8de9902bca73023b1f25f96c

See more details on using hashes here.

File details

Details for the file phulize-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: phulize-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for phulize-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e643830ee4b2fcde4a6b3090bbeec2f8c372c4ccbacfcb363b44fab8ead3fb3
MD5 49f6b7682d4f1d8e762101e4c9123080
BLAKE2b-256 fb30072c14f81b5ccb0e8eec571fbb3a09bb6c2d6673c174787b2a6c04f7ef87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page