Almost SooC swapped left & right with BASH script
[Jump to gallery | script] These are some almost SooC images BUT with left and right images swapped. They were captured with my recently constructed stereo camera module. This is part of an ongoing project to create a modular GNU/Linux digital camera system using easily available generic components.
Although the images themselves are unedited, the left and right images have been swapped over, using a simple BASH shell script (detailed below). Thus they behave as 3d cross-eyed pairs. To view them in 3D simply cross your eyes slightly until a third image appears between the two photos. If you are doing it correctly then this third image will be in 3D. For example in the pictures featuring Estella Rose, the silver-coloured mannequin and model Estella Rose will clearly be in the foreground.
Gallery of simple cross eyed stereo pairs
BASH script ‘garf-crosseyed’
This script takes a directory full of parallel stereo pairs and converts them into cross-eyed stereo pairs by swapping the left and right halves. It works on entire current directory and creates a new subdirectory for the new file(s).
#!/bin/bash
# garf-crosseyed
#
# By Garfield Lucas.
# Updated 2026-05-19.
#
# Converts horizontal stereo pairs into horizontal cross-eyed stereo pairs
# by swapping the left and right halves.
# Works on entire current directory and creates a new subdirectory for the new file(s).
#
# Usage ./garf-crosseyed *.jpg or ./garf-crosseyed *.png
#
# May also work on other image formats.
#
# Input must be:
# Side-by-side image
# Total size: 3200x1600
# Left eye : 1600x1600
# Right eye: 1600x1600.
#
# Output saved into ./crosseyed
# Original filename(s) preserved
#
# Requires: ImageMagick ("magick" command)
# Exit on errors, undefined variables, or failed pipelines
set -euo pipefail
# Make subdirectory "crosseyed"
mkdir -p crosseyed
# Process every file given on the command line
for img in "$@"; do
[ -f "$img" ] || continue
filename=$(basename "$img")
magick "$img" \
\( -clone 0 -crop 1600x1600+1600+0 +repage \) \
\( -clone 0 -crop 1600x1600+0+0 +repage \) \
-delete 0 \
+append \
"crosseyed/$filename"
echo "Created: crosseyed/$filename"
done
Copy and paste the above script to a text file and save it as “garf-crosseyed”. Please note this script assumes the input images are 3200 x 1200 pixel pairs of equally sized 1600 x 1200 pixel images. If your input images are some other size, then you will need to make adjustments to the above script.
Permissions
Don’t forget to change the script file’s permissions to make it executable. From the same directory run the following command:-
chmod +x garf-crosseyed
Dependencies
This script requires ImageMagick on your system. To install it on Debian-based systems, type or paste the following into a terminal and hit return:-
sudo apt install imagemagick
Credits
- ImageMagick
- With many thanks to my friend and model Estella Rose for dressing up in her “Dorothy Gale” costume and posing for some test images.
Disclaimer
Scripts and other code are provided as-is, with no warranty, express or implied. They all work perfectly for me, but I cannot guarantee they will work for you.
