/resize-imgs

Resizing multiple images with Python and OpenCV. Easy and fast batch processing via bash command.

Primary LanguagePythonMIT LicenseMIT

Batch Resizing Images

Short Python script using OpenCV to resize multiple images. Intentionally to be used for preparing lots of squared images for compiling datasets. You can specify and run the script directly in Terminal. Processes JPG and PNG files and outputs JPGs.

What you need to do:

Clone repo, cd to repo directory, pip install requirements (run $ pip install -r requirements.txt or
$ pip3 install -r requirements.txton Python3) and put all your source images there.
Inside the repo dir run $ python resize.py -d [resized_dimensions] -fn [new_file_name] .
If you're on Python3 run $ python3 resize.py -d [resized_dimensions] -fn [new_file_name] .

The script will output count of images, processing time, resized dimensions and the destination path.
Images will be named like so: new_file_name00001, new_file_name00002 etc., adding 5 digits to the
specified file name.
Dimensions default to 512 and filename defaults to image-.
If you need more than five digits open resize.py and change .zfill(5) in line 34 to any positive integer.

Example:

$ python3 resize.py -d 256 -fn resized- will resize your images to 256 x 256 and name them resized-00001
resized-00002 and so on.