SourceForge

PNG and MNG tools
EXIF and PNG

PNG Web Site

Converting TIFF-EP or EXIF files to PNG format (Draft 0.05, July 31, 2000)

Notices:

Copyright 2000, Glenn Randers-Pehrson, randeg@alum.rpi.edu, all rights reserved. The original document is available at http://pmt.sourceforge.net/exif/d005.html

You may link to this file or (preferably) to the directory in which it resides, but please do not publish this file on your web site without my permission. You may quote portions of this document, and the preceding editions, on web sites and in messages, provided that you include the copyright notice and a link to the original document. If and when this document emerges from draft status, it will be released on more generous terms, identical to those of the PNG extensions document [PNGEXT].

Status of this document

This is a draft of a proposal to the PNG Development Group for registration of a new text keyword (EXIF) and a new special-purpose chunk (eXIF). It has not been approved by any approving body.

This document and the latest version of this document can be found at <http://pmt.sourceforge.net/exif>. If at some date the files move to another site, I intend to leave a link to the new location here, if possible.

Scope:

This document proposes a new PNG [PNG] registered keyword, "EXIF", and a new PNG special-purpose chunk, "eXIF". It shows how to use these to preserve the EXIF information [EXIFFORMAT] that is present in a TIFF-EP [TIFF-EP] file, when converting the file to PNG or JNG [JNG] format (JNG is a sub-format of the MNG (Multiple-image Network Graphics) [MNG] format.

Introduction

It is desireable to save the EXIF information present in some camera images because

Some of the information, which describes the particulars of the encoding of the original image, are of no use once the image has been converted to another format, so these need not be preserved.

Applications that convert an image back to the original format need to know whether the image data has been changed, and must be able to rely on the saved EXIF data being in a machine-parseable format and to rely on the data being valid.

The PNG format does not presently formally accommodate EXIF data. It could be stored in PNG text chunks, but a formal specification for storing EXIF data is required, to ensure that the data will remain valid and be machine-parseable. This proposal includes a provision that text chunks containing EXIF data provide a warning that the chunk is not to be edited manually.

A flag is required by which applications can determine whether the image data might have been edited in a manner that invalidates the stored EXIF data. The PNG specification provides copying rules that would allow a new "eXIF" chunk, which would not be recognized by current applications, to serve this purpose. Applications that modify the image data and do not recognize the eXIF chunk are required by the PNG specification to discard it, and applications that edit a PNG file without changing the image data are required to retain it; therefore, the presence or absence of the eXIF chunk serves as the needed flag.

Terminology

textEXIF chunk
A PNG iTXt, tEXt, or zTXt chunk that contains EXIF information, and whose keyword is "EXIF".

Mapping of TIFF-EP data to PNG chunks:

Tags that provide details about the TIFF compression itself are no longer useful and are dropped. Other tags can be converted to existing PNG chunks, or to a tEXt/zTXt/iTXt chunk using the "EXIF" keyword (i.e., a "textEXIF" chunk), as shown in this table.

TIFF-EP TagEXIF Item NamePNG encoding
*0x0FE NewSubfileType drop
*0x0FF SubfileType drop
0x100 ImageWidth [1] IHDR width, textEXIF width
0x101 ImageLength IHDR height, textEXIF height
0x102 BitsPerSample [2] sBIT
0x103 Compression [3] textEXIF Compression
0x106 PhotometricInterpretation textEXIF PhotometricInterpretation
0x10A FillOrder [4] drop?
0x10D DocumentName text Title
0x10E ImageDescription text Description
0x10F Make textEXIF Make
0x110 Model textEXIF Model
0x111 StripOffsets drop
0x112 Orientation [5] textEXIF Orientation
0x115 SamplesPerPixel drop
0x116 RowsPerStrip drop
0x117 StripByteCounts drop
0x11A XResolution pHYs X/unit
0x11B YResolution pHYs Y/unit
0x11C PlanarConfiguration textEXIF PlanarConfiguration
0x128 ResolutionUnit pHYs unit
0x12D TransferFunction [6] textEXIF TransferFunction
0x131 Software textEXIF Software
0x132 DateTime [7] tIME/text Creation time
0x13B Artist text Author
*0x13D Predictor drop
0x13E WhitePoint cHRM
0x13F PrimaryChromaticities cHRM
0x156 TransferRange textEXIF TransferRange
*0x15B JPEGTables [8] drop
0x200 JPEGProc drop
0x201 JPEGInterchangeFormat drop?
0x202 JPEGInterchangeFormatLength drop?
0x211 YCbCrCoefficients [9] drop
0x212 YCbCrSubSampling drop
0x213 YCbCrPositioning drop
0x214 ReferenceBlackWhite textEXIF referenceBlackWhite ?
0x828D CFARepeatPatternDim ?
0x828E CFAPattern ?
0x828F BatteryLevel textEXIF BatteryLevel
0x8298 Copyright text Copyright
0x829A ExposureTime textEXIF ExposureTime
0x829D FNumber textEXIF FNumber
0x83BB IPTC/NAA textEXIF IPTC/NAA ?
0x8769 ExifOffset drop
0x8773 InterColorProfile [10] iCCP
0x8822 ExposureProgram textEXIF ExposureProgram
0x8824 SpectralSensitivity textEXIF SpectralSensitivity
0x8825 GPSInfo write individual GPS tags as textEXIF:
 GPSVersionID GPSVersionID
 GPSLatitudeRef GPSLatitudeRef
 GPSLatitude GPSLatitude
 GPSLongitudeRef GPSLongitudeRef
 GPSLongitude GPSLongitude
 GPSAltitudeRef GPSAltitudeRef
 GPSAltitude GPSAltitude
 GPSTimeStamp GPSTimeStamp
 GPSSatellites GPSSatellites
 GPSStatus GPSStatus
 GPSMeasureMode GPSMeasureMode
 GPSSDOP GPSDOP
 GPSSpeedRef GPSSpeedRef
 GPSSpeed GPSSpeed
 GPSTrackRef GPSTrackRef
 GPSTrack GPSTrack
 GPSImgDirectionRef GPSImgDirectionRef
 GPSImgDirection GPSImgDirection
 GPSMapDatum GPSMapDatum
 GPSDestLatitudeRef GPSDestLatitudeRef
 GPSDestLatitude GPSDestLatitude
 GPSDestLongitudeRef GPSDestLongitudeRef
 GPSDestLongitude GPSDestLongitude
 GPSDestBearingRef GPSDestBearingRef
 GPSDestBearing GPSDestBearing
 GPSDestDistanceRef GPSDestDistanceRef
 GPSDestDistance GPSDestDistance
0x8827 ISOSpeedRatings textEXIF ISOSpeedRatings
0x8828 OECF textEXIF OECF
*0x8829 Interlace drop
0x882A TimeZoneOffset textEXIF TimeZoneOffset
0x882B SelfTimerMode textEXIF SelfTimerMode
0x9000 ExifVersion textEXIF ExifVersion
0x9003 DateTimeOriginal [11] textEXIF DateTimeOriginal
0x9004 DateTimeDigitized [12] textEXIF DateTimeDigitized
0x9101 ComponentsConfiguration textEXIF ComponentsConfigurations
0x9102 CompressedBitsPerPixel textEXIF CompressedBitsPerPixel
0x9201 ShutterSpeedValue textEXIF ShutterSpeedValue
0x9202 ApertureValue textEXIF ApertureValue
0x9203 BrightnessValue textEXIF BrightnessValue
0x9204 ExposureBiasValue textEXIF ExposureBiasValue
0x9205 MaxApertureValue textEXIF MaxApertureValue
0x9206 SubjectDistance textEXIF SubjectDistance
0x9207 MeteringMode textEXIF MeteringMode
0x9208 LightSource textEXIF Lightsource
0x9209 Flash textEXIF Flash
0x920A FocalLength textEXIF FocalLength
0x920B FlashEnergy textEXIF FlashEnergy
0x920C SpatialFrequencyResponse textEXIF SpatialFrequencyResponse
0x920D Noise textEXIF Noise
*0x020E FocalPlaneXResolution textEXIF FocalPlaneXResolution
*0x920F FocalPlaneYResolution textEXIF FocalPlaneYResolution
*0x9210 FocalPlaneResolutionUnit textEXIF FocalPlaneResolutionUnit
0x9211 ImageNumber textEXIF ImageNumber
0x9212 SecurityClassification tEXt Warning Classified
 FileSecurityClassification textEXIF FileSecurityClassification
 FileCodewords textEXIF FileCodewords
 FileControlAndHandling textEXIF FilecontrolAndHandling
 FileReleasingInstructions textEXIF FileReleasingInstructions
 FileClassificationAuthority textEXIF FileClassificationAuthority
 FileSecurityControlNumber textEXIF FileSecurityControlNumber
 FileSecurityDowngrade textEXIF FileSecurityDowngrade
 FileSecurityDowngradingEvent textEXIF FileSecurityDowngradingEvent
0x9213 ImageHistory textEXIF ImageHistory
0x9214 SubjectLocation textEXIF SubjectLocation
0x9215 ExposureIndex textEXIF ExposureIndex
0x9216 TIFF/EPStandardID textEXIF TIFF/EPStandardID
0x9217 SensingMethod textEXIF SensingMethod
0x927C MakerNote [14]textEXIF MakerNote
0x9286 UserComment text Comment/textEXIF UserComment
0x9290 SubSecTime textEXIF SubSecTime
0x9291 SubSecTimeOriginal textEXIF SubSecTimeOriginal
0x9292 SubSecTimeDigitized textEXIF SubSecTimeDigitized
0xA000 FlashPixVersion textEXIF FlashPixVersion
0xA001 ColorSpace textEXIF ColorSpace
0xA002 ExifImageWidth textEXIF ExifImageWidth
0xA003 ExifImageLength textEXIF ExifImageLength
0xA005 InteroperabilityOffset drop
*0xA20B FlashEnergy [15] textEXIF FlashEnergy
*0xA20C SpatialFrequencyResponse textEXIF SpatialFrequencyResponse
*0xA20E FocalPlaneXResolution textEXIF FocalPlaneXResolution
*0xA20F FocalPlaneYResolution textEXIF FocalPlaneYResolution
*0xA210 FocalPlaneResolutionUnit textEXIF FocalPlaneResolutionUnit
*0xA214 SubjectLocation textEXIF SubjectLocation
*0xA215 ExposureIndex textEXIF ExposureIndex
*0xA217 SensingMethod textEXIF SensingMethod
0xA300 FileSource textEXIF FileSource
0xA301 SceneType textEXIF SceneType
TIFF TagEXIF Item NamePNG encoding
[*] Not in TIFF-EP
[1] If the file is later cropped, don't change the textEXIF width and height; they record the original width and height.
[2] The sBIT chunk is unnecessary and should not be written if the original file and the PNG file to which it is being converted have the same sample depth.
[3] This identifies the compression method used in the original file.
[4] Details about the original compression are of no further use and should be dropped. If an application converts the PNG file back to a TIFF-EP or ELIF file, it must supply these details with respect to the new file that it is creating.
[5] This identifies the orientation of the original file. Converters should orient the pixels in the PNG or JNG file with the first pixel representing the top left corner of the image, using a lossless method of rotation. An application that converts a PNG or JNG back to TIFF-EP format must restore the image to an orientation that has the same width and height as the original, using a lossless method of rotation. If the eXIF chunk is present, its "current_orientation" field can be consulted to distinguish between right-side-up and upside-down images, and the application can either reorient the image or revise the value in the "Orientation" tag that it writes.
[6] Is this related to gamma? If so, a gAMA chunk should be written. It is recorded in EV units, so it isn't directly gamma.
[7] This is the time the image was originally recorded by the camera. But see also [12]; how do these tags differ?
[8], [9] This information is recorded in the JPEG datastream.
[10] If the ICC profile is the sRGB profile, then write an sRGB chunk instead of an iCCP chunk (note that DCF images are always in sRGB).
[11] A tIME chunk can also be written, containing the time that the image was first converted to the PNG or JNG format. If the image is later modified, the tIME chunk will be overwritten with the modification time.
[12] A text "Creation time" chunk can also be written with this time.
[13], [15] Some of the TIFF tags 0x920B through 0x9217 are duplicates of 0xA20B through 0xA217. The former appear in the ISO Standard for TIFF-EP [TIFF-EP], but the latter have been written by some applications.
[14] Since the contents of MakerNote are not known for all vendors, and since it can contain null-terminated strings, it is stored as a string of hex numbers preceded by a byte-count. It ends with a newline and can have embedded newlines which are to be ignored by decoders.
The tag list was obtained from the exifdump source code [EXIFDUMP], and compared with the tag list in the TIFF-EP Standard [TIFF-EP]. See also the "Description of the Exif file format" [EXIFFORMAT], which was generated by inspection of EXIF files, without reference to the actual EXIF specification [EXIFSPEC].

Usage of the proposed EXIF text keyword

All of the EXIF information should be written in a single textEXIF chunk (multiple chunks can be used, provided that no particular tag appears in more than one of them), with a newline terminating the data for each item. In TIFF-EP tags whose data is a string ending with a null, the terminating null is replaced with a newline character, and embedded newlines are permitted. Converters must verify that the character-count field in tags that contain strings is correct, because the terminating null is not available for use by decoders. Any CRLF sequences in such strings are replaced with the newline character, and the character-count is adjusted accordingly. If any character outside the Latin-1 character set is present (which would violate the TIFF-EP Standard but might happen anyway), the strings must be converted to UTF-8 format and the iTXt chunk must be used. The data field of the text chunk must begin with the EXIF keyword plus this caution not to edit the data manually:

EXIF\0Caution: Do not manually edit the data in this chunk.\n

The eXIF chunk

The proposed eXIF chunk contains the editing status of the PNG file. Its data field contains two bytes:
     1 byte:  editing_status
              0: image has not been edited
              1: image has been edited by an
                EXIF-cognizant application
     1 byte:  current_orientation (1, 3, 6, 8, or 9)
     2 bytes: (unsigned integer in network byte order)
              number of textEXIF chunks in the PNG datastream.
     4 bytes: CRC of a textEXIF chunk
     4 bytes: CRC of another textEXIF chunk
     etc.,    until the CRCs of all textEXIF chunks have been
              listed, in no particular order.
             

Applications that are cognizant of EXIF and have edited the image data in a manner that does not invalidate the EXIF data must either change the "editing_status" field to 1 or discard the chunk. If they make changes that invalidate the EXIF data, they must discard the eXIF chunk.

If an application reorients an image, it must update the "current_orientation" field. If it edits the EXIF "Orientation" tag, it must also update the eXIF chunk's "current_orientation" field, to maintain the proper relationship between the two values.

PNG-compliant applications that are not cognizant of EXIF are required by the PNG specification to discard the eXIF chunk if they edit the PNG file in any manner that changes any critical chunk.

Applications that wish to determine the validity of the EXIF data contained in the text/EXIF chunks should check for the presence of an eXIF chunk. If none is present, it can be concluded that the file has been edited by an application that is not cognizant of EXIF. If it is present, then it can be concluded that the EXIF data is still valid. The "editing_status" field of the eXIF chunk can then be used to tell whether the image data was modified or not.

Do not write the eXIF chunk in any PNG files until it is registered, Until then, its specification is subject to change. For testing and evaluation purposes, write an "exIF" chunk (lower-case "x") instead, bearing in mind that the specification for the chunk might change..

Software

Software applications for converting to and from the PNG format are beyond the scope of this document. It is clearly evident that Thierry Bousch's exifdump [EXIFDUMP] software could be easily modified to do the job.

If you wish to write software to evaluate this proposal, you must not write eXIF chunks until this chunk type is registered by the PNG group. Instead, use a lower-case "x" to write an exIF chunk which has the same syntax as the proposed eXIF chunk but is a private unregistered chunk. Your software may read the eXIF chunk in anticipation of its approval, however, bearing in mind that the specification for the chunk might change.

Rationale

This section provides some of the reasoning behind the decisions made in forming this proposal.

Why not simply embed the entire TIFF-EP data structure in binary form in a new eXIF or eXIf chunk?

Issues to be resolved:

Revision history:

References:

[EXIFDUMP] Bousch, Thierry, exifdump.py, v 1.13 (Python source code for exifdump), 1999/08/21, available at
http://topo.math.u-psud.fr/~bousch/exifdump.py

[EXIFFORMAT] Tachibanaya, TsuruZoh, "Description of Exif File Format", Revision 1.2, July 19, 2000, available at
http://www.butaman.ne.jp/~tsuruzoh/Computer/Digicams/exif.html (Japanese) http://www.butaman.ne.jp/~tsuruzoh/Computer/Digicams/exif-e.html (English)

[EXIFSPEC] I have not seen the formal specification of the EXIF format. It is not available on-line.

[JNG] Randers-Pehrson, Glenn, et. al., "JNG (JPEG Network Graphics) Specification, version 0.97, February, 2000, available at
ftp://swrinde.nde.swri.edu/pub/mng/documents.

[MNG] Randers-Pehrson, Glenn, et. al., "MNG (Multiple-image Network Graphics) Format, version 0.97", February, 2000, available at
ftp://swrinde.nde.swri.edu/pub/mng/documents.

[MNG-VLC] Randers-Pehrson, Glenn, et. al., "MNG-VLC (Multiple-image Network Graphics--Very Low Complexity) Format, version 0.97", February, 2000, available at
ftp://swrinde.nde.swri.edu/pub/mng/documents.

[PNG] Randers-Pehrson, Glenn, et. al., "PNG (Portable Network Graphics) Specification, version 1.2", July, 1999, available at
ftp://swrinde.nde.swri.edu/pub/png/documents.

[PNGEXT] Randers-Pehrson, Glenn, et. al., "Extensions to the PNG 1.2 Specification, version 1.2.0", July, 1999, available at
ftp://swrinde.nde.swri.edu/pub/png/documents.

[TIFF-EP] ISO/DIS 12234-2, "Photography---Electronic still picture imaging--- Removable memory---Part 2: Image data format---TIFF-EP", November 24, 1998, available at
http://www.pima.net/standards/iso/standards/documents/N4378.pdf


[HOME] | [UP]