ChatGPT解决这个技术问题 Extra ChatGPT

Does PNG contain EXIF data like JPG?

I was wondering if PNG contains data like the following?

What I did was to convert the jpg file to png format, and I was expecting to retrieve the same info I had on the jpg as below:

Currently using this as3 library to read the data.

IDF0--- IDF @[134 - 248] (9 entries) Orientation (SHORT) : 1 XResolution (RATIONAL) : 72/1 YResolution (RATIONAL) : 72/1 ResolutionUnit (SHORT) : 2 Software (ASCIIx16) : QuickTime 7.6.6 DateTime (ASCIIx20) : 2011:10:02 22:43:37 HostComputer (ASCIIx16) : Mac OS X 10.6.8 Exif IFD (LONG) : 8 34853 GPS IFD (LONG) : 248

Orientation (SHORT) : 1

XResolution (RATIONAL) : 72/1

YResolution (RATIONAL) : 72/1

ResolutionUnit (SHORT) : 2

Software (ASCIIx16) : QuickTime 7.6.6

DateTime (ASCIIx20) : 2011:10:02 22:43:37

HostComputer (ASCIIx16) : Mac OS X 10.6.8

Exif IFD (LONG) : 8 34853

GPS IFD (LONG) : 248

EXIF IDF--- IDF @[8 - 134](10 entries) ExifVersion (UNDEFINEDx4) : 0220 DateTimeOrigina (ASCIIx20) : 2011:04:14 17:22:01 UserComment (UNDEFINEDx63) : ASCII FlashpixVersion (UNDEFINEDx4) : 0100 ColorSpace (SHORT) : 1 PixelXDimension (LONG) : 1022 PixelYDimension (LONG) : 486 Unknown (ASCIIx13) : Image Tag-LOL SceneCaptureType (SHORT) : 0

ExifVersion (UNDEFINEDx4) : 0220

DateTimeOrigina (ASCIIx20) : 2011:04:14 17:22:01

UserComment (UNDEFINEDx63) : ASCII

FlashpixVersion (UNDEFINEDx4) : 0100

ColorSpace (SHORT) : 1

PixelXDimension (LONG) : 1022

PixelYDimension (LONG) : 486

Unknown (ASCIIx13) : Image Tag-LOL

SceneCaptureType (SHORT) : 0

GPS IDF--- IDF @[248 - 338](7 entries) Interoperability Index (ASCIIx2) : N Interoperability Version (RATIONALx3) @425: 52/1, 1144/100, 0/1 Unknown (ASCIIx2) : W Unknown (RATIONALx3) : 1/1, 4392/100, 0/1 Unknown (RATIONAL) : 5/1 Unknown (ASCIIx2) : T Unknown (RATIONAL) : 3694/117

Interoperability Index (ASCIIx2) : N

Interoperability Version (RATIONALx3) @425: 52/1, 1144/100, 0/1

Unknown (ASCIIx2) : W

Unknown (RATIONALx3) : 1/1, 4392/100, 0/1

Unknown (RATIONAL) : 5/1

Unknown (ASCIIx2) : T

Unknown (RATIONAL) : 3694/117


h
hippietrail

Edit: Version 1.5.0 (July 2017) of the Extensions to the PNG 1.2 Specification has finally added an EXIF chunk. It remains to be seen if encoders-decoders begin to support it.

Original: PNG does not embed EXIF info. It allows, however, to embed metadata "chunks" inside the image. Some of the standardized chunks correspond to a few EXIF attributes (physical dimensions, timestamp). And it's also possible to store arbitrary textual data as key=>value pairs, or to define new chunk types. So, you could in theory store any EXIF information... but, alas, in your own custom format. Some attempts to standarize have not caught up, it seems.


h
hippietrail

Edit: As of July 2017, PNG officially supports an eXIf chunk to store EXIF metadata (specification). ExifTool 10.59 and later write EXIF to this new chunk in PNG images.

Original: ImageMagick stores EXIF information in a PNG "Raw profile type APP1" zTXt chunk when converting from JPEG images. This method of storing EXIF in PNG images is also supported by ExifTool (and I believe Exiv2 too), but it is not part of the PNG or EXIF specification.


That's very good to know! Do you know if it extracts it from TIFF as well?
The PNG group has recently been considering adding a new "eXIf" and/or "zXIf" chunk to store EXIF information. ExifTool 10.43 added support for "exIf" and "zxIf" chunks in support of this.
P
Perception

PNG does not support embedding of EXIF information. When you convert from JPEG to PNG the information is lost.


hey is there any documentation that says that? cause i need a proof to let my supervisor know as i am working on an project that requires me to read the EXIF info for png. If that is the case, i could show him and let him know about it
You can point him towards the specification, which has no implicit or explicit specification for EXIF data embedding, or to the PNG wiki entry.
This is not entirely true. For example, if you use convert (from ImageMagick) to convert a JPEG to a PNG and then use convert to convert the PNG back to a JPEG the new JPEG will still have the EXIF Data in it.
In 2012, this answer might have been true, but is it still accurate?
Wrong, both back then and now. PNG does have metadata - it just doesn't use the EXIF standard for it. So good conversion programs would convert the EXIF metadata to PNG metadata where applicable. (Nowadays PNG has an eXIf chunk, but I'm not sure why it was added. Presumably it's designed for carrying forward the original EXIF when converting from JPEG or TIFF.)
8
8bittree

As of July 2017, there does appear to be officially registered chunk for EXIF data called... eXIf:

The data segment of the eXIf chunk contains an Exif profile in the format specified in "4.7.2 Interoperability Structure of APP1 in Compressed Data" of [CIPA DC-008-2016] except that the JPEG APP1 marker, length, and the "Exif ID code" described in 4.7.2(C), i.e., "Exif", NULL, and padding byte, are not included.

Note that this is both A) only a few months old (as of writing) and B) an optional extension, not part of the basic specification. Therefore, support for the eXIf chunk might be limited in many applications.


A
Asteroids With Wings

Yes and no.

As other answers have already stated, PNG didn't have a formal EXIF chunk until eXIf was added in v1.5.0 (2017), and to my knowledge this chunk still does not enjoy wide support.

But that's because it doesn't need it. Many pieces of software encode EXIF in a PNG by convention in an iTXt (or compressed zTXt) chunk notated "Raw profile type APP1". The newer eXIf chunk was intended to provide a standardised location for this, though in my opinion that ship has sailed now.

In addition, much of the EXIF standard's metadata can be represented by XMP, an alternative and newer metadata transport mechanism that has an EXIF namespace for precisely this purpose. PNG files have included XMP documents (including translated EXIF metadata) in iTXt chunks for years. You will find that many processors convert between the two on the fly.


Do these same processors, whatever they are, convert XMP or EXIF to/from the various standard PNG metadata chunks?
@Stewart The standard PNG metadata chunks are limited and could not represent the breadth of EXIF or XMP data. That's why we've historically encoded EXIF/XMP into the files (in text chunks).
OK, I'll rephrase that: Do these same processors convert those items of XMP or EXIF metadata that are capable of being represented by standard PNG metadata chunks to standard PNG metadata chunks, and vice versa?
@Stewart I don't know. I doubt it. If they do, it'd be very limited. Overall there's really no benefit in doing so; the EXIF and XMP fields may not be standard, but they're completely conventional and widely used. So everybody just uses that. The PNG metadata does include some Keywords/Author stuff but it's mostly image data.
S
Stewart

Did you mean:

Do PNG files contain the metadata items you listed? Short answer: It varies. Does PNG use the EXIF standard for storing such metadata? Short answer: Generally no.

Generally, PNG uses various chunks that are part of the PNG standard for storing metadata. To go through your list:

Orientation - Not applicable to PNG - fixed as row by row starting from the top left.

XResolution, YResolution, ResolutionUnit - pHYs chunk.

Software, HostComputer, other textual metadata - tEXt, iTXt, zTXt chunks.

DateTime - Not clear to me what this is the date/time of. tIME indicates the date/time of last modification to the image data; other dates/times can be stored in text chunks. Creation Time is actually a defined text chunk key, but the format and how time zones are handled aren't stipulated, which is a bad design.

ColorSpace, PixelXDimension, PixelYDimension - not sure how these would be metadata. They are fundamental to the image, and as such are in the IHDR chunk.

Not sure what the others you've listed mean.

But puzzlingly, in recent years an eXIf chunk has been added to the official list of extension chunks (which is essentially an addendum to the PNG spec). Presumably it's targeted at preserving the information in files converted from JPEG/TIFF to PNG and not intended to be used in files that are created as PNGs originally, but that isn't clear.