ExifTool Forum

ExifTool => Archives => Topic started by: Archive on May 12, 2010, 08:54:36 AM

Title: Copying Makernotes from XML not working
Post by: Archive on May 12, 2010, 08:54:36 AM
[Originally posted by tni on 2009-06-06 09:19:52-07]

I'm extracting the metadata to an XML file:
Code:
perl ./Image-ExifTool-7.76/exiftool test_file.CR2 -X -l > test.xml

When trying to copy the metadata to a JPG, the Makernotes are lost (no Canon stuff at all in the jpg):
Code:
perl ./Image-ExifTool-7.76/exiftool -tagsFromFile test.xml -all:all test.jpg

exiftool seems to be able to read them (but doesn't do the copy for some reason):
Code:
perl ./Image-ExifTool-7.76/exiftool test.xml -X
Code:
<rdf:Description rdf:about='test.xml'
...
  xmlns:Canon='http://ns.exiftool.ca/MakerNotes/Canon/1.0/'
  xmlns:CanonCustom='http://ns.exiftool.ca/MakerNotes/CanonCustom/1.0/'
...
 <Canon:MacroMode>Normal</Canon:MacroMode>
...
 <CanonCustom:FocusingScreen>Ec-A,B,C,CII,CIII,D,H,I,L</CanonCustom:FocusingScreen>
...

However, when it is reading the XML data that includes the unconverted values, it reads the converted ones, e.g.:
Code:
perl ./Image-ExifTool-7.76/exiftool test.xml -X -l
test.xml:
Code:
...
 <ExifIFD:ApertureValue rdf:parseType='Resource'>
   <et:desc>Aperture Value</et:desc>
   <et:prt>12.9</et:prt>
   <et:val>12.883922655594</et:val>
 </ExifIFD:ApertureValue>
...
Output:
Code:
<ExifIFD:ApertureValue rdf:parseType='Resource'>
   <et:desc>Aperture Value</et:desc>
   <et:prt>12.9</et:prt>
 </ExifIFD:ApertureValue>

-- Tilo
Title: Re: Copying Makernotes from XML not working
Post by: Archive on May 12, 2010, 08:54:36 AM
[Originally posted by exiftool on 2009-06-06 12:05:31-07]

Hi Tilo,

Thanks for this report.

The -X option isn't 100% compatible with all exiftool features.
Reading and writing to XML isn't fully symmetrical.  In particular,
extra information written to the XML file isn't read by exiftool
when extracting.  This includes extra output from the -D,
-H, -l, -t and -struct options.
only the tag name and a single value are read when extracting
from XML.  This situation has been slowing improving, but I don't
think there will ever be complete symmetry here.

As far as the makernotes go: The makernotes can not be generated
from individual tags, it must be written as a binary data block.  For
this to work, the binary makernote block must be stored in the XML
file.  You can do this with -b -X -makernotes, but this
is not an ideal solution for a few reasons: 1) There is no convenient
way to get only a single copy of the makernote block in the -X
output if you also want to extract all other tags. 2) The makernote
offsets are not properly adjusted when extracting makernote binary
data from an XML file.  3) There is a bug in exiftool which prevents
encoded binary values in XML files from being decoded properly if
the same tag is extracted twice.  (this bug will be fixed in the next
release)

You should not be using XML if all you want to do is store a copy
of the metadata from an image.  Instead, use the MIE format.
XML has many limitations, and is a very inefficient storage format
for purposes like this.

- Phil
Title: Re: Copying Makernotes from XML not working
Post by: Archive on May 12, 2010, 08:54:36 AM
[Originally posted by tni on 2009-06-07 08:34:08-07]

Phil,

Thanks for your comments. I guess, I'll keep an additional MIE around. Is the Makernotes block left intact and stuffed as a BLOB into the MIE or are they included as separate fields?

With regards to the efficiency of XML, it's not that bad (this is for a Canon CR2):

Code:
MIE (-tagsFromFile -all:all -ThumbnailImage=): 9.5kb
MIE (-tagsFromFile -all:all -ThumbnailImage=) gziped: 3.3kb
XML (-X): 19kb
XML (-X) gziped: 4.7kb
XML (-X -l): 49.9kb
XML (-X -l) gziped: 7.6kb
JSON (-j -g:0:1:2): 10.9kb
JSON (-j -g:0:1:2) gziped: 3.5kb

-- Tilo
Title: Re: Copying Makernotes from XML not working
Post by: Archive on May 12, 2010, 08:54:36 AM
[Originally posted by exiftool on 2009-06-07 11:09:46-07]

Hi Tilo,

If you write to MIE with -all:all then all metadata is
stored in its original binary format.  In this case, the full makernotes
(including all as-yet unknown information, which is considerable)
are stored in binary format inside the native EXIF metadata and
encapsulated by the MIE file.

- Phil