TIFF-PIL TIFF format (Pillow)

Extensions: .tif, .tiff

This is a copy from the Pillow docs.

PIL reads and writes TIFF files. It can read both striped and tiled images, pixel and plane interleaved multi-band images, and either uncompressed, or Packbits, LZW, or JPEG compressed images.

If you have libtiff and its headers installed, PIL can read and write many more kinds of compressed TIFF files. If not, PIL will always write uncompressed files.

The write() method sets the following info properties:


Compression mode.

New in version Pillow: 2.0.0


Image resolution as an (xdpi, ydpi) tuple, where applicable. You can use the tag attribute to get more detailed information about the image resolution.

New in version Pillow: 1.1.5


Image resolution as an (xres, yres) tuple, where applicable. This is a measurement in whichever unit is specified by the file.

New in version Pillow: 1.1.5

The tag_v2 attribute contains a dictionary of TIFF metadata. The keys are numerical indexes from TAGS_V2. Values are strings or numbers for single items, multiple values are returned in a tuple of values. Rational numbers are returned as a IFDRational object.

New in version Pillow: 3.0.0

For compatibility with legacy code, the tag attribute contains a dictionary of decoded TIFF fields as returned prior to version 3.0.0. Values are returned as either strings or tuples of numeric values. Rational numbers are returned as a tuple of (numerator, denominator).

Deprecated since version 3.0.0.

Saving Tiff Images

The save() method can take the following keyword arguments:


If true, Pillow will save all frames of the image to a multiframe tiff document.

New in version Pillow: 3.4.0


A ImageFileDirectory_v2 object or dict object containing tiff tags and values. The TIFF field type is autodetected for Numeric and string values, any other types require using an ImageFileDirectory_v2 object and setting the type in tagtype with the appropriate numerical value from TiffTags.TYPES.

New in version Pillow: 2.3.0

Metadata values that are of the rational type should be passed in using a IFDRational object.

New in version Pillow: 3.1.0

For compatibility with legacy code, a ImageFileDirectory_v1 object may be passed in this field. However, this is deprecated.

New in version Pillow: 3.0.0


Only some tags are currently supported when writing using libtiff. The supported list is found in LIBTIFF_CORE.

A string containing the desired compression method for the file. (valid only with libtiff installed) Valid compression methods are: None, "tiff_ccitt", "group3", "group4", "tiff_jpeg", "tiff_adobe_deflate", "tiff_thunderscan", "tiff_deflate", "tiff_sgilog", "tiff_sgilog24", "tiff_raw_16"

These arguments to set the tiff header fields are an alternative to using the general tags available through tiffinfo.





A string of “inch”, “centimeter” or “cm”




Either a Float, 2 tuple of (numerator, denominator) or a IFDRational. Resolution implies an equal x and y resolution, dpi also implies a unit of inches.