Archive for the Uncategorized Category

Splitting a .mpo file

3D photography is something that I was massively into for a couple of years, starting when 3D films were beginning to make a resurgence at the cinema and 3D televisions were just entering the market. In that time I bought a Fujifilm W1 3D camera and a couple of 3D Loreo lenses so that I could take stereoscopic images using my existing SLRs.


The issue for me was always how to view the photographs afterwards; lenticular prints (ridged prints that let your right and left eye see different images) were the best option, but on my old photography site (… which will soon be owned by someone else) I wanted to give people options of how to view the photos. The options I gave were red / cyan anaglyphs (viewable using red / cyan glasses) or stereoscopic pictures (viewable using stereoscopic glasses, or by using the “magic eye” technique of going slightly cross-eyed.


Yes, I even had a bit of a foray into 3D wedding photography, with mainly positive feedback.

It was easy to manipulate the photos I’d taken on my SLRs into those formats, but I had a bit of a pain with the “.mpo” format produced by the Fujifilm W1. It comes with its own software bundle for Windows and Mac…I used (and continue to use) Ubuntu. So, I wrote a little bash script to help to batch extract the .mpo format images into something more useful for my standard image-processing workflow. It relies on ImageMagick and ExifTool, then I use AnaBuilder to further play (manually) with the anaglyph images it creates.

sudo apt-get install imagemagick
sudo apt-get install libimage-exiftool-perl

Credit should go to the 3D photography blog for getting me started with the exiftool commands. I’ll put in my standard caveat: the code below is probably sub-optimal, but it worked for me.

for img in *.mpo
echo " splitting " $img;


# create temporary left and right images
exiftool -trailer:all= $img -o $imgName"_L.jpg"
exiftool $img -mpimage2 -b > $imgName"_R.jpg"

echo " combining left and right for " $imgName;
# create stereo image
convert $imgName"_L.jpg" $imgName"_R.jpg" +append $imgName"-stereo.jpg"

# create red-blue image and resize it for anaBuilder (x dimension of 2000 pixels)
composite -stereo 0 $imgName"_L.jpg" $imgName"_R.jpg" $imgName"-redbluetmp.jpg"

# extract the dimensions of the image
pixelX=$(identify $imgName"-redbluetmp.jpg" | sed 's/^.*JPEG \(.*\)x.*$/\1/' | cut -d' ' -f2);
pixelY=$(identify $imgName"-redbluetmp.jpg" | sed 's/^.*x\(.*\)+.*$/\1/' | cut -d'+' -f1);

if [ $pixelX -gt $pixelY ] ; then
tempsize=`echo "scale=4; 2000/$pixelX" | bc`;
tempsize=`echo "scale=4; 2000/$pixelY" | bc`;

size=`echo "scale=4; $tempsize*100" | bc`;

convert $imgName"-redbluetmp.jpg" -resize $size% $imgName"-redblue.jpg"

# remove the temporary images
echo " removing temporary images"
rm $imgName"_L.jpg"
rm $imgName"_R.jpg"
rm $imgName"-redbluetmp.jpg"

I’ll admit that I’ve now moved away from 3D photography – whilst it was fun and niche, it was a bit of a distraction for me and I think in its current form it will only ever be a gimmick. What I’m waiting for is proper 3D – filming from multiple angles, then recreating holographically!