TIFF image format and WebKit Decoding

Source: Internet
Author: User

Tiff (taglmagefileformat) is a common image file format developed by Aldus and Microsoft for the desktop publishing system. Tiff formats flexible and variable, it defines four different formats: TIFF-B for Binary Images: TIFF-G for black-and-white gray images; TIFF-P for color images with a palette: TIFF-R applies to RGB true color images.

Tiff supports multiple encoding methods, including RGB, RLE, and JPEG.

Tiff is one of the most complex formats of existing image files. It is scalable, convenient, and changeable and can be provided to running and image editing programs in ibnmpc and other environments.

A tiff image file consists of three data structures: the file header, one or more IFD directories containing the mark pointer, and the data itself.

The first data structure in a TIFF image file is called the image file header or IFH. This structure is a unique and fixed part of a tiff file. The IFD image file directory is a variable-byte information block, and tag is the core part of the TIFF file, all image parameters are defined in the image file directory. Each directory entry contains a parameter of the image.

TIF image format Overview

The TIF graph consists of four parts:
1. Image File Header (IFH ):

Figure 1 IFH Structure Description

The IFH data structure contains a total of 8 bytes of three members. The byte order member may be "mm" (0x4d4d) or "II" (0x4949 ), 0x4d4d indicates that the TIFF image is in the Motorola integer format 0x4949, indicating that the image is in the Intel integer format. The version member always contains the decimal 42 (0x2a), which is used to further verify whether the file is in the Tif format, 42 this number is not generally considered as the TIF software version, in fact, the number 42 will never change; The Third Member is IFD (the second data structure to be discussed next) the offset relative to the start of the file.

2. Image File directory (IFD ):

Figure 2 IFD and De Structure Description

IFD is the most important data structure in a TIF graph. It contains the most important information in a tif file. a tif graph may have multiple ifds, which indicates that there are multiple images in the file, each IFD identifies the basic attributes of an image. The IFD structure contains three types of members. Directory Entry count indicates the number of directory entries in the structure. Next, there are n de sequences in linear arrangement, the number is not fixed (this is why Tif format files can be expanded, or even users can add custom tag attributes), each de identifies a certain attribute of the image; the last offset identifies the position of the next file directory relative to the start of the file. Of course, if the tif file contains only one image, there is only one IFD. Obviously, the offset is equal to 0;

3. Directory Entry (de ):
12 bytes in total, as shown in figure 2. Simply put, a de is a certain attribute of an image. For example, the image size, resolution, whether to compress, the number of rows and columns of pixels, and the number of digits of a pixel (1 represents both black and white, and 8 represents 256 colors. The tag member is the ID of this attribute. In the image file directory, it is sorted in ascending order. You can read these numbers and find the meanings in the TIF White Paper. Attribute is represented by data, so type represents the data type. tif officially specifies five data types. Type = 1 is the byte type (8-bit untagged integer), type = 2 is the ASCII type (7-bit ASCII code plus 1-bit binary 0), type = 3 is the short type (16-bit untagged integer), type = 4 is long
Type (32-bit untagged integer), type = 5 is the rational type (2 long, the first is the molecule, and the second is the denominator ). The length member is the number of data rather than the length of the data type. Valueoffset is very important for 4th members. It is the offset of the variable value represented by the tag attribute relative to the start of the file. If the space occupied by the variable value is less than 4 bytes, the value is stored in valueoffset, and there is no need to point to another place.

4. Image Data the image provided in this example is based on 256 gray level, that is, a byte represents a pixel, Which is 0x00 ~ Any integer with 256 gray levels in the 0xff interval. By using the ultraedit tool, we found that the image file is organized in the form of IFH -- Data -- IFD.

An error occurs when WebKit parses Tiff. Therefore, browsers such as chrome and Android cannot display tiff images. After analysis, it turns out that tiff needs to be parsed after the network loads data,
Partial parsing is not supported.

Solution: Add a condition judgment statement to imagesource: setdata.

If (codec-> getformat () = skimagedecoder: k1__format &&! Alldatareceived ){


Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.