Lens data copied incorrectly

Started by grums, April 17, 2016, 10:44:05 AM

Previous topic - Next topic

grums

My first post ;)

I'm experimenting with exiftool (10.13) as backup/restore solution for my metadata, so I tried this simple operation:

1) Copy A.jpg to B.jpg (In Windows CMD prompt)
2) Remove all metadata from B.jpg (using a tool I know: IrfanView)
3) Verify the metadata has gone: exiftool -a -u b.jpg
4) Restore the metadata to B.jpg: exiftool -a -u -tagsfromfile A.jpg B.jpg
5) Save the metadata listing to text files: exiftool -a -u A.jpg >A.txt AND exiftool -a -u B.jpg >B.txt
6) Check the differences between the text files: diff -iwB A.txt B.txt
    (diff is a handy Linux file comparison tool which is ported to Windows)

I notice some obvious differences (time changes, blocks shifted, offsets changed), but at the very end I see this:
Quote198c213
< Scale Factor To 35 mm Equivalent: 5.6
---
> Scale Factor To 35 mm Equivalent: 19.7
203,208c218,223
< Circle Of Confusion             : 0.005 mm
< Depth Of Field                  : 10.76 m (0.65 - 11.41 m)
< Field Of View                   : 65.6 deg
< Focal Length                    : 5.0 mm (35 mm equivalent: 27.9 mm)
< Hyperfocal Distance             : 1.37 m
< Lens                            : 5.0 - 60.0 mm (35 mm equivalent: 27.9 - 335.1 mm)
---
> Circle Of Confusion             : 0.002 mm
> Depth Of Field                  : 0.66 m (0.98 - 1.64 m)
> Field Of View                   : 20.7 deg
> Focal Length                    : 5.0 mm (35 mm equivalent: 98.7 mm)
> Hyperfocal Distance             : 4.83 m
> Lens                            : 5.0 - 60.0 mm (35 mm equivalent: 98.7 - 1184.7 mm)

My interpretation of the above is that some lens calculations go wrong - I don't understand why the values are not just copied?

I will happily provide any additional documentation needed.

Regards

StarGeek

Quote from: grums on April 17, 2016, 10:44:05 AM
2) Remove all metadata from B.jpg (using a tool I know: IrfanView)

Slightly off topic, I'm curious how you went about this.  I've never noticed an option to do this in Irfanview. 

It looks like most of the tags you are listing are Composite tags, which not tags that are actually part of the file, but data which is derived from other tags.  Part of the problem probably lies within your command, exiftool -a -u -tagsfromfile A.jpg B.jpg.  This command doesn't do an exact copy of the tags.  From the docs, "If no tags are specified, then all possible tags (see note 1 below) from the source file are copied to same-named tags in the preferred location of the output file" (emphisis mine).  See -TAG for preferred groups listing. 

What you want to do is use -tagsfromfile A.jpg -All:All B.jpg to make sure all the tags are copied into the same place.  Also, you might want to add -G1 to your listing command to see where the metadata is actually located.



* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

grums

Thanks StarGeek!

The IrfanView thing is located in the Thumbnails program: File->JPG Lossless Operations->Lossless rotation...

Now the commands are:
1) Remove all metadata from B.jpg (using a tool I know: IrfanView)
2) Copy metadata: exiftool -tagsfromfile A.jpg -All:All B.jpg
3) Dump metadata of original: exiftool -a -u -G1 A.jpg >A.txt
4) Dump metadata of copy: exiftool -a -u -G1 B.jpg >B.txt
5) Compare: diff -iwB A.txt B.txt

Output:
Quote198c191
< [Composite]     Scale Factor To 35 mm Equivalent: 5.6
---
> [Composite]     Scale Factor To 35 mm Equivalent: 19.7
203,208c196,201
< [Composite]     Circle Of Confusion             : 0.005 mm
< [Composite]     Depth Of Field                  : 10.76 m (0.65 - 11.41 m)
< [Composite]     Field Of View                   : 65.6 deg
< [Composite]     Focal Length                    : 5.0 mm (35 mm equivalent: 27.9 mm)
< [Composite]     Hyperfocal Distance             : 1.37 m
< [Composite]     Lens                            : 5.0 - 60.0 mm (35 mm equivalent: 27.9 - 335.1 mm)
---
> [Composite]     Circle Of Confusion             : 0.002 mm
> [Composite]     Depth Of Field                  : 0.66 m (0.98 - 1.64 m)
> [Composite]     Field Of View                   : 20.7 deg
> [Composite]     Focal Length                    : 5.0 mm (35 mm equivalent: 98.7 mm)
> [Composite]     Hyperfocal Distance             : 4.83 m
> [Composite]     Lens                            : 5.0 - 60.0 mm (35 mm equivalent: 98.7 - 1184.7 mm)

I'v attached the output from diff -iwBy -w170 A.txt B.txt (side-by-side comparison of the two files)

Regards

Phil Harvey

Since you are rebuilding the EXIF from scratch, you also should be copying the unsafe tags (as per FAQ 20).  As well, you can use ExifTool to remove the original metadata first in the same operation (ie. no need to run IrfanView first).  So try this:

exiftool -all= -tagsfromfile A.jpg -All:All -unsafe B.jpg

I'm not sure about the exact reason why the calculated ScaleFactor35efl is different.  I would have to look into this in more detail.  I have a PowerShot S sample that I can test this with, but I won't have time to do this until tomorrow.

- 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 ($).

StarGeek

Quote from: grums on April 17, 2016, 01:57:52 PM
The IrfanView thing is located in the Thumbnails program: File->JPG Lossless Operations->Lossless rotation...

Ahh, got it.  I the lossless rotation nearly every day, but since I have the options set how I like them, I haven't looked at them in a long time.

As for the tags, those are all composite tags, so they're not actually part of the file, they're derived from other tags.  And they nearly all seem to be based upon ScaleFactor35efl (Scale Factor To 35 mm Equivalent).  If you can post a sample image, I'm curious enough to take a look, but can't guarantee anything.  You may have to wait until Phil can look into it in greater detail.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Quote from: Phil Harvey on April 17, 2016, 03:42:30 PM
I have a PowerShot S sample that I can test this with, but I won't have time to do this until tomorrow.

Ooops.  While I do have a sample from every Canon PowerShot ever made, I need to know the model number of your camera.  The model name was truncated to "PowerShot S" in your side-by-side output file, but there are 199 different models with names that start like this.

- 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 ($).

grums

Thanks both!
Sorry for not revealing the camera model: it's a Canon PowerShot SX130 IS

Phil Harvey

Ah very interesting.  The difference is due to a bit of magic that ExifTool uses to determine the focal plane resolution for Canon images, combined with the fact that the stored rational values for FocalPlaneX/YResolution are reduced when these values are rewritten.  I will fix the magic algorithm to take this into account, so ScaleFactor35efl will be properly calculated for the image with the copied metadata.  This difference also results in the changed values of all of the other Composite tags since they are based on ScaleFactor35efl.

The bottom line is that the information is copied correctly, and the differences you are seeing are due to the different way the information is stored.

I don't know exactly what you are trying to achieve here, but if you want to preserve the structure of the EXIF and XMP at the binary level, you could copy them as binary data blocks and eliminate differences like this.  To do this, the command would look like:

exiftool -all= -tagsfromfile A.jpg -exif -xmp B.jpg

- 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 ($).

grums

Thank you Phil.

I'm trying to make a backup of my metadata - and also be sure to be able to restore the backup...
I originally started out creating a MIE sidecar file for backup, restoring it to a copy of the same image (without metadata), and then testing by comparing a dump of the metadata of the images.
When I got the error with the lens data, I ended up with the one-liner instead - just for testing.

The last command you presented does remove the lens data error - great!
I noticed that my IPTC data was not copied, but being a bold poster in the newbie group I tried just to add -iptc as well, so now that's copied as well - thank you again.

Phil Harvey

Quote from: grums on April 18, 2016, 10:03:18 AM
I noticed that my IPTC data was not copied, but being a bold poster in the newbie group I tried just to add -iptc as well, so now that's copied as well - thank you again.

Right.  Glad you figured this out.  I was working with an SX130IS sample which didn't contain IPTC.

- 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 ($).