Simple script written in Python that converts all images found within the folder where the script is located (and all sub-folders); if the images are not in png or jpg (and jpeg) type, then it converts them to the latter one.
Among the options there is the possibility of setting the quality, the maximum resolution in pixels of the long side of the image while maintaining the aspect ratio (without upscaling if smaller) and changing the dpi.
There is the possibility to convert all images to the RGB colour space (Important: ICC colour profiles are not used for this conversion so switching between different formats may result in incorrect colours).
It also prints out a list of all corrupted images and any other files found.
The following formats are recognised: jpg, jpeg, png, tif, tiff, bmp, psd, psb.
Warning: psd and psb file types have not been tested.
git clone https://github.com/EdoardoTosin/Batch-Image-Converter.git
cd Batch-Image-Converter/src && python3 -m pip install -r requirements.txt
- Copy
main.py
into the folder you want to convert all images. python3 main.py
- Help screen:
python3 main.py -h
git clone https://github.com/EdoardoTosin/Batch-Image-Converter.git
cd Batch-Image-Converter\src; python -m pip install -r requirements.txt
- Copy
main.py
into the folder you want to convert all images. - Double click
main.py
to start it with default parameters or launch via terminal withpython main.py
. - Help screen:
python main.py -h
Note: append the following string before calling main.py script based on your operating system.
- Linux:
python3
- Windows:
python
Show help message and exit
Usage: main.py -h
Set path where images are located (default: Folder where this script is located).
Usage:
- Windows:
main.py -p "C:\Windows\Log"
- Linux:
main.py -p "/var/log"
Set pixel density in pixels per inch (dpi), must be in range 1-1000 (default: 72).
Usage: main.py -d 72
Set max resolution of image (long side) in pixel (downscaling only), must be in range 1-10000 (default: 1000).
Usage: main.py -s 1000
Set type of filter used for downscaling, must be an integer in range 0-3 (default: 0 = Nearest).
0 | 1 | 2 | 3 |
---|---|---|---|
Nearest | Bilinear | Bicubic | Antialias |
Usage: main.py -f 0
Set color space to RGB (default: False).
Warning: converting CYMK to RGB might not be accurate because the script doesn't use the icc profiles.
True | False |
---|---|
--colorspace | --no-colorspace |
--cs | --no-cs |
Usage: main.py --colorspace
or main.py --no-colorspace
Set quality of output images, must be in range 1-100 (values above 95 should be avoided) (default: 80).
Usage: main.py -q 80
Attempt to compress the palette by eliminating unused colors (default: True).
True | False |
---|---|
--optimize | --no-optimize |
Usage: main.py --optimize
or main.py --no-optimize
Play alert sound when finished the conversion (default: True).
True | False |
---|---|
--mute | --no-mute |
Usage: main.py --mute
Wait user keypress (Enter
) when finished the conversion (default: True).
True | False |
---|---|
--wait | --no-wait |
Usage: main.py --wait
or main.py --no-wait
This software is released under the terms of the GNU General Public License v3.0. See the LICENSE file for further information.