Using Image Magick to shrink your JPGs

Here is a small script to use Image Magick tools on the JPEG files from your camera, and create “smaller” versions in a new sub-folder called “smaller”.

It must be changed to match the JPG files produced by your camera. It looks for JPEG files with specific dimensions.

And of course this version only works on Unix-like systems that have the “bash” shell available.

#!/bin/bash
rm -f list.txt
mkdir smaller

echo List of JPG files
for a in P*.JPG; do (identify $a >>list.txt); done

echo convert 4032x2272 images
for a in $(grep -e "2272" list.txt | sed -re "s/^([^ ]+).*/\1/"); do (convert $a -comment "Copyright Robert Echlin. Larger version available." -resize 1920x1080 smaller/$a ); done

echo convert 4032x3024 images
for a in $(grep -e "3024" list.txt | sed -re "s/^([^ ]+).*/\1/"); do (convert $a -comment "Copyright Robert Echlin. Larger version available." -resize 1600x1200 smaller/$a ); done

echo checking ...
echo Local files
ls *JPG | wc -l

echo smaller files
ls smaller | wc -l
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s