I use this primitive command line script to format images for my phone stereoscope. The input is any side-by-side image pair and the output is a rescaled side-by-side pair with a spacer in between the image halves.
usage:
lr_resize_add_spacer [input file] [output file] [width of the image halve] [width of the spacer] [colour of the spacer]
If you omit any of the parameters, the script uses a default of 1911 px width, 18 px spacer, black colour.
To run the script on an entire batch of images, I copy the originals into a new directory and run the command in a cycle:
for i in *;do lr_resize_add_spacer $i $i;done
Note that the script only works for landscape or square images - anything higher than 8:9 yields incorrect results!! However, such images are a total exception in my case...
Many thanks to my brother Jiří for help! Unlike me, he is a real programmer.
#!/bin/bash
SPACING=$4
SPACING=${SPACING:=18}
SPACING_COLOUR=$5
SPACING_COLOUR=${SPACING_COLOUR:=black}
WIDTH=$3
WIDTH=${WIDTH:=1911}
if [[ -z $1 ]] || [[ -z $2 ]]; then
echo "usage: $0 left_right.image left_space_right.image [image_width [spacing [spacing_colour]]]" >&2
exit 1
fi
read W H <<< `identify -format "%W %H" $1`
if [[ -z $H ]]; then
echo "cannot determine the dimensions of $1" >&2
exit 1
fi
W=$(($W/2))
LEFT=`mktemp /tmp/XXXX.png`
RIGHT=`mktemp /tmp/XXXX.png`
convert -crop "${W}x${H}+0+0" -resize ${WIDTH}x $1 $LEFT
convert -crop "${W}x${H}+${W}+0" -resize ${WIDTH}x -background $SPACING_COLOUR -splice ${SPACING}x0 $1 $RIGHT
convert +append $LEFT $RIGHT $2
rm $LEFT $RIGHT