drewnoakes / metadata-extractor

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Apache License 2.0
2.56k stars 480 forks source link

Read exif chunk from a PNG image #475

Closed Ciruman closed 4 years ago

Ciruman commented 4 years ago

Since 2017, PNG supports eXIf chunk. The content is described here:

3.7. eXIf Exchangeable Image File (Exif) Profile

I tried to read the exif metadata of an image by making use of the following methods without success: ImageMetadataReader.readMetadata or: PngMetadataReader.readMetadata

I had a try with the following steps:

  1. Make use of the method extract from the class PngChunkReader with a PngChunkType eXIf

  2. Give the content found in the previous step to the method processIfd in the class TiffReader

All metadata was extracted from a PNG image without a problem.

Is there any plan to support PNG eXIf chunks?

Is there any interest in the implementation of it?

I analyzed the images with the tools ExifTool and ImageMagick and they were able to read/write the PNG images.

drewnoakes commented 4 years ago

@Ciruman can you provide a sample PNG image that contains Exif data?

Would you like to submit a PR for this?

Ciruman commented 4 years ago

Yes, I will provide a sample image and I will try to create a PR for this. :-)

Ciruman commented 4 years ago

@drewnoakes The sample image can be found here: https://we.tl/t-OFOvimwd91 The image used was: https://github.com/drewnoakes/metadata-extractor/blob/master/Tests/Data/dotnet-256x256-alpha-palette.png And the exif data was added using https://github.com/dlemstra/Magick.NET/ The output using exiftool is:

❯ exiftool sampleWithExifData.png
ExifTool Version Number         : 11.85
File Name                       : sampleWithExifData.png
Directory                       : .
File Size                       : 12 kB
File Modification Date/Time     : 2020:05:21 21:46:15+02:00
File Access Date/Time           : 2020:05:21 21:47:03+02:00
File Inode Change Date/Time     : 2020:05:21 21:46:19+02:00
File Permissions                : rw-rw-rw-
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 256
Image Height                    : 256
Bit Depth                       : 8
Color Type                      : Palette
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Gamma                           : 2.2
White Point X                   : 0.3127
White Point Y                   : 0.329
Red X                           : 0.64
Red Y                           : 0.33
Green X                         : 0.3
Green Y                         : 0.6
Blue X                          : 0.15
Blue Y                          : 0.06
Palette                         : (Binary data 720 bytes, use -b option to extract)
Background Color                : 0
Modify Date                     : 2020:05:20 19:37:26
Exif Byte Order                 : Little-endian (Intel, II)
Copyright                       : Acme
Software                        : Acme-software: 1.0.0.0
Image Description               : This is an image with exif data
Maker Note Unknown Text         : This is an example of markernotes
Warning                         : [minor] Text chunk(s) found after PNG IDAT (may be ignored by some readers)
Datecreate                      : 2020-05-20T19:37:26+00:00
Datemodify                      : 2020-05-20T19:37:26+00:00
Image Size                      : 256x256
Megapixels                      : 0.066

I am preparing the PR but I thought it is a good idea if you can have a look to the image first.

drewnoakes commented 4 years ago

@Ciruman thanks for the image. I've added it to the library so that we have a baseline for changes from your PR.

Ciruman commented 4 years ago

Pull request: https://github.com/drewnoakes/metadata-extractor/pull/481