The Problem

While working on my backpacking guides, I was constantly having to compress my images, and manually convert them to progressive JPEG formats. I was performing the same, or very similar actions for every image, so I realized that the process needed to be automated.

My Solution

I started by identifying the tools required to perform the image manipulations I required from the command line, ImageMagick and JPEGtran. Then I created a shell language script to loop over a set of files, invoking the relevant tools with settings based on inputted user flags. These settings controlled the resolution scale factor, saturation, and output path of the resulting images. I designed the script to operate on any number of images at once, regardless of the filename character set, or the prefixed path. I used regular expression tools such as grep and sed to ensure that the outputted file names are accurate and intuitive for the user.

Prior to publishing, I polished the script by adding ease of use features like quiet mode, improper usage messages, and help text. Prior to running, the script ensures that both dependencies are installed, and if they aren't, it provides the user with instructions on how to install them.