SourceForge

PNG and MNG tools
EXIF and PNG

PNG Web Site

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

Notices:

Copyright 2000, Glenn Randers-Pehrson, randeg@alum.rpi.edu, all rights reserved.

You may link to this file or (preferably) to the directory in which it resides, but please do not copy this file to your web site. 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.

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, as shown in this table.

TIFF TagEXIF Item NamePNG encoding
0x100 ImageWidth [1] IHDR width, text EXIF width
0x101 ImageLength IHDR height, text EXIF height
0x102 BitsPerSample [2] sBIT
0x103 Compression [3] text EXIF Compression
0x106 PhotometricInterpretation text EXIF PhotometricInterpretation
0x10A FillOrder [4] drop?
0x10D DocumentName text Title
0x10E ImageDescription text Description
0x10F Make text EXIF Make
0x110 Model text EXIF Model
0x111 StripOffsets drop
0x112 Orientation [5] text EXIF Orientation
0x115 SamplesPerPixel drop
0x116 RowsPerStrip drop
0x117 StripByteCounts drop
0x11A XResolution pHYs X/unit
0x11B YResolution pHYs Y/unit
0x11C PlanarConfiguration text EXIF PlanarConfiguration
0x128 ResolutionUnit pHYs unit
0x12D TransferFunction [6] text EXIF TransferFunction
0x131 Software text EXIF Software
0x132 DateTime [7] tIME/text Creation time
0x13B Artist text Author
0x13E WhitePoint cHRM
0x13F PrimaryChromaticities cHRM
0x156 TransferRange text EXIF TransferRange
0x200 JPEGProc [8] drop?
0x201 JPEGInterchangeFormat drop?
0x202 JPEGInterchangeFormatLength drop?
0x211 YCbCrCoefficients [9] drop
0x212 YCbCrSubSampling drop
0x213 YCbCrPositioning drop
0x214 ReferenceBlackWhite text EXIF referenceBlackWhite ?
0x828D CFARepeatPatternDim ?
0x828E CFAPattern ?
0x828F BatteryLevel text EXIF BatteryLevel
0x8298 Copyright text Copyright
0x829A ExposureTime text EXIF ExposureTime
0x829D FNumber text EXIF FNumber
0x83BB IPTC/NAA text EXIF IPTC/NAA ?
0x8769 ExifOffset oFFs ?
0x8773 InterColorProfile [10] iCCP
0x8822 ExposureProgram text EXIF ExposureProgram
0x8824 SpectralSensitivity text EXIF SpectralSensitivity
0x8825 GPSInfo text EXIF GPSInfo
0x8827 ISOSpeedRatings text EXIF ISOSpeedRatings
0x8828 OECF text EXIF OECF
0x9000 ExifVersion text EXIF ExifVersion
0x9003 DateTimeOriginal [11] text EXIF DateTimeOriginal
0x9004 DateTimeDigitized [12] text EXIF DateTimeDigitized
0x9101 ComponentsConfiguration text EXIF ComponentsConfigurations
0x9102 CompressedBitsPerPixel text EXIF CompressedBitsPerPixel
0x9201 ShutterSpeedValue text EXIF ShutterSpeedValue
0x9202 ApertureValue text EXIF ApertureValue
0x9203 BrightnessValue text EXIF BrightnessValue
0x9204 ExposureBiasValue text EXIF ExposureBiasValue
0x9205 MaxApertureValue text EXIF MaxApertureValue
0x9206 SubjectDistance text EXIF SubjectDistance
0x9207 MeteringMode text EXIF MeteringMode
0x9208 LightSource text EXIF Lightsource
0x9209 Flash text EXIF Flash
0x920A FocalLength [13] text EXIF FocalLength
0x920B FlashEnergy text EXIF FlashEnergy
0x920C SpatialFrequencyResponse text EXIF SpatialFrequencyResponse
0x020E FocalPlaneXResolution text EXIF FocalPlaneXResolution
0x920F FocalPlaneYResolution text EXIF FocalPlaneYResolution
0x9210 FocalPlaneResolutionUnit text EXIF FocalPlaneResolutionUnit
0x9214 SubjectLocation text EXIF SubjectLocation
0x9215 ExposureIndex text EXIF ExposureIndex
0x9217 SensingMethod text EXIF SensingMethod
0x927C MakerNote text EXIF MakerNote
0x9286 UserComment text Comment/text EXIF UserComment
0x9290 SubSecTime text EXIF SubSecTime
0x9291 SubSecTimeOriginal text EXIF SubSecTimeOriginal
0x9292 SubSecTimeDigitized text EXIF SubSecTimeDigitized
0xA000 FlashPixVersion text EXIF FlashPixVersion
0xA001 ColorSpace text EXIF ColorSpace
0xA002 ExifImageWidth text EXIF ExifImageWidth
0xA003 ExifImageLength text EXIF ExifImageLength
0xA005 InteroperabilityOffset text EXIF InteroperabilityOffset
0xA20B FlashEnergy [14] text EXIF FlashEnergy
0xA20C SpatialFrequencyResponse text EXIF SpatialFrequencyResponse
0xA20E FocalPlaneXResolution text EXIF FocalPlaneXResolution
0xA20F FocalPlaneYResolution text EXIF FocalPlaneYResolution
0xA210 FocalPlaneResolutionUnit text EXIF FocalPlaneResolutionUnit
0xA214 SubjectLocation text EXIF SubjectLocation
0xA215 ExposureIndex text EXIF ExposureIndex
0xA217 SensingMethod text EXIF SensingMethod
0xA300 FileSource text EXIF FileSource
0xA301 SceneType text EXIF SceneType
[1] If the file is later cropped, don't change the text EXIF 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], [14] TIFF tags 0x920B through 0x9217 are duplicates of 0xA20B through 0xA217. The latter appear in the ISO Standard for TIFF-EP [TIFF-EP], but the former have been written by some applications.
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 text EXIF 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. Any CRLF sequences in such strings are replaced with the newline character. 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 a 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)
             

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 cognizaant 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.

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.

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]