添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe the bug
The documentation states that comments and EXIF data can be read from PNG files. As far as I can tell, it works for XMP, IPTC and ICC, but not for comments and EXIF.

To Reproduce
Steps to reproduce the behaviour:

  • build Exiv2 commit 6215d57 (quite current) OR use pre-compiled exiv2 0.25 (Ubuntu 18.04)
  • Insert comment and/or EXIF data into any png file:
  • exiftool test.png -exif:ImageDescription='Test EXIF' -o test_with_exif.png
    exiftool test.png -comment='Test comment' -o test_with_comment.png
    
  • The inserted data can neither be read with the compiled lib nor with exiv2 executable. The chunks WITH the data can be seen in the printed structure though.
  • Expected behavior
    I would expect to actually get the EXIF data and the comment as the documentation promises that.

    Desktop (please complete the following information):

  • OS: Ubuntu 18.04 LTS
  • Compiler & Version: Gcc 7.3
  • Exiv2 does read EXIF encoded data in PNG file and this is tested in our test harness.

    1200 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pe test/data/ReaganLargePng.png
    Exif.Image.NewSubfileType                    Long        1  0
    Exif.Image.ImageWidth                        Long        1  200
    Exif.Image.ImageLength                       Long        1  130
    Exif.Image.BitsPerSample                     Short       3  8 8 8
    Exif.Image.Compression                       Short       1  5
    

    Can you please provide your test file and I will investigate.

    Comment inserted into empty.png by:
    exiftool empty.png -comment='Can you read me?' -o comment.png
  • exif.png
    EXIF.image.ImageDescription added to empty.png by:
    exiftool empty.png -exif:ImageDescription='Can you read me?' -o exif.png
  • Using Exiv2 on it:

    $ exiv2 --version
    exiv2 0.25 001900 (64 bit build)
    $ exiv2 comment.png 
    File name       : comment.png
    File size       : 400 Bytes
    MIME type       : image/png
    Image size      : 200 x 100
    comment.png: No Exif data found in the file
    $ exiv2 exif.png 
    File name       : exif.png
    File size       : 484 Bytes
    MIME type       : image/png
    Image size      : 200 x 100
    exif.png: No Exif data found in the file
    

    But I'm actually using the lib directly inside a project using the commit as mentioned above, where it is also not working.

    This is very interesting. Firstly, to see the exif metadata, you should use the option -pe. The default (when you don't use any -pOption) prints a brief summary. I can however confirm that exiv2 isn't collected the EXIF metadata from your file. The reason is the encoding of your chunk.

    1210 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pa ~/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png 
    1211 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pS ~/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png 
    STRUCTURE OF PNG FILE: /Users/rmills/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png
     address | chunk |  length | data                           | checksum
           8 | IHDR  |      13 | .......d....                   | 0x4ce4e85c
          33 | sRGB  |       1 |                                | 0xaece1ce9
          46 | gAMA  |       4 | ....                           | 0x0bfc6105
          62 | pHYs  |       9 | .........                      | 0xc76fa864
          83 | IDAT  |     257 | x^..1..0......t.....h......z.. | 0x64465429
         352 | eXIf  |     108 | MM.*.................J........ | 0x764e86e1  <---- What's this?
         472 | IEND  |       0 |                                | 0xae426082
    1212 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ exiv2 -pS test/data/ReaganLargePng.png 
    STRUCTURE OF PNG FILE: test/data/ReaganLargePng.png
     address | chunk |  length | data                           | checksum
           8 | IHDR  |      13 | ............                   | 0x8cf910c3
          33 | zTXt  |    8461 | Raw profile type exif..x...iv. | 0x91fbf6a0  <--- We're looking for this
        8506 | zTXt  |     636 | Raw profile type iptc..x..TKn. | 0x4e5178d3
        9154 | iTXt  |    7156 | XML:com.adobe.xmp.....<?xpacke | 0x8d6d70ba
       16322 | gAMA  |       4 | ....                           | 0x0bfc6105
       16338 | iCCP  | 1151535 | ICC profile..x...UP.........!! | 0x11f49e31
     1167885 | bKGD  |       6 | ......                         | 0xa0bda793
     1167903 | pHYs  |       9 | ...#...#.                      | 0x78a53f76
     1167924 | tIME  |       7 | ......2                        | 0x582d32e4
     1167943 | zTXt  |     278 | Comment..x.}[email protected].. | 0xdb1dfff5
     1168233 | IDAT  |    8192 | x...k.%.u%....D......GWW...ER. | 0x929ed75c
     1176437 | IDAT  |    8192 | .F('.T)\....D"]..."2 '(...D%.. | 0x52c572c0
     1184641 | IDAT  |    8192 | y-.....>....3..p.....$....E.Bj | 0x65a90ffb
     1192845 | IDAT  |    8192 | ....S....?..G.....G........... | 0xf44da161
     1201049 | IDAT  |    7173 | .evl...3K..j.S.....x......Z .D | 0xbe6d3574
     1208234 | IEND  |       0 |                                | 0xae426082

    Curiously, my program tvisitor.cpp which is documented in my book Image Metadata & Exiv2 Architecture does find the EXIF metadata. I'm a little amazed because it don't remember knowing about the chunk eXIf

    1215 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ tvisitor -pR ~/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png 
    STRUCTURE OF PNG FILE (MM): /Users/rmills/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png
      address | chunk |  length |   checksum | data 
            8 |  IHDR |      13 | 0x4ce4e85c | ___.___d..___
           33 |  sRGB |       1 | 0xaece1ce9 | _
           46 |  gAMA |       4 |  0xbfc6105 | __..
           62 |  pHYs |       9 | 0xc76fa864 | __..__...
           83 |  IDAT |     257 | 0x64465429 | x^..1..0_.....t.....h......z..a....&z..a
          352 |  eXIf |     108 | 0x764e86e1 | MM_*___._..._.___.___J.._.___.___\.._.__
      STRUCTURE OF TIFF FILE (MM): /Users/rmills/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png:360->108
       address |    tag                              |      type |    count |    offset | value
            10 | 0x010e Exif.Image.ImageDescription  |     ASCII |       17 |        74 | Can you read me?
            22 | 0x011a Exif.Image.XResolution       |  RATIONAL |        1 |        92 | 72/1
            34 |
    
    
    
    
        
     0x011b Exif.Image.YResolution       |  RATIONAL |        1 |       100 | 72/1
            46 | 0x0128 Exif.Image.ResolutionUnit    |     SHORT |        1 |           | 0
            58 | 0x0213 Exif.Image.YCbCrPositioning  |     SHORT |        1 |           | 0
      END: /Users/rmills/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png:360->108
          472 |  IEND |       0 | 0xae426082 | 
    END: /Users/rmills/Downloads/94996823-1d0cfd80-05a7-11eb-8a1b-b9a69b9062d7.png
    1216 rmills@rmillsmbp:~/gnu/github/exiv2/0.27-maintenance $ 

    My book is a "work in progress" and I hope to finish it by the end of 2020. Draft: https://clanmills.com/exiv2/book/

    Two interesting discoveries here:

  • Exiv2 does not support chunk "eXIf".
  • Bug. Amazing find. I'll fix that next week. May I use your images in the test suite? I didn't write the PNG support in Exiv2, I believe it was added about 10 years ago. It's astonishing that this hasn't been reported.

  • tvisitor.cpp does supports PNG chunk "eXIf", however it doesn't support chunk zTXt with signature Raw profile type exif.
  • The reason is because tvisitor.cpp does not link zlib and therefore cannot read the compressed zTXt chunk. I don't intend to change that. tvisitor.cpp is a 3000 line program with no external library dependencies. The purpose of tvisitor.cpp is to explain how exiv2 works without discussing 100,000 lines of code.

    tvisitor.cpp supports all the image formats supported by Exiv2 + BigTiff, ISOBMFF (CR3, HEIF, AVIF).

    Yes, feel free to add the images to the test suite (I updated the comment.png because of a typo). Did you also look for the 'comment'? exiftool seems to embed it as a tEXt chunk:

     address | chunk |  length | data                           | checksum
           8 | IHDR  |      13 | .......d....                   | 0x4ce4e85c
          33 | sRGB  |       1 |                                | 0xaece1ce9
          46 | gAMA  |       4 | ....                           | 0x0bfc6105
          62 | pHYs  |       9 | .........                      | 0xc76fa864
          83 | IDAT  |     257 | x^..1..0......t.....h......z.. | 0x64465429
         352 | tEXt  |      24 | Comment.Can you read me?       | 0x83cad5fa
         388 | IEND  |       0 |                                | 0xae426082
    

    Looking at your test/data/ReaganLargePng.png, do you currently expect the comment in a zTXt chunk only?

    Thanks for agreeing to have your images in the test suite. Very helpful, thank you.

    I'll have to investigate the comment issue. As I said, I didn't write the PNG support. Recently, it came to light that EXIF support in PSD images is not tested and I fixed that on Friday #1342. I hope to investigate more "testing gaps" this week. I'm working hard to finish the book by the end of 2020. Most weeks bring unexpected/unscheduled work and distraction. So, although progress on the book is delayed, Exiv2 is in better place at the end of every week.

    I'm going to make EXIV2_ENABLE_PNG an option in the tvisitor program in the book and and support zTXt. There is a metadata format for PNG files used by ImageMagic (its not Exif, XMP, ICC, IPTC, or Comment). I'd like to document and support that. The book is my retirement gift to the community and I hope to inspire somebody to maintain and develop Exiv2 in future. So, tvisitor.cpp supports matters not handled in Exiv2 to prove that they are possible with modest effort.

    I've got this fixed on 0.27-maintenance on my machine. I'll submit the code (and additional tests) tomorrow and will be very happy to have your review.

    This was quite a find and will have consequences for the book. I'm very pleased to be getting everything written down. When I get to the end of this, the book cover everything I know about both exiv2 and how metadata is stored and navigated.

    The best part of the book is the tvisitor.cpp code. In 3000 lines of C++11, we can navigate all the file formats and metadata standards. It's easy to change and experiment. The png code is exiv2 is ugly and inflexible. There's an ominous comment:

    src/pngimage.cpp:            /// \todo analyse remaining chunks of the standard
    

    For sure, this find is embodied in that comment. I suspect there are more discoveries to be made about PNG.

    The situation here is mixed. The current PNG Specification (2003)is here: https://www.w3.org/TR/2003/REC-PNG-20031110/

    I believe we should split this into two issues (exif and comment)

  • Exif metadata can either:
    a) Stored compressed in a zTXt chunk with the signature Raw profile type exif\0\0 (This is supported in Exiv2)
    b) Stored in a eXIfchunk as a decompressed Tiff file (This is not supported in Exiv2)
  • I believe this is a fixable fixable bug.

  • The Exiv2 --comment/-pc is intended to set a comment in a JPEG file.
    The Exiv2 implementation maps that as PNG "Textual information" as a zTXt chunk with keyword Description
  • Here's what the standard says:

    11.3.4 Textual information

    11.3.4.1 Introduction

    PNG provides the tEXt, iTXt, and zTXt chunks for storing text strings associated with the image, such as an image description or copyright notice. Keywords are used to indicate what each text string represents. Any number of such text chunks may appear, and more than one with the same keyword is permitted.

    11.3.4.2 Keywords and text strings

    The following keywords are predefined and should be used where appropriate.

    Title Short (one line) title or caption for image

    Other keywords may be defined for other purposes. Keywords of general interest can be registered with the PNG Registration Authority. It is also permitted to use private unregistered keywords.

    I have added code to respect the chunk tEXt with keyword Comment. This caused considerable "ripple" of issues in our test suite.

    I think it's OK to retain the existing implementation of mapping --comment/-pc to zTXt/Description as this has been in the implementation for about 10 years without causing concern.

    I'd like you to open a new issue and request support in Exiv2 for PNG Textual Information.

    As I am overloaded at present, I'm unassigning myself from this issue and it's unlikely to get attention on the 0.27-maintenance branch.

    @piponazo Thanks. I seem to have lost a note I wrote yesterday about this.

    I suspect adding support for PNG Textual information is a major undertaking. I have discussed it (briefly) in my book. I think you will have to introduce a new "Family" of metadata with keys such as PNG.zTXt.Author. Before adding a new "Family", we should investigate the unified metadata container on the svn unstable branch. Once that has been ported to 'master', adding a new "Family" is probably straightforward.

    Additionally, I believe PNG permits multiple chunks with the same name - so there can be 2 or more chunks named PNG.zTXt.Author. Arnold (@tester0077) said there was a deficiency in our PNG metadata support and asked for "disclaimer". I replied that we support Exiv2, IPTC, XMP and ICC metadata on about 20 formats. So, PNG Textual information is not supported.

    So, let's not commit to this for v0.28. For sure, it'll never be added to 0.27-maintenance. I have documented PNG Textual Information in the book and tvisitor.cpp will reveal it to the user.

    Hello, I think I hit the same problem. I have a PNG that had no EXIF data, added some by running
    % exiftool -alldates="1959:04:17 15:21:02" 10.png
    Verified them with exiftool:

    % exiftool 10.png
    ExifTool Version Number         : 11.70
    File Name                       : 10.png
    [...several lines omitted...]
    Modify Date                     : 1959:04:17 15:21:02
    Y Cb Cr Positioning             : Centered
    Exif Version                    : 0232
    Date/Time Original              : 1959:04:17 15:21:02
    Create Date                     : 1959:04:17 15:21:02
    

    ...and then this:

    % exiv2 10.png
    File name       : 10.png
    File size       : 17213 Bytes
    MIME type       : image/png
    Image size      : 120 x 81
    10.png: No Exif data found in the file
    Exit 253
    % exiv2 -pe 10.png
    % exiv2 -pS 10.png
    STRUCTURE OF PNG FILE: 10.png
     address | chunk |  length | data                           | checksum
           8 | IHDR  |      13 | ...x...Q....                   | 0x96a5f57b
          33 | tEXt  |      31 | create-date.1959-04-17T15:21:0 | 0x06bc1396
          76 | tIME  |       7 | .......                        | 0x070fddc9
          95 | IDAT  |    8192 | x.d.I.%]r...g.....z5.C.S..#).. | 0xe830cf4f
        8299 | IDAT  |    8192 | REQ.Q.BD,.ct....B..p...39.%*.3 | 0x880848c3
       16503 | IDAT  |     434 | n..&.#...8.."..{....C.&.#.W... | 0x54301f6c
       16949 | eXIf  |     240 | MM.*.................V........ | 0x8fdeeac2
       17201 | IEND  |       0 |                                | 0xae426082
    

    I actually noticed the problem after importing the file into DigiKam 7.0, and reported it on their mail list.
    Do you think you can publish an update that the DigiKam project could use?

    Thank you for all your work!
    Rainer

    PS. Here is my PNG file 10.png. I own the copyright and you have my permission to use it for any purpose within the Exiv2 project.

    Exiv2 supports Exif, IPTC, XMP and ICC metadata. You haven't hit a problem. Your file contains PNG metadata which is not in one of those four formats.

    As you've realised, you can see the metadata embedded in the tEXt chunk. In preparation for retirement (I was 70 in January), I have written a book Image Metadata and Exiv2 Architecture https://clanmills.com/exiv2/book.

    In Chapter 1 Image Formats, I discuss each of the about 20 image formats: JPEG, TIFF, PNG and others. The PNG specification provides a feature 11.3.4 Textual information. This is discussed in the book: https://clanmills.com/exiv2/book/#PNG.

    There is a program tvisitor provided in the book. It's a more comprehensive version of exiv2 -pS. Here's tvisitor at work on your file:

    1100 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance $ tvisitor  -pR ~/Desktop/111037227-7d8c4a80-8423-11eb-8565-ec1e98008727.png 
    STRUCTURE OF PNG FILE (MM): /Users/rmills/Desktop/111037227-7d8c4a80-8423-11eb-8565-ec1e98008727.png
      address | chunk |  length |   checksum | data 
            8 |  IHDR |      13 | 0x96a5f57b | ___x___Q..___
           33 |  tEXt |      31 |  0x6bc1396 | create-date_1959-04-17T15:21:02
           76 |  tIME |       7 |  0x70fddc9 | .......
           95 |  IDAT |    8192 | 0xe830cf4f | x.d.I.%]r...g.....z5.C.S..#)..(...I..&`.
         8299 |  IDAT |    8192 | 0x880848c3 | REQ.Q.BD,.ct....B..p...39.%*.3..Y-Y..R.u
        16503 |  IDAT |     434 | 0x54301f6c | n..&.#...8.."..{....C.&.#.W...g..4...Td.
        16949 |  eXIf |     240 | 0x8fdeeac2 | MM_*___._..._.___.___V.._.___.___^.(_.__
      STRUCTURE OF TIFF FILE (MM): /Users/rmills/Desktop/111037227-7d8c4a80-8423-11eb-8565-ec1e98008727.png:16957->240
       address |    tag                                  |      type |    count |    offset | value
            10 | 0x011a Exif.Image.XResolution           |  RATIONAL |        1 |        86 | 72/1
            22 | 0x011b Exif.Image.YResolution           |  RATIONAL |        1 |        94 | 72/1
            34 | 0x0128 Exif.Image.ResolutionUnit        |     SHORT |        1 |           | 2
            46 | 0x0132 Exif.Image.DateTime              |     ASCII |       20 |       102 | 1959:04:17 15:21:02
            58 | 0x0213 Exif.Image.YCbCrPositioning      |     SHORT |        1 |           | 1
            70 | 0x8769 Exif.Image.ExifTag               |      LONG |        1 |           | 122
        STRUCTURE OF TIFF FILE (MM): /Users/rmills/Desktop/111037227-7d8c4a80-8423-11eb-8565-ec1e98008727.png:16957->240
         address |    tag                                  |      type |    count |    offset | value
             124 | 0x9000 Exif.Photo.ExifVersion           | UNDEFINED |        4 |           | 0232
             136 | 0x9003 Exif.Photo.DateTimeOriginal      |     ASCII |       20 |       200 | 1959:04:17 15:21:02
             148 | 0x9004 Exif.Photo.DateTimeDigitized     |     ASCII |       20 |       220 | 1959:04:17 15:21:02
             160 | 0x9101 Exif.Photo.ComponentsConfigura.. | UNDEFINED |        4 |           | ..._
             172 | 0xa000 Exif.Photo.FlashpixVersion       | UNDEFINED |        4 |           | 0100
             184 | 0xa001 Exif.Photo.ColorSpace            |     SHORT |        1 |           | 65535
        END: /Users/rmills/Desktop/111037227-7d8c4a80-8423-11eb-8565-ec1e98008727.png:16957->240
      END: /Users/rmills/Desktop/111037227-7d8c4a80-8423-11eb-8565-ec1e98008727.png:16957->240
        17201 |  IEND |       0 | 0xae426082 | 
    END: /Users/rmills/Desktop/111037227-7d8c4a80-8423-11eb-8565-ec1e98008727.png
    1101 rmills@rmillsm1:~/gnu/github/exiv2/0.27-maintenance $

    The Exiv2 project is alive and well, however there is nobody actively developing PNG support in Exiv2. I intended to retire in January, and have been persuaded by darktable to add bmff support for CR3, HEIC and AVIF files. Exiv2 v0.27.4 RC1 will be released this week. v0.27.4 is on track to ship as scheduled on 2021-05-22. #1018 (comment)

    We had a Team Exiv2 meeting on 2021-02-27 to discuss the future. We agreed to investigate moving Exiv2 into the KDE organisation. I've agreed to "yet one more final release" of v0.28 on 2021-09-15. #1466 (comment)

    I assume DigiKam will update their product to take advantage of Exiv2 v0.27.4. In the past, I have made a considerable effort to provide support and meet special demands from that project. As no words of appreciation were offered for hundreds of hours of effort, I will never again undertake development at their request.

    I hope somebody will volunteer to manage Exiv2 in future. A future maintainer will determine priorities. Will PNG Textual information be supported? You are welcome to join the team and develop the necessary code.

    Hello Robin,
    to be honest, I had not understood that the date information in my PNG file isn't Exif data. Thanks for pointing that out.
    I've realised that there is probably an easy workaround for my problem: If I use exiv2 instead of exiftool to store the date information in my PNGs, I expect that DigiKam will recognize it.
    I'm not yet a long time DigiKam user, and have only got to know exiv2 less than 24 hours ago, but I am already impressed with what the project provides and how it got there. Today, I've learned how to build exiv2, and have begun to study your book, which is certainly a useful resource.
    Thank you for responding.
    Good luck, Rainer

    Thanks for the feed-back. The book is very detailed because its purpose is to conserve my knowledge. The aim of the book is to ensure that Exiv2 survives or inspires a new library. It comes with a guaranteed cure for insomnia.

    Please understand that when darktable asked please add bmff before you retire, they were asking for 500+ hours of my life. Unlike digiKam, I believe they will show appreciation.

    The project to move Exiv2 under the KDE umbrella will probably involve similar demands on my time. I wanted out of here in January. Perhaps I will escape in September.

    An important precursor for PNG (and other Families not in Exif/IPTC/XMP) is the Unified Metadata Container. This has now been studied #1505 and I regard this a must have feature for v1.00.

    Although I'll set the milestone of v1.00 for this issue, whether we implement PNG Textual information support in v1.00 will depend on have a contributor to accept the challenge. I hope that when the Unified Metadata Container is implemented in Exiv2, PNG support is provide to prove that the code to add a new family does work correctly.

    Textual information, such as author information, creator software,
    and a description can be stored in a PNG's tEXt, zTXt, and
    iTXt chunks, [1].
    libexiv2 can extract EXIF information out of PNGs but does not
    support PNG Textual Information, see [2], however Qt's PNG handler
    makes this information readily available as textKeys.
    [1] https://www.w3.org/TR/PNG/#11keywords
    [2] Exiv2/exiv2#1343
    Textual information, such as author information, creator software,
    and a description can be stored in a PNG's tEXt, zTXt, and
    iTXt chunks, [1].
    libexiv2 can extract EXIF information out of PNGs but does not
    support PNG Textual Information, see [2], however Qt's PNG handler
    makes this information readily available as textKeys.
    Unfortunately, the "Description" key is used by QImage to keep
    track of the QImageIOHandler's Description and overrides the actual
    PNG "Description" text, making it useless.
    [1] https://www.w3.org/TR/PNG/#11keywords
    [2] Exiv2/exiv2#1343
    Textual information, such as author information, creator software,
    and a description can be stored in a PNG's tEXt, zTXt, and
    iTXt chunks, [1].
    libexiv2 can extract EXIF information out of PNGs but does not
    support PNG Textual Information, see [2], however Qt's PNG handler
    makes this information readily available as textKeys.
    Unfortunately, the "Description" key is used by QImage to keep
    track of the QImageIOHandler's Description and overrides the actual
    PNG "Description" text, making it useless.
    [1] https://www.w3.org/TR/PNG/#11keywords
    [2] Exiv2/exiv2#1343