-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
Comment and EXIF data cannot be read from PNG files #1343
Comments
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. |
Same results with latest build...
|
This is very interesting. Firstly, to see the exif metadata, you should use the option -pe. The default (when you don't use any 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 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:
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.
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'?
Looking at your |
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. |
Nice catch here guys. @clanmills Let me know if I can help you by taking care of this issue on |
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:
For sure, this find is embodied in that comment. I suspect there are more discoveries to be made about PNG. |
Ohhh I remember that I wrote that comment at some point when reading about the PNG metadata and adding unit tests for them ... surely we still have work to do there |
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)
I believe this is a fixable fixable bug.
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.
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 I think it's OK to retain the existing implementation of mapping 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. |
Hi @clanmills , I will assign this issue to myself and work on it when I have spare time. I cannot promise to have it ready for the next milestone but I'll do my best. |
@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. |
It has been a while since I worked with PNGs, iTXt & zTXt etc.
My understanding of multiple chunks of any one type is that they are
used to limit the size of each chunk, rather than to allow multiple keys
with the same name, though I have not investigated this further.
Another difference, of interest to myself, is the idea that the earlier
text chunks tEXt & zTXt were specifically limited to use Latini1
(ISO8859-1), while iTXt allows other char sets.
Arnold
|
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, |
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
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:
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):
The text was updated successfully, but these errors were encountered: