Removing the MPImage2 tag in a .mpo file from a FujiFilm Real 3D W1 camera

Started by wsherman, May 10, 2010, 10:37:31 PM

Previous topic - Next topic

wsherman

Hello,

I recently found my way to the ExifTool via a weblog on how to extract multiple images from the .mpo format used by the FujiFilm Real 3D W1 camera.  And I really love all the features included in exiftool, and the fact that I don't have to rely on non-Linux applications to extract the left-eye image from the .mpo file is great.

But I do have a request (perhaps it's a bug report, I don't know).

Presently there are two ways to get the right eye image from the .mpo file, so to some degree this question is academic.  But I'm thinking there is a more elegant solution, and so I thought I'd see if it might be possible.

As the author of exiftool knows (so this bit of info is for other readers), an MPO file is basically a JPEG file with additional images that can be accessed via some EXIF tags.  The right-eye image in the .mpo file is the primary image, and most image applications that can handle JPEGs will simply treat the file as a single JPEG image that happens to be the right-eye view as produced by the FujiFilm 3D camera.  The left-eye view is contained as the 2nd image, and can be retrieved with the "MPImage2" tag.

So, one way to "extract" the right image from the original .MPO file is simply to remove all the data after the trailing EXIF tags:
   % exiftool -trailer:all= dscf0213.mpo -o ~/Temp/dscf0213_right.jpg

The problem with this method is that the file still thinks it's an MPO file containing multiple images.  So if one then tries to extract the "MPImage2" tag at this point, it generates an error because the tag is there, but the data is missing.  Also the other MPO related tags will indicate that there are 2 images in the file, etc.

So I thought the "elegant" solution would simply be to remove the "MPImage2" tag from the file (and I suppose some manual adjustments would still be required of the "NumberOfImages" tag (and maybe 5 others: MPImageFlags, MPImageFormat, MPImageType, MPImageLength, MPImageStart -- though perhaps really only the latter two are the most important).  I started by simply trying to remove the "MPImage2" tag, but got this result:
    % exiftool -mpimage2 ~/Temp/dscf0213.mpo
   MP Image 2                      : (Binary data 2569447 bytes, use -b option to extract)

    % exiftool -b -f -mpimage2= ~/Temp/dscf0213.mpo -o dscf0213rev.mpo
   Warning: Tag 'mpimage2' does not exist


Of course, as per the first command, the tag does exist.  So I'm wondering if the "does not exist" message really means "is not writeable".  And hence my request is that it be made possible to remove the "MPImage2" tag -- and then also alter the "MPImageLength" and "MPImageStart" tags.

I guess the ultimate in elegancy would be for there to be an "MPImage1" tag that could be used to extract the right-eye image with all the MPO tags properly adjusted -- namely the "MPIndividualNum" tag indicates the ordering of that particular image within the MPO file from which it was extracted.


For completeness sake, there are two other ways to get the right-eye image, but neither of these provides updated MPO tags that indicate this to be image 1 of a set of images.  Method #1 is to simply use the .mpo file as the right-eye jpeg file (as indicated above, most applications will only see that first image only).  And Method #2 is the easiest -- the camera will actually save a single JPEG image of each 3D shot along side the .MPO file, so whenever a picture is taken, three images are written to memory card, the right eye in the JPEG file and both eyes in the MPO file.  Again though, the "MPIndividualNum" tag is not present in the directly produced JPEG file, so again I'm hoping for the possibility of some more "elegant" solution.

Obviously not an urgent request by any means, and I suppose I might be able to create the "MPIndividualNum" tag in my right-eye images too.


One other thought occurs to me prior to wrapping up this post -- there is also a "Parallax" tag, but oddly it only shows up in the left-eye image that is extracted from the original MPO file.  Just a passing bemused thought.

    Thank you,
    Bill

Phil Harvey

I suggest this command to extract the right-eye image from an mpo:

exiftool -all= --exif:all -o %f_right.jpg FILE

This will remove the MPF information as well as the other images but preserve the EXIF.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ludovic

Hello,

Phil wrote
QuoteI suggest this command to extract the right-eye image from an mpo:
exiftool -all= --exif:all -o %f_right.jpg FILE

Is there an equivalent for the left eye image?

Have you investigated the sony NEX-5 which takes 3D panorama? It seems the left image would be the 3rd one (to extract with -mpimage3).

Ludovic

Phil Harvey

Hi Ludovic,

Quote from: ludovic on September 24, 2010, 04:19:07 AM
Is there an equivalent for the left eye image?

The command could look something like this:

exiftool -mpimage2 -b -w %f_left.jpg FILE

But depending on the camera, it may be MPImage3.  You would need to check to see which other image has an MPImageType of "Multi-frame Disparity" and use that one.

Quote
Have you investigated the sony NEX-5 which takes 3D panorama? It seems the left image would be the 3rd one (to extract with -mpimage3).

Do you know where I can get an NEX-5 MPO sample image?  I haven't found one yet.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

Just for completeness, here is a set of commands that should generate left/right JPEG images for all MPO images in a directory:

exiftool -all= --exif:all -o %d%f_right.jpg -ext mpo DIR
exiftool -mpimage2 -b -w %d%f_left.jpg -if "$mpimage2:mpimagetype==0x020002" -ext mpo DIR
exiftool -mpimage3 -b -w %d%f_left.jpg -if "$mpimage3:mpimagetype==0x020002" -ext mpo DIR


(note: use single quotes instead of double quotes in the above commands if you are on Mac or Linux)

One thing that is a bit tricky is that the last two commands must test the numerical value of MPImageType since the -b option was used. (Otherwise I would normally do something like -if "$mpimage2:mpimagetype=~/Disparity/".)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ludovic

Phil,

Thank you for the additional tips on extracting images from mpo, I tested all you mentioned on a linux platform with success.

I attached an mpo file from the sony NEX5. It is not art but we use it in my lab to try to compute depth map from the left and right images and see if it is worth using this camera for such a purpose.
Note that when shooting a 3D panorama, you can select the direction along which to sweep the scene. This mpo was shot from left to right.

I will shoot other mpo and provide some to you if this can help (is the best to attach them in posts?)

Oh... I couldn't upload my file in this post, a message said it took too long to upload my attachment. I will try later.

Ludovic

Phil Harvey

Hi Ludovic,

Feel free to mail me the sample (philharvey66 at gmail.com) if that is easier for you.

Thanks.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

vinny

This is making me a bit crazy.  I've got a Fuji W3 camera.  It looks like they've reversed right and left from the W1.  Its weird so I just don't want to take it on my own testing.  I tested by creating two 3d photos and interfered with the left lens in the first and the right lens in the second.  So when I execute

exiftool -all= --exif:all -o %d%f_R.mpo.jpg $1

I get the left lens image and when i execute

exiftool -mpimage2 -b -w %d%f_L.mpo.jpg -if '$mpimage2:mpimagetype==0x020002' $1

I get the right lens image.  Am I making a bonehead mistake or did Fuji just swap things around for grins?

As a side note, the 'viewfinder' shows the left lens image so maybe its a primary/secondary kind of thing.

Thanks!  Exiftool is amazing!




Phil Harvey

It could easily be that they reversed the location of the images.  I don't have a W3 .MPO sample, so I can't say for sure.  (If you want to send me one, I would be happy to have a sample)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gemlion

I hope it is okay to proceed here instead of opening a new topic. I was happy to find this topic. But I'd like to define the target file by name. I tried:

exiftool -mpimage2 -b -o "path/to/target/file.jpg" "source.MPO"

which, unfortunately does not work. What am I doing wrong?

Phil Harvey

The -o option is used to set the output when writing tags to an image.  However, the -W (capital W) option should do what you want:

exiftool -mpimage2 -b -W "path/to/target/file.jpg" "source.MPO"

Usually though, this is done by shell redirection:

exiftool -mpimage2 -b "source.MPO" > "path/to/target/file.jpg"

The only functional difference between these two commands is that the first command won't create a new file if MPImage does not exist, while the second command would create a zero-length file in this case.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gemlion

Unfortuantely this command:

exiftool -mpimage2 -b -W "target.jpg" "(2012-11-11 06-21-45).MPO"

creates a file which contains the name of the source file:

(2012-11-11 06-21-45)target.jpg

Therefore I can't change the path where to create this file. Thats the same what the command with lower case -w does.

Phil Harvey

Try updating to a more recent version of ExifTool.  This feature was added in version 9.23.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gemlion

Ah, alright. The problem was, that ExifTool in (K)ubuntu is very outdated. But following the instructions how to install exiftool evereything worked fine. Thank you. Problem solved.

gemlion

One last question (very similar to the first one in this topic):

When splitting an MPO image with these two commands:

exiftool -all= --exif:all -o TARGET-L SOURCE

and

exiftool -mpimage2 -b -W TARGET-R SOURCE

IPTC and XMP tags are removed from the first image as well, right? To preserve them, do I have to change them to (?):

exiftool -all= --exif:all --iptc:all --xmp:all -o TARGET-L SOURCE

and is it safe to copy all exif-tags from MPO file to the second image to keep comments, GPS-coordinates and so on?

Cheers,
Gem