Project

General

Profile

xmp metadata modified when using »exiv2 insert -lcompr -S.tif none/*.tif«

Added by Jochen Barth about 5 years ago

Dear forum,

I'll try to de-compress tiff files with multiple TIFF-Directories, e. g. tiffinfo 00007.tif:
TIFF Directory at offset 0x8 (8)
Subfile Type: (0 = 0x0)
Image Width: 3442 Image Length: 6017
Resolution: 697.719, 697.719 pixels/inch
Bits/Sample: 8
Compression Scheme: LZW
...
TIFF Directory at offset 0x1897ec4 (25788100)
ExposureTime: 0.076923
FNumber: 9.000000
ExposureProgram: 1
ISOSpeedRatings: 125
Tag 34864: 2
Tag 34866: 125
...

When de-compressing using tiffcp -c none compr/00007.tif none/00007.tif
the secondary TIFF Directory is being lost.

So I've tried exiv2 to copy the metadata from compr/00007.tif to none/00007.tif,
but then the XMP XML/RDF metadata is somewhat disordered (tags to attributes, partially):

6c6
< Compression Scheme: LZW
---

Compression Scheme: None

18,235c18,221
< <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27 ">
< <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
< <rdf:Description rdf:about=""
< xmlns:xmp="http://ns.adobe.com/xap/1.0/">
< <xmp:Rating>0</xmp:Rating>
< <xmp:ModifyDate>2016-06-03T07:34:05+02:00</xmp:ModifyDate>
< <xmp:CreateDate>2016-06-02T12:06:58</xmp:CreateDate>
< <xmp:MetadataDate>2016-06-03T07:34:05+02:00</xmp:MetadataDate>
< <xmp:CreatorTool>Adobe Photoshop CS6 (Windows)</xmp:CreatorTool>
< </rdf:Description>
< <rdf:Description rdf:about=""
< xmlns:aux="http://ns.adobe.com/exif/1.0/aux/">
< <aux:SerialNumber>073022001352</aux:SerialNumber>
< <aux:LensInfo>100/1 100/1 0/0 0/0</aux:LensInfo>
< <aux:Lens>EF100mm f/2.8 Macro USM</aux:Lens>

...

> &lt;x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core  4.4.0-Exiv2"&gt;
> &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
> &lt;rdf:Description rdf:about=""
> xmlns:xmp="http://ns.adobe.com/xap/1.0/"
> xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
> xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
> xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
> xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
> xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#"
> xmlns:dc="http://purl.org/dc/elements/1.1/"
> xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"
> xmp:Rating="0"
> xmp:ModifyDate="2016-06-03T07:34:05+02:00"
> xmp:CreateDate="2016-06-02T12:06:58"
> xmp:MetadataDate="2016-06-03T07:34:05+02:00"
> xmp:CreatorTool="Adobe Photoshop CS6 (Windows)"
> aux:SerialNumber="073022001352"
> aux:LensInfo="100/1 100/1 0/0 0/0"
> aux:Lens="EF100mm f/2.8 Macro USM"

...

Is there a switch to prevent this modification and copy metadata "as pure as possible" from file a to b?

Kind regards,
Jochen


Replies (6)

RE: xmp metadata modified when using »exiv2 insert -lcompr -S.tif none/*.tif« - Added by Robin Mills about 5 years ago

I think the answer is "Yes". However we have to get to a common understanding of what you hope to achieve.

New features have been added to the trunk (for the upcoming v0.26 release) to extract and insert XMP into images. To extract raw XMP to stdout:

$ exiv2 -pX foo.img 
To insert raw XMP (from the file foo.xmp)
$ exiv2 -iXX foo.img
You can pipe XMP from stdin:
$ cat my_file.xmp | exiv2 -iXX- foo.img

And there are better file dump and analysis tools. The following command recursively dump structures from an image to help you understand what is being done.

 $ exiv2 -pR foo.img

Please take a look at those tools. To make more progress with your request, please attach a sample image and a longer explanation of your thoughts. When we are "on the same page", I'm confident we'll find a way forward.

RE: xmp metadata modified when using »exiv2 insert -lcompr -S.tif none/*.tif« - Added by Robin Mills about 5 years ago

I omitted to say that if you are dealing with multi-page tiff files, our support for this is an open issue #1124. It's on the list of features being considered for v0.27. http://dev.exiv2.org/news/3

I had some success in using libtiff to split multi-page tiff files into single pages, modify pages, and reassemble the multi-page document with libtiff's tiffcp command. This is described in #1124 and has been occasionally discussed in the forum. Searching for tiffcp will reveal those conversions.

RE: xmp metadata modified when using »exiv2 insert -lcompr -S.tif none/*.tif« - Added by Jochen Barth about 5 years ago

No, the image is not multi-tiff; it is 2-tiff-directories/1-image-data;

here is the file for download:

http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif

Kind regards,
Jochen

RE: xmp metadata modified when using »exiv2 insert -lcompr -S.tif none/*.tif« - Added by Robin Mills about 5 years ago

Thank You for providing a test file and clarifying that we are discussing a single page tiff.

What issue are we trying to solve here?

Exiv2 normally builds an internal representation of the metadata in memory. The v0.26 options: -pX and -iXX literally copy the metadata from the image. The command: $ exiv2 -ex /path/to/0007.tif reads your image into memory and serialises that data into the sidecar /path/to/0007.xmp. The command: $ exiv2 -pX ..... 0007.tif copies the XMP from the image to standard output (without deserializing/serializing the XMP). The command: $ exiv2 -iXX- /path/to/0007.tif copies the XMP from standard input and directly updates the image /path/to/0007.tif.

So, I think way to move the XMP with minimum processing (and therefore maximum fidelity) is to use the -pX/iXX options to extract the XMP from one image and place it in another.

Here's what I see. I can dump the structure of the TIFF file, extract and rewrite the XMP.

607 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pR http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif | head -10 ; echo '...' ; 
STRUCTURE OF TIFF FILE (II): http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif
 address |    tag                           |      type |    count |    offset | value
      10 | 0x00fe NewSubfileType            |      LONG |        1 |         0 | 0
      22 | 0x0100 ImageWidth                |     SHORT |        1 |      3442 | 3442
      34 | 0x0101 ImageLength               |     SHORT |        1 |      6017 | 6017
      46 | 0x0102 BitsPerSample             |     SHORT |        3 |       314 | 8 8 8
      58 | 0x0103 Compression               |     SHORT |        1 |         5 | 5
      70 | 0x0106 PhotometricInterpretation |     SHORT |        1 |         2 | 2
      82 | 0x010f Make                      |     ASCII |        6 |       320 | Canon
      94 | 0x0110 Model                     |     ASCII |       14 |       326 | Canon EOS 5DS
...
608 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pR http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif | tail -10
  25788414 | 0xa402 ExposureMode              |     SHORT |        1 |         1 | 1
  25788426 | 0xa403 WhiteBalance              |     SHORT |        1 |         1 | 1
  25788438 | 0xa406 SceneCaptureType          |     SHORT |        1 |         0 | 0
  25788450 | 0xa431 BodySerialNumber          |     ASCII |       13 |  25788614 | 073022001352
  25788462 | 0xa432 LensSpecification         |  RATIONAL |        4 |  25788627 | 100/0 1/0 100/0 1/0
  25788474 | 0xa434 LensModel                 |     ASCII |       24 |  25788659 | EF100mm f/2.8 Macro USM
  25788486 | 0xa435 LensSerialNumber          |     ASCII |       11 |  25788683 | 0000000000
  END http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif
     298 | 0x8773 InterColorProfile         | UNDEFINED |      560 |     28040 | ...0ADBE....mntrRGB XYZ ....... ...
END http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif
609 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pX http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif | xmllint --pretty 1 - | wc 
    214     291   10576
610 rmills@rmillsmbp:~/gnu/exiv2/trunk $ curl --silent -O http://digi.ub.uni-heidelberg.de/diglitData/v/00007.tif
611 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pX test/data/Reagan.jpg  | exiv2 -iXX- 00007.tif 
612 rmills@rmillsmbp:~/gnu/exiv2/trunk $ exiv2 -pX 00007.tif  | xmllint --pretty 1 - | wc 
     69     264    6354
613 rmills@rmillsmbp:~/gnu/exiv2/trunk $ 

RE: xmp metadata modified when using »exiv2 insert -lcompr -S.tif none/*.tif« - Added by Jochen Barth about 5 years ago

Our partner wants non-compressed tiff files, but we have internally lzw compressed ones.
The metadata of the tiffs should not change (excluding compression info, of course) - but with imagemagick the secondary tiff directory is being lost.

RE: xmp metadata modified when using »exiv2 insert -lcompr -S.tif none/*.tif« - Added by Robin Mills about 5 years ago

I'm lost, Jochen. I don't know anything about your partner, libtiff or imagemagick. I'm trying to help you. I'm guessing that you have some kind of image processing pipeline and you want Exiv2 to copy the metadata from the original images into the processed images. Is that right? Would it help to discuss this on an instant messenger such as Skype ('clanmills')?

    (1-6/6)