|
北京总部: 4006-505-646 |
天 津 部: 4006-505-646 |
上 海 部: 4006-505-646 |
深 圳 部: 4006-505-646 |
广 州 部: 4006-505-646 |
重 庆 部: 4006-505-646 |
南 京 部: 4006-505-646 |
其它地区: 4006-505-646 | | |
|
|
|
Exif file format
Description of Exif file format
Currently, most of new digicam use Exif file format to store images. This specification was made by JEIDA, but there is no open document in internet. So I made tiny description about Exif from some of open documents that can get from internet.
Add: Now we can get official document of Exif2.1 from PIMA's website.
ISO is now working to build DCF (Design rule for Camera File system) Specification. The entire digicam manufacturer is moving to adopt it and their newest digicam already uses DCF. DCF defines whole file-system of digicam; directory structure, file naming method, character set and file format etc. The file format of DCF is based on Exif2.1 specification.
I believe this document is basically based on Exif2.1/DCF specification, if you have information about 'unknown' item or find errata, please e-mail me, TsuruZoh Tachibanaya , t s u r u z o h @ b a . w a k w a k . c o m
This is a FREE document, you may use this document for any purpose (commercial/non-commercial) of all/part of this document. All trade names mentioned in this document are trademarks or registered trademarks of their respective holders.
TsuruZoh Tachibanaya, t s u r u z o h @ b a . w a k w a k . c o m
http://park2.wakwak.com/~tsuruzoh/
rev. 1.4 Feb.03,2001 rev. 1.3 Sep.09,2000 rev. 1.2 Jul.19,2000 rev. 1.1 Dec.19,1999 rev. 1.0 May.28,1999
--------------------------------------------------------------------------------
Referenced materials
Exif file format written by itojun (Japanese language document) Exif file format written by Mamoru Ohno (Japanese language document) TIFF6.0 Specification written by Adobe TIFF/EP Specification written by ISO TC42 WG18 exifdump program written by Thierry Boush DCF Specification written by ISO TC42 WG18 Exif2.1 Specification written by JEIDA
--------------------------------------------------------------------------------
What is Exif format?
JPEG format and Marker
Marker used by Exif
Exif data structure
TIFF Header
IFD : Image file directory
Data format
IFD data structure
Thumbnail image
JPEG format thumnail
TIFF format thumbnail
Tag number used by Exif/TIFF
IFD0 (IFD of main image) section
Exif SubIFD section
IFD1 (IFD of thumbnail image) section
Misc Tags
Appendix 1: MakerNote of Olympus digicams
Appendix 2: MakerNote of Nikon digicams
Appendix 3: MakerNote of Casio digicams
Appendix 4: MakerNote of Fujifilm digicams
Appendix 5: MakerNote of Canon digicams
History
Acknowledgement
--------------------------------------------------------------------------------
What is Exif file format?
Basically, Exif file format is the same as JPEG file format. Exif inserts some of image/digicam information data and thumbnail image to JPEG in conformity to JPEG specification. Therefore you can view Exif format image files by JPEG compliant Internet browser/Picture viewer/Photo retouch software etc. as a usual JPEG image files.
JPEG format and Marker
Every JPEG file starts from binary value '0xFFD8', ends by binary value '0xFFD9'. There are several binary 0xFFXX data in JPEG data, they are called as "Marker", and it means the period of JPEG information data. 0xFFD8 means SOI(Start of image), 0xFFD9 means EOI(End of image). These two special Markers have no data following, the other Markers have data with it. Basic format of Marker is below.
0xFF Marker Number(1 byte) Data size(2 bytes) Data(n bytes)
Data size(2 Bytes) has "Motorola" byte align, starts from bigger digits. Please notice that "Data" contains Data size descriptor, if there is a Marker like this;
FF C1 00 0C
It means this Marker(0xFFC1) has 0x000C(equal 12)bytes of data. But the data size '12' includes "Data size" descriptor, it follows only 10 bytes of data after 0x000C.
In JPEG format, some of Markers describe data, then SOS(Start of stream) Marker placed. After the SOS marker, JPEG image stream starts and terminated by EOI Marker.
SOI Marker Marker XX size=SSSS Marker YY size=TTTT SOS Marker size=UUUU Image stream EOI Marker
FFD8 FFXX SSSS DDDD...... FFYY TTTT DDDD...... FFDA UUUU DDDD.... I I I I.... FFD9
Marker used by Exif
The marker 0xFFE0~0xFFEF is named "Application Marker", not necessary for decoding JPEG image. They are used by user application. For example, older olympus/canon/casio/agfa digicam use JFIF(JPEG File Interchange Format) for storing images. JFIF uses APP0(0xFFE0) Marker for inserting digicam configuration data and thumbnail image.
Also Exif uses an Application Marker for inserting data, but Exif uses APP1(0xFFE1) Marker to avoid a conflict with JFIF format. Every Exif file formats starts from this format;
SOI Marker APP1 Marker APP1 Data Other Marker
FFD8 FFE1 SSSS 457869660000 TTTT...... FFXX SSSS DDDD......
It starts from SOI(0xFFD8) Marker, so it's a JPEG file. Then APP1 Marker follows immediately. All the data of Exif are stored in this APP1 data area. The part of "SSSS" on upper table means the size of APP1 data area (Exif data area). Please notice that the size "SSSS" includes the size of descriptor itself also.
After the "SSSS", APP1 data starts. The first part is a special data to identify whether Exif or not, ASCII character "Exif" and 2bytes of 0x00 are used.
After the APP1 Marker area, the other JPEG Markers follows.
Exif data structure
Roughly structure of Exif data (APP1) is shown as below. This is a case of "Intel" byte aligns and it contains JPEG format thumbnail. As described above, Exif data is starts from ASCII character "Exif" and 2bytes of 0x00, and then Exif data follows. Exif uses TIFF format to store data. For more details of TIFF format, please refer to "TIFF6.0 specification".
FFE1 APP1 Marker
SSSS APP1 Data APP1 Data Size
45786966 0000 Exif Header
49492A00 08000000 TIFF Header
XXXX. . . . IFD0 (main image) Directory
LLLLLLLL Link to IFD1
XXXX. . . . Data area of IFD0
XXXX. . . . Exif SubIFD Directory
00000000 End of Link
XXXX. . . . Data area of Exif SubIFD
XXXX. . . . Interoperability IFD Directory
00000000 End of Link
XXXX. . . . Data area of Interoperability IFD
XXXX. . . . Makernote IFD Directory
00000000 End of Link
XXXX. . . . Data area of Makernote IFD
XXXX. . . . IFD1(thumbnail image) Directory
00000000 End of Link
XXXX. . . . Data area of IFD1
FFD8XXXX. . . XXXXFFD9 Thumbnail image
Structure of TIFF header
First 8bytes of TIFF format are TIFF header. First 2bytes defines byte align of TIFF data. If it is 0x4949="I I", it means "Intel" type byte align. If it is 0x4d4d="MM", it means "Motorola" type byte align. For example, value '305,419,896' is noted as 0x12345678 by sixteenth system. At the Motorola align, it is stored as 0x12,0x34,0x56,0x78. If it's Intel align, it is stored as 0x78,0x56,0x34,0x12. It seems that most of digicam uses Intel align. Ricoh uses Motorola align. Sony uses Intel align except D700. Kodak DC200/210/240 use Motorola aligns, but DC220/260 use Intel aligns though they are using PowerPC! Therefore when we need the value of Exif data, we MUST check byte align every time. Though JPEG data uses Motorola align only, Exif allows both alignments. I can't understand why Exif didn't fix a byte align to Motorola.
Next 2bytes are always 2bytes-length value of 0x002A. If the data uses Intel align, next 2bytes are "0x2a,0x00". If it uses Motorola, they are "0x00,0x2a". The last 4bytes of TIFF header are an offset to the first IFD(Image File Directory, described in next chapter). Includes this offset, all the offset value used in TIFF format counts offset bytes from the first of TIFF header("I I" or "MM"). Usually the first IFD starts immediately next to TIFF header, so this offset has value '0x00000008'.
Byte align TAG Mark Offset to first IFD
"I I" or "MM" 0x002a 0x00000008
IFD : Image file directory
Next to TIFF header, there is the first IFD:Image File Directory. It contains image information data. At the chart below, the first 2bytes('EEEE') means the number of directory entry contains in this IFD. Then directory entry (12bytes per entry) follows. After last directory entry, there is a 4bytes of data('LLLLLLLL' at the chart), it means an offset to next IFD. If its value is '0x00000000', it means this is the last IFD and there is no linked IFD.
EEEE No. of directory entry
TTTT ffff NNNNNNNN DDDDDDDD Entry 0
TTTT ffff NNNNNNNN DDDDDDDD Entry 1
. . . . . . . . . . . . . . .
TTTT ffff NNNNNNNN DDDDDDDD Entry EEEE-1
LLLLLLLL Offset to next IFD
'TTTT'(2bytes) of above chart is Tag number, this shows a kind of data. 'ffff'(2bytes) is data format, 'NNNNNNNN'(4bytes) is number of components. 'DDDDDDDD'(4bytes) contains a data value or offset to data value.
Data format
Data format ('ffff' at the above chart) is defined as below. "rational" means a fractional value, it contains 2-signed/unsigned long integer values, and the first represents the numerator, and the second, the denominator.
Value 1 2 3 4 5 6
Format unsigned byte ascii strings unsigned short unsigned long unsigned rational signed byte
Bytes/component 1 1 2 4 8 1
Value 7 8 9 10 11 12
Format undefined signed short signed long signed rational single float double float
Bytes/component 1 2 4 8 4 8
You can get the total data byte length by multiplies a 'bytes/components' value (see above chart) by number of components stored 'NNNNNNNN' area. If total data length is less than 4bytes, 'DDDDDDDD' contains the value of that Tag. If its size is over 4bytes, 'DDDDDDDD' contains the offset to data stored address.
IFD data structure
At Exif format, the first IFD is IFD0(IFD of main image), then it links to IFD1(IFD of thumbnail image) and IFD link is terminated. But IFD0/IFD1 doesn't contain any digicam's information such as shutter speed, focal length etc. IFD0 always contains special Tag Exif Offset (0x8769), it shows an offset to Exif SubIFD. Exif SubIFD is IFD formatted data also, it contains digicam's information.
In case of Extended Exif format (Exif2.1/DCF), Exif SubIFD contains special Tag Exif Interoperability Offset (0xa005). It also points to the Interoperability IFD. By the DCF specification, this tag is mandatory and both SubIFD (main image IFD) and IFD1 (thumbnail image IFD) may have Interoperability IFD. In usual, only main image have this tag.
And some of digicam uses IFD data format for Makernote; Maker-specific magic number area. It's very hard to decision whether makernote is IFD format or not, be careful to coding program. See Appendix for information of Makernote.
0000: 49 49 2A 00 08 00 00 00-02 00 1A 01 05 00 01 000010: 00 00 26 00 00 00 69 87-04 00 01 00 00 00 11 020020: 00 00 40 00 00 00 48 00-00 00 01 00 00 00
If the first part of TIFF data is above, it can read as;
The first 2bytes are "I I", byte align is 'Intel'.
Address 0x0004~0x0007 is 0x08000000, IFD0 starts from address '0x0008'
Address 0x0008~0x0009 is 0x0200, number of directory entry of IFD0 is '2'.
Address 0x000a~0x000b is 0x1A01, it means this is an XResolution(0x011A) Tag, it contains a horizontal resolution of image.
Address 0x000c~0x000d is 0x0500, format of this value is unsigned rational(0x0005).
Address 0x000e~0x0011 is 0x01000000, number of components is '1'. Unsigned rational's data size is 8bytes/components, so total data length is 1x8=8bytes.
Total data length is larger than 4bytes, so next 4bytes contains an offset to data.
Address 0x0012~0x0015 is 0x26000000, XResolution data is stored to address 0x0026
Address 0x0026~0x0029 is 0x48000000, numerator is 72, address 0x002a~0x002d is 0x0100000000, denominator is '1'. So the value of XResoultion is 72/1.
Address0x0016~0x0017 is 0x6987, next Tag is ExifOffset(0x8769). Its value is an offset to Exif SubIFD
Data format is 0x0004, unsigned long integer.
This Tag has one component. Unsigned long integer's data size is 4bytes/components, so total data size is 4bytes.
Total data size is equal to 4bytes, next 4bytes contains the value of Exif SubIFD offset.
Address 0x001e~0x0021 is 0x11020000, Exif SubIFD starts from address '0x0211'.
This is the last directory entry, next 4bytes shows an offset to next IFD.
Address 0x0022~0x0025 is 0x40000000, next IFD starts from address '0x0040'
Thumbnail image
Exif format contains thumbnail of image (except Ricoh RDC-300Z). Usually it is located next to the IFD1. There are 3 formats for thumbnails; JPEG format(JPEG uses YCbCr), RGB TIFF format, YCbCr TIFF format. It seems that JPEG format and 160x120 pixels of size are recommended thumbnail format for Exif2.1 or later. By the DCF specification, thumbnail image MUST use JPEG format and image size is fixed to 160x120 pixels.
JPEG format thumbnail
If the value of Compression(0x0103) Tag in IFD1 is '6', thumbnail image format is JPEG. Most of Exif image uses JPEG format for thumbnail. In that case, you can get offset of thumbnail from JpegIFOffset(0x0201) Tag in IFD1, size of thumbnail from JpegIFByteCount(0x0202) Tag. Data format is ordinary JPEG format, starts from 0xFFD8 and ends by 0xFFD9.
TIFF format thumbnail
If the value of Compression(0x0103) Tag in IFD1 is '1', thumbnail image format is no compression(called TIFF image). Start point of thumbnail data is StripOffset(0x0111) Tag, size of thumbnail is the sum of StripByteCounts(0x0117) Tag.
If thumbnail uses no compression and PhotometricInterpretation(0x0106)Tag in IFD1 has a value '2', thumbnail uses RGB format. In that case, you can see thumbnail image by simply copy data to computer's RGB format(such as BMP format, or copy to VRAM directory). Kodak DC-210/220/260 uses this format. Be mention that at TIFF stores pixel data as 'RGB' order, but BMP stores 'BGR' order. If that tag has a value '6', thumbnail uses YCbCr format. If you want to see thumbnail, you must convert it to RGB. Ricoh RDC4200/4300, Fuji DS-7/300 and DX-5/7/9 use this format(newer RDC5000/MX-X00 series use JPEG). Next section is brief description to conversion of Fuji DS's thumbnail. For more details, refer to TIFF6.0 specification.
At DX-5/7/9, YCbCrSubsampling(0x0212) has values of '2,1', PlanarConfiguration(0x011c) has a value '1'. So the data align of this image is below.
Y(0,0),Y(1,0),Cb(0,0),Cr(0,0), Y(2,0),Y(3,0),Cb(2,0),Cr(3.0), Y(4,0),Y(5,0),Cb(4,0),Cr(4,0). . . .
The numeric in parenthesis is pixel coordinates. DX series' YCbCrCoefficients(0x0211) has values '0.299/0.587/0.114', ReferenceBlackWhite(0x0214) has values '0,255,128,255,128,255'. Therefore to convert from Y/Cb/Cr to RGB is;
B(0,0)=(Cb-128)*(2-0.114*2) Y(0,0) R(0,0)=(Cr-128)*(2-0.299*2) Y(0,0) G(0,0)=(Y(0,0)-0.114*B(0,0)-0.299*R(0,0))/0.587
Horizontal subsampling is a value '2', so you can calculate B(1,0)/R(1,0)/G(1,0) by using the Y(1,0) and Cr(0,0)/Cb(0,0). Repeat this conversion by value of ImageWidth(0x0100) and ImageLength(0x0101).
Tag number used by Exif/TIFF
Tag numbers used by Exif/TIFF are shown as below. If the Tag has upper limit of components number, CompoNo column has numeric value. If it has no value, there is no limitation.
Tags used by IFD0 (main image)
Tag No. Tag Name Format CompoNo Desc.
0x010e ImageDescription ascii string Describes image. Two-byte character code such as Chinese/Korean/Japanese cannot be used.
0x010f Make ascii string Shows manufacturer of digicam. In the Exif standard, this tag is optional, but it is mandatory for DCF.
0x0110 Model ascii string Shows model number of digicam. In the Exif standard, this tag is optional, but it is mandatory for DCF.
0x0112 Orientation unsigned short 1
Value 0th Row 0th Column
1 top left side
2 top right side
3 bottom right side
4 bottom left side
5 left side top
6 right side top
7 right side bottom
8 left side bottom
The orientation of the camera relative to the scene, when the image was captured. The relation of the '0th row' and '0th column' to visual position is shown as right.
0x011a XResolution unsigned rational 1 Display/Print resolution of image. Default value is 1/72inch, but it has no mean because personal computer doesn't use this value to display/print out.
0x011b | |
|
上一篇:专业数码照片CR2、TIF恢复成功 |
下一篇:DELL笔记本装系统数据丢失100恢复 | |
| | |