The power of the command line
Sunday, June 3rd, 2007 at 2:24 pm
Twice in the past few days I have found that my best solution for the problem was command line tools under Linux.
First was some image manipulation:
My mother has been preparing a (physical) album from the digitial photos they took on their trip to China earlier in the year. In order to fit more photos in she was looking at collage programs so she could combine a number of photos into one print that could then be cut up. Unfortunately none of the programs could handle the simple task of combining photos, they all assumed a freeform layout.
The command line solution? The append option of ImageMagick. Once my mother has worked out which photos she wants I will write a shell script to semi-automate the process of appending a pair of images:
convert -append 1.jpg 2.jpg final.jpg
I may even take it a step further and use PerlMagick, the Perl API for ImageMagick, to make it easier to automate more complex manipulations such as cropping, resizing and rotation.
Second was some video manipulation:
I have a set of avi videos that I had been unable to archive as the total filesize was slightly bigger than a single sided DVD-R disc. I couldn’t easily chop the end off each video to reduce the size as the audio was using a variable bitrate as I would first have to convert the audio to a constant bitrate in a multistep process.
The command line solution? Transcode, a suite of command line utilities for transcoding video and audio. The following command converts the audio stream of the avi to be 64kbit/sec MP3 while leaving the video untouched:
transcode -i input.avi -P 1 -N 0x55 -b 64 -o output.avi
I couldn’t detect any difference in the quality of the audio and it had the pleasant side effect of reducing the file size enough for my purposes. A quick shell script allowed me to batch process an entire directory of videos.
Also, these were both installed on my linux box from the command line:
apt-get install imagemagick apt-get install transcode
It is nice when it all comes together.