Project

General

Profile

Bug #900

TIFF images lose XMP packet on write if exiv2 was compiled without XMP support

Added by Andreas Huggel over 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
tiff parser
Target version:
Start date:
13 May 2013
Due date:
% Done:

100%

Estimated time:
1.00 h

Description

I've played a bit with the library and so far I can tell that there is a strange behavior with the xmp handling. I've found a workaround that is suitable for me but maybe you are interested about this feedback:

- Compile exiv2 without xmp support.
- Open an image already containing XMLpacket data.
- Write any exif metadata on it and save.

The resulting image have the xml packet removed in case of tiff format. For jpeg format, the xml packet is still there. My guess is the second behavior is the good one... To have the same behavior for tiff I had to comment the encodeXmp() in tiffvisitor.cpp...

Reported by Loïc Carrère


Related issues

Related to Exiv2 - Bug #1081: Read XMP values from CR2 raw file when stored in XMLPacketClosed15 May 2015

Actions

Associated revisions

Revision 3739 (diff)
Added by Robin Mills over 6 years ago

#900. Preserve XMP data in TIFF files when XMPsdk is not build into the library.

History

#1

Updated by Robin Mills over 8 years ago

  • Status changed from New to Assigned
  • Assignee set to Robin Mills
#2

Updated by Robin Mills over 8 years ago

  • Target version set to 0.24
#3

Updated by Robin Mills over 8 years ago

  • Target version changed from 0.24 to 0.25

Deferred for 0.25.

#4

Updated by Robin Mills over 6 years ago

  • Target version changed from 0.25 to 0.26

Fix submitted: r3739

This is an interesting issue. Notes about various files formats can be found on the Exiv2 Wiki.

JPEG files consists of a number of variable length segments which store different kinds of data. Exif and XMP Metadata are contained in APP1 segments. When the library writes a file, it either rewrites a segment, or does a binary copy. When XMP has not been built into the library, the APP1/XMP packet is binary copied to the output file.

TIFF also contain variable length segments of which one is XMLpacket. The code in tiffvisitor.cpp encodeXMP() is used to recover XMP metadata from the non-existing XMPsdk and writes nothing! It has obliterated the XMLpacket.

Your suggested fix to comment out the code in tiff visitor.cpp encodeXMP() is perfect. The body of encodeXMP() is empty when #ifndef EXV_HAVE_XMP_TOOLKIT

This is not easy to test from our test harness because we normally build and test with --enable-xmp. However, I've built and manually tested this as follows on JPEG/PNG/TIFF images. The XMP data is preserved for TIFF files when XMPsdk has not been build with the library. This behaviour is consistent for JPEG/TIFF and PNG.

JPEG:

$ exiv2 -pS jpg.jpg 
STRUCTURE OF JPEG FILE: jpg.jpg
 address | marker     | length  | data
       2 | 0xd8 SOI  
       4 | 0xe1 APP1  |   14862 | Exif..II*.....................
   14868 | 0xe1 APP1  |    2720 | http://ns.adobe.com/xap/1.0/.<
   17590 | 0xed APP13 |     110 | Photoshop 3.0.8BIM.......6....
   17702 | 0xe2 APP2  |    4094 | MPF.II*...............0100....
   21798 | 0xdb DQT   |     132 
   21932 | 0xc0 SOF0  |      17 
   21951 | 0xc4 DHT   |     418 
   22371 | 0xda SOS   |      12 
$ exiv2 -pa -g Image jpg.jpg 
Warning: XMP toolkit support not compiled in.
Warning: Failed to decode XMP metadata.
...
Exif.Image.Model                             Ascii      12  NIKON D5300
...
$ exiv2 -M'set Exif.Image.Model Nikon is a very nice camera' jpg.jpg
Warning: XMP toolkit support not compiled in.
Warning: Failed to decode XMP metadata.
$ exiv2 -pS jpg.jpg 
STRUCTURE OF JPEG FILE: jpg.jpg
 address | marker     | length  | data
       2 | 0xd8 SOI  
       4 | 0xe1 APP1  |   14884 | Exif..II*.....................
   14890 | 0xe1 APP1  |    2720 | http://ns.adobe.com/xap/1.0/.<  <--- MOVED & PRESERVED
   17612 | 0xed APP13 |     110 | Photoshop 3.0.8BIM.......6....
   17724 | 0xe2 APP2  |    4094 | MPF.II*...............0100....
   21820 | 0xdb DQT   |     132 
   21954 | 0xc0 SOF0  |      17 
   21973 | 0xc4 DHT   |     418 
   22393 | 0xda SOS   |      12 
$
TIFF:
$ exiv2 -pS tif.tif 
STRUCTURE OF TIFF FILE: tif.tif
 address |    tag                      |      type |    count |   offset | value
      10 | 0x0100 ImageWidth           |     SHORT |        1 |  2621440 | 40
      22 | 0x0101 ImageLength          |     SHORT |        1 | 30801920 | 470
      34 | 0x0102 BitsPerSample        |     SHORT |        3 |      182 | 
      46 | 0x0103 Compression          |     SHORT |        1 |   327680 | 5
      58 | 0x0106 PhotometricInterpret |     SHORT |        1 |   131072 | 2
      70 | 0x0111 StripOffsets         |      LONG |        1 |     2694 | 0
      82 | 0x0112 Orientation          |     SHORT |        1 |   393216 | 6
      94 | 0x0115 SamplesPerPixel      |     SHORT |        1 |   196608 | 3
     106 | 0x0116 RowsPerStrip         |     SHORT |        1 | 71565312 | 1092
     118 | 0x0117 StripByteCounts      |      LONG |        1 |     5086 | 0
     130 | 0x011c PlanarConfiguration  |     SHORT |        1 |    65536 | 1
     142 | 0x013d Predictor            |     SHORT |        1 |   131072 | 2
     154 | 0x0153 SampleFormat         |     SHORT |        3 |      188 | 
     166 | 0x02bc XMLPacket            |      BYTE |     2500 |      194 | <?xpacket begin="..." id="W5M0Mp ...
$ exiv2 -M'set Exif.Image.Software exiv2' tif.tif 
Warning: XMP toolkit support not compiled in.
Warning: Failed to decode XMP metadata.
$ exiv2 -pS tif.tif 
STRUCTURE OF TIFF FILE: tif.tif
 address |    tag                      |      type |    count |   offset | value
      10 | 0x0100 ImageWidth           |     SHORT |        1 |  2621440 | 40
      22 | 0x0101 ImageLength          |     SHORT |        1 | 30801920 | 470
      34 | 0x0102 BitsPerSample        |     SHORT |        3 |      194 | 
      46 | 0x0103 Compression          |     SHORT |        1 |   327680 | 5
      58 | 0x0106 PhotometricInterpret |     SHORT |        1 |   131072 | 2
      70 | 0x0111 StripOffsets         |      LONG |        1 |     2712 | 0
      82 | 0x0112 Orientation          |     SHORT |        1 |   393216 | 6
      94 | 0x0115 SamplesPerPixel      |     SHORT |        1 |   196608 | 3
     106 | 0x0116 RowsPerStrip         |     SHORT |        1 | 71565312 | 1092
     118 | 0x0117 StripByteCounts      |      LONG |        1 |     5086 | 0
     130 | 0x011c PlanarConfiguration  |     SHORT |        1 |    65536 | 1
     142 | 0x0131 Software             |     ASCII |        6 |      200 | exiv2.
     154 | 0x013d Predictor            |     SHORT |        1 |   131072 | 2
     166 | 0x0153 SampleFormat         |     SHORT |        3 |      206 | 
     178 | 0x02bc XMLPacket            |      BYTE |     2500 |      212 | <?xp...   <--- MOVED & PRESERVED
PNG:
$ exiv2 -pS png.png 
STRUCTURE OF PNG FILE: png.png
 address | index | chunk_type |   length | data
       8 |     0 |       IHDR |       13 | 
      33 |     1 |       zTXt |     8769 | Raw profile type exif..x...[r..
    8814 |     2 |       zTXt |      270 | Raw profile type iptc..x.=QKn. 
    9096 |     3 |       iTXt |     2524 | XML:com.adobe.xmp.....<?xpacket
   11632 |     4 |       iCCP |     1404 | icc..x...i8.......af\...w_3...
   13048 |     5 |       sBIT |        3 | 
   13063 |     6 |       zTXt |       87 | Software..x...A.. ......B....}.
   13162 |     7 |       IDAT |     8192 | x...Y.$Wv&v.{.{l.T.......[w.=m$
...
  131376 |    22 |       IEND |        0 | 
$ exiv2 -pa -g Image png.png 
Warning: XMP toolkit support not compiled in.
Warning: Failed to decode XMP metadata.
...
Exif.Image.Make                              Ascii      18  NIKON CORPORATION
$ exiv2 -M'set Exif.Image.Model Nikon' png.png
Warning: XMP toolkit support not compiled in.
Warning: Failed to decode XMP metadata.
$ exiv2 -pS png.png 
STRUCTURE OF PNG FILE: png.png
 address | index | chunk_type |   length | data
       8 |     0 |       IHDR |       13 | 
      33 |     1 |       zTXt |     8773 | Raw profile type exif..x...k...
    8818 |     2 |       zTXt |      270 | Raw profile type iptc..x.=QKn. 
    9100 |     3 |       iTXt |     2524 | XML:com.adobe.xmp.....<?xpacket  <--- MOVED & PRESERVED
   11636 |     4 |       iCCP |     1404 | icc..x...i8.......af\...w_3...
   13052 |     5 |       sBIT |        3 | 
   13067 |     6 |       zTXt |       87 | Software..x...A.. ......B....}.
   13166 |     7 |       IDAT |     8192 | x...Y.$Wv&v.{.{l.T.......[w.=m$
...
  131380 |    22 |       IEND |        0 | 

#5

Updated by Robin Mills over 6 years ago

  • Status changed from Assigned to Resolved
#6

Updated by Robin Mills over 6 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Estimated time set to 1.00 h

This matter was incorrectly open for v0.25 and should have been closed (my error). Closing now.

Also available in: Atom PDF