vt-resize-pictures is a really simple ImageMagick wrapper written in Bash aimed at batch image resizing. Currently it uses hardcoded parameters and users are encouraged to adjust the script to meet their needs.
#!/usr/bin/env bash echo 'Original:' ls -l *.JPG vt-resize-pictures.sh echo echo 'Resized:' ls -l resized_pictures/* # Example output: # # Original: # -rw-rw-r--. 1 voj-tech voj-tech 4388271 Apr 20 2016 P1050809.JPG # -rw-rw-r--. 1 voj-tech voj-tech 4531403 Apr 20 2016 P1050810.JPG # # Resized: # -rw-rw-r--. 1 voj-tech voj-tech 728966 Aug 11 01:25 resized_pictures/P1050809.JPG # -rw-rw-r--. 1 voj-tech voj-tech 746587 Aug 11 01:25 resized_pictures/P1050810.JPG
vt-resize-pictures was originally a script for my personal use but it might come in handy as a template to others as well.
It is required that your environment features reasonably new versions of:
- the find and xargs command line utilities
- the GNU core utilities
It should be noted that the script has been tested using ImageMagick 126.96.36.199, findutils 4.6.0 (provides the find and xargs utilities), coreutils 8.30 and Bash 4.4.23 on Fedora 29.
No actual installation is needed. To start using the script follow these steps:
Download a ZIP file with the required version of the script from this page. Most likely you want the latest version.
Unpack the downloaded file and add the execute mode bit to the
vt-resize-pictures.shscript file mode bits.
unzip vt-resize-pictures-0.8.2.zip && chmod +x vt-resize-pictures-0.8.2/vt-resize-pictures.sh
Optionally copy the script to a directory which is in your
PATHenvironment variable for convenience. This might be the
~/bindirectory for example.
cp vt-resize-pictures-0.8.2/vt-resize-pictures.sh ~/bin
Resize JPEG images in
DIRECTORY (the current directory by default).
The script resizes all the images identified as files with the
.jpg filename extension found directly in the
specified directory and places the output images to an output directory. The output directory has the name
resized_pictures and is created in the directory with the input images. The output images have the same file
names as their input counterparts.
The actual operation of resizing the images is done using ImageMagick with a set of hardcoded parameters. The
images are resized proportionally and the output images have the width of
1280 pixels, the compression
level (quality) of
98 and the sampling factor of
vt-resize-pictures.sh script exits with the status of the last command which is to remove a
temporary file used internally by the script. This is
0 if it succeeds, otherwise it is a value greater than
0. However the script exits with status:
1if the output directory cannot be created
2if no JPEG images are found
Suggestions and bug reports are more than welcome at firstname.lastname@example.org.