Mirror images with imagemagick

The new screenshot gallery on roundcube.net shows up with some nice web 2.0 mirrored images. Of course I’m not the kind of person who likes to create all of them in Photoshop. I therefore wrote a little shell script generating a mirror image using imagemagick. Here’s the code of makemirror.sh

#!/bin/sh

infile=$1
outfile=$2
width=120
height=32
alpha=30

convert -size ${width}x${height} xc:none \
\( \( -flip $infile -crop ${width}x${height}+0+0 \) \
  -size ${width}x${height} gradient: -evaluate Pow 1.4 \
  -compose Copy_Opacity -composite \) \
-compose blend -set "option:compose:args" $alpha -composite $outfile

The script takes two arguments: the input file (thumbnail) and the output file name (.png). Of course the other hard-coded parameters such as image size and opacity could be provided as arguments too.

The input file is first flipped vertically and then cropped to the size of the mirror image. After that its alpha channel (opacity) is composed with a gradient image which is generated with a quadratic function. Finally we compose that gradient thumbnail with a transparent image using the given alpha value.