Lonely Dreamer (sanmai) wrote,
Lonely Dreamer
sanmai

Fujifilm FinePix REAL 3D universal decoder for Linux and Mac



This script extracts the left and right image from any .MPO file, crops them to match the embedded parallax value, then makes an anaglyph image, stereopair (JPS, Stereo JPEG analogue), and also an animated GIF for your viewing pleasure.

Prequisites: bash, ExifTool, ImageMagick, and bc.

See example output at the bottom.
#!/bin/bash
SRC=$1;
BASENAME="`basename $SRC .MPO`"
LEFT="${BASENAME}-L.jpg"
RIGHT="${BASENAME}-R.jpg"
GIF="${BASENAME}.gif"
STEREO="${BASENAME}-stereo.jpg"
ANAGLYPH="${BASENAME}-anaglyph.jpg"
 
rm $RIGHT $LEFT 2> /dev/null
 
# Extract left and right images
exiftool -trailer:all= "$SRC" -o "$LEFT"
exiftool "$SRC" -mpimage2 -b > "$RIGHT"
 
# Raw parallax value from the right photo
PARALLAX=`exiftool -b -Parallax "$RIGHT"`
 
# Original image width
WIDTH=`exiftool -b -ImageWidth "$RIGHT"`
 
# Parallax multiplier
SHIFT=$((WIDTH/100))
 
# Parallax value in pixels
PARALLAX=`echo "($PARALLAX * $SHIFT + 0.5)/1" | bc`
 
# Default gravity for positive parallax
GRAVITY_LEFT=East
GRAVITY_RIGHT=West
 
# Invert gravity for negative parallax values
if [ "${PARALLAX:0:1}" = "-" ] ; then
	PARALLAX=${PARALLAX#-}
	GRAVITY_LEFT=West
	GRAVITY_RIGHT=East
fi;
 
# Adjust image width
WIDTH=$((WIDTH-PARALLAX))
 
# Crop away out of view parts of both images
mogrify -verbose -gravity $GRAVITY_LEFT -crop ${WIDTH}x0+0+0 +repage $LEFT 
mogrify -verbose -gravity $GRAVITY_RIGHT -crop ${WIDTH}x0+0+0 +repage $RIGHT
 
composite -stereo +0 $LEFT $RIGHT $ANAGLYPH
mogrify -resize "1024x1024>" $ANAGLYPH
 
montage $LEFT $RIGHT -verbose -mode Concatenate -tile x1 -resize "1024x1024>" $STEREO
 
convert -verbose -delay 30 $LEFT $RIGHT -resize 600x600 $GIF;
rm $RIGHT $LEFT 2> /dev/null

Usage:
./MPO.sh DSCF1234.MPO

Red-blue anaglyph:


Animated GIF:


JPS, Stereo JPEG:


Stereo-on-hover:
(move your mouse in and out to see the effect)
Tags: 3d, linux, mac, useful, про фото
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 16 comments