TIFF (.tiff, .tif)
Background & Context
-
- Registered MIME type: image/tiff
- TIFF raster image format.
- Commonly used in image manipulation applications, page layout applications, scanners and other imaging devices, and for the archiving of images.
- Suitable for high-color-depth images.
- TIFF is an acronym for Tagged Image File Format.
- Binary format.
- Supports multiple color resolutions, color encodings, color palettes, and compression methods.
- Supports floating-point images with 32 and 64 bits per channel.
- Can store multiple images.
- Supports alpha channels.
- Introduced in 1986 by Aldus.
Import & Export
- Import["file.tiff"] imports a TIFF file, returning a single Image object or a list of images.
- Import["file.tiff",elem] imports the specified element from a TIFF file.
- The import format can be specified with Import["file","TIFF"] or Import["file",{"TIFF",elem,…}].
- Export["file.tiff",expr] exports an image, graphics, or any other expression as an image to a TIFF file.
- Export["file.tiff",{expr1,expr2,…}] exports a list of expressions as a multi-image TIFF file.
- Export["file.tiff",Manipulate[…]] exports a list of frames from an animated demonstration of a Manipulate object.
- Image objects are by default exported at their full raster size. Graphics and other arbitrary expressions are exported using the same raster size as their displayed form.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"ColorMap" color reduction palette "Data" array of pixel values "Graphics" the first image in the file, given as graphics "Image" first image in the file, represented as an Image object "RawData" array of color map indices "Thumbnail" thumbnail of the first image - Data representation elements for multi-image TIFF files:
-
"Animation" multi-image TIFF represented as an animation object "Image3D" images in the file, represented as an Image3D object {"GraphicsList",frames} images as a list of graphics (default frames=All) {"ImageList",frames} a list of images (default frames=All) {"ThumbnailList",frames} a list of thumbnails (default frames=All) - Import by default uses "Image" for single-frame TIFF files and "ImageList" for multi-frame TIFF files.
- Import of a multi-image TIFF with element "Graphics" or "Image" gives the first image.
- Export by default generates a multi-image TIFF if the expression supplied is a list of Graphics or Image objects.
- Export with element "Graphics" or "Image" always generates a single-image TIFF.
- Advanced Import elements:
-
"BitDepth" bits used to represent each color channel in the file "Channels" the number of color channels used in the file "ColorProfileData" embedded color profile, given as a ColorProfileData object "ColorSpace" color encoding used in the file "ImageCount" number of images in the file "ImageEncoding" how images are compressed in the file "ImageResolution" image resolution specified in the file "ImageSize" raster dimensions "Summary" summary of the file "SummarySlideView" slide view summary of all frames - Advanced metadata elements:
-
"CameraTopOrientation" orientation of the camera when the picture was taken "Exif" formatted Exif (Exchange image file format) "FlashUsed" whether the flash was fired "GeoPosition" latitude and longitude represented as GeoPosition object "GPSDateTime" image creation date and time registered by GPS "IPTC" formatted IPTC (International Press Telecommunications Council) "MetaInformation" combination of all formatted metadata present in the file "XMP" formatted XMP (Extensible metadata platform) - Raw metadata, as stored in the file, can be imported using "RawExif", "RawXMP", and "RawIPTC" elements, returned as an association.
- All Exif and IPTC tags can be imported individually. Common tags include:
-
"ApertureValue" lens aperture "DateTime" image creation date and time "ExposureTime" exposure time, given in seconds "FNumber" F number "FocalLength" actual focal length of the lens, given in millimeters "Make" manufacturer of the recording equipment "Model" model name or model number of the equipment "Software" name and version of the software or firmware of the camera or image input device used to generate the image - For multi-image TIFF files, the above data representation and metadata elements are taken to be lists of the respective expressions.
Import Options
- Import options include:
-
ImageResolution Automatic resolution used for rendering the graphics "ImageTopOrientation" Automatic orientation of the image as stored in the file IncludeMetaInformation All metadata types to import and export RasterSize Automatic dimensions of the image "TakeRows" {1,-1} rows to import - Possible settings for "ImageTopOrientation" are Automatic, Top, Bottom, Left or Right.
Export Options
- Export to TIFF has the same options as Rasterize, with the following additions and changes:
-
"BitDepth" Automatic bit depth per channel used to store image data ByteOrdering -1 ordering of bytes in the file "ColorMapLength" Automatic number of colors to use for quantization "ColorSeparation" False whether to store color channels in separate planes ColorSpace Automatic color encoding to be used in the file CompressionLevel Automatic compression level, given as a number between 0 and 1 "DifferencingPredictor" False whether to use horizontal differencing when using LZW or ZIP compression Dithering "FloydSteinberg" dithering algorithm used for generating the color-reduction table "ImageEncoding" "ZIP" how images are compressed in the file ImageResolution Automatic resolution used for rendering the graphics "ImageTopOrientation" Automatic orientation of the image as stored in the file IncludeMetaInformation All metadata types to import and export "QuantizationMethod" Automatic a method to use for quantization RasterSize Automatic dimensions of the image - Export["file.tiff",expr] creates a TIFF image with the same image size as the displayed form of expr.
- Supported "BitDepth" settings are: Automatic, 1, 8, 16, 32, and 64.
- By default, "Bit" images are exported to 1-bit, "Byte" images are exported to 8-bit, and other types are exported to 16-bit TIFF files.
- The value of "ColorMapLength" can be a positive integer not greater than 256.
- Supported "ColorSpace" settings are: "Grayscale", "RGB", "CMYK", and "LAB".
- Possible settings for Dithering are "FloydSteinberg" or None.
- The following settings for "ImageEncoding" are supported:
-
None no compression "JPEG" lossy JPEG compression "LZW" lossless LZW compression "PackBits" PackBits run-length encoding method "ZIP" lossless ZIP image data compression - Possible settings for "ImageTopOrientation" are Automatic, Top, Bottom, Left or Right.
- Possible settings for "QuantizationMethod" are Automatic, "MedianCut", "MinVariance" or "Octree".
- Options for exporting a Manipulate:
-
"ControlAppearance" Automatic how Manipulate control elements are rendered in the exported file - The following settings can be given for "ControlAppearance":
-
Automatic captures user controls exactly as seen in the notebook interface, using the style elements of the local computer system "Generic" renders graphical controls in a generic style None excludes control elements when exporting an animation
Examples
open all close allBasic Examples (5)
This imports a TIFF example file, rendering it as an Image:
Import["ExampleData/spikey.tiff"]Import["ExampleData/spikey.tiff", "Summary"]Export["image.tiff", [image]]Import a multi-frame TIFF file as an animation:
Import["ExampleData/CTengine.tiff", "Animation"]Create a multi-frame TIFF file from a list of images:
Export["multiframe.tiff", {[image], [image], [image], [image], [image]}]Scope (8)
Show all elements available in the file:
Import["ExampleData/spikey.tiff", "Elements"]Import["ExampleData/spikey.tiff", {"Exif", "Elements"}]//ShortImport["ExampleData/spikey.tiff", {"IPTC", "Elements"}]//ShortImport["ExampleData/hedgehog.tiff", "DateTime"]Export["binary.tiff", [image]]Import[%, "BitDepth"]Export a real-valued RGB image:
Export["real.tiff", [image], "BitDepth" -> 32]Export["lab.tiff", [image]]Create a TIFF file from data representation elements:
Export["random.tiff", {"Data" -> RandomInteger[255, {10, 10, 4}]}, "Rules", ColorSpace -> "CMYK"]Create a multi-frame TIFF file from a list of RGB images:
Export["multiframeRGB.tiff", {[image], [image], [image], [image], [image], [image]}]Create a multi-frame TIFF from a Manipulate:
Manipulate[Blur[[image], r], {r, 1, 10}]Export["blur.tiff", %]Read the number of exported frames:
Import[%, "ImageCount"]Import Elements (39)
Available Elements (4)
Import["ExampleData/spikey.tiff", "Elements"]List of available Exif elements:
Import["ExampleData/spikey.tiff", {"Exif", "Elements"}]//ShortList of available IPTC elements:
Import["ExampleData/spikey.tiff", {"IPTC", "Elements"}]//ShortGet image-related information as list of rules:
Import["ExampleData/spikey.tiff", "Rules"]//ShortData Representation (10)
"Animation" (1)
"Data" (1)
"Graphics" (1)
Import as a Graphics object:
Import["ExampleData/spikey.tiff", "Graphics"]Head[%]"Image" (2)
"Image3D" (1)
Multi-frame TIFF files with commensurate properties can get imported as an Image3D:
Import["ExampleData/CTengine.tiff", "Image3D"]"ImageList" (2)
Get the data as a list of Image objects:
Import["ExampleData/CTengine.tiff", "ImageList"][[1 ;; 3]]This is the default import element for TIFF:
Import["ExampleData/CTengine.tiff"][[1 ;; 3]]Import["ExampleData/CTengine.tiff", {"ImageList", Range[3]}]"Thumbnail" (1)
Metadata (25)
"BitDepth" (1)
"CameraTopOrientation" (1)
"Channels" (1)
"ColorProfileData" (1)
Get the embedded color profile, given as a ColorProfileData object:
Import["ExampleData/peacock.tif", "ColorProfileData"]The color profile is stored in the ColorSpace option of the imported image:
Options[Import["ExampleData/peacock.tif"], ColorSpace]"ColorSpace" (1)
Get the color encoding used on export:
Import["ExampleData/spikey.tiff", "ColorSpace"]Use ImageColorSpace to get the color space of an imported image:
Import["ExampleData/spikey.tiff"]//ImageColorSpace"DateTime" (1)
"Exif" (3)
Import["ExampleData/spikey.tiff", "Exif"]Extract an individual tag from the association:
Import["ExampleData/spikey.tiff", "Exif"]["Image", "BitsPerSample"]Individual Exif tags can also be imported directly:
Import["ExampleData/spikey.tiff", "BitsPerSample"]Some Exif tags are processed to give more detailed information:
Import["ExampleData/spikey.tiff", "Orientation"]Compare with the raw "Orientation" tag:
Import["ExampleData/spikey.tiff", "RawExif"]["Image", "Orientation"]"FlashUsed" (1)
Import a tag that shows whether the flash fired:
Import["ExampleData/hedgehog.tiff", "FlashUsed"]"FlashUsed" is a subelement of "FlashInfo" element:
Import["ExampleData/hedgehog.tiff", "Exif"]["Photo", "FlashInfo"]Extract "FlashUsed" from the full "Exif":
Import["ExampleData/hedgehog.tiff", "Exif"]["Photo", "FlashInfo", "FlashUsed"]"GeoPosition" (1)
"GPSDateTime" (1)
"ImageCount" (1)
"ImageEncoding" (1)
"MetaInformation" (1)
"RasterSize" (1)
Get the dimensions of the image stored in the file:
Import["ExampleData/spikey.tiff", "RasterSize"]Using ImageDimensions on an imported image gives the same result:
Import["ExampleData/spikey.tiff"]//ImageDimensions"RedEyeCorrection" (1)
"RawExif" (1)
Import unprocessed Exif metadata:
Short@Import["ExampleData/hedgehog.tiff", "RawExif"]Import["ExampleData/hedgehog.tiff", "RawExif"]["Photo", "FocalLength"]Compare to the processed element:
Import["ExampleData/hedgehog.tiff", "Exif"]["Photo", "FocalLength"]"RawIPTC" (1)
"RawXMP" (1)
"RowsPerStrip" (1)
"Summary" (1)
"SummarySlideView" (1)
Import Options (7)
ImageResolution (1)
By default, the image resolution is extracted from the file:
Options[Import["ExampleData/spikey.tiff"], ImageResolution]Specify the resolution of the imported image:
Options[Import["ExampleData/spikey.tiff", ImageResolution -> 72], ImageResolution]Specify different resolutions in
and
directions:
Options[Import["ExampleData/spikey.tiff", ImageResolution -> {72, 144}], ImageResolution]"ImageTopOrientation" (1)
By default, images are imported with the native orientation stored in the file:
Import["ExampleData/hedgehog.tiff"]Specify the side that is supposed to be on the top:
Import["ExampleData/hedgehog.tiff", "ImageTopOrientation" -> Left]The correct orientation can also be achieved by rotating the image after import:
ImageRotate[Import["ExampleData/hedgehog.tiff"], Left -> Top]IncludeMetaInformation (3)
By default, all available metadata is imported:
Options[Import["ExampleData/peacock.tif"], MetaInformation]//ShortAll imported classes of metadata:
Keys[MetaInformation /. %]Import the image with no metadata:
Options[Import["ExampleData/peacock.tif", IncludeMetaInformation -> None], MetaInformation]Import the image with Exif metadata only:
Options[Import["ExampleData/peacock.tif", IncludeMetaInformation -> {"Exif"}], MetaInformation]//ShortRasterSize (1)
By default, images are imported in their full resolution:
Import["ExampleData/spikey.tiff"]Specify the raster size of the imported JPEG image:
Import["ExampleData/spikey.tiff", RasterSize -> 50]ImageDimensions[%]Specify both width and height of the imported image:
Import["ExampleData/spikey.tiff", RasterSize -> {50, 20}]ImageDimensions[%]Export Options (12)
"BitDepth" (2)
By default, the exported TIFF file has a bit depth of 16:
Export["real.tiff", [image]]Import[%, "BitDepth"]Specify a different bit depth:
Export["real.tiff", [image], "BitDepth" -> 32]Import[%, "BitDepth"]Export real valued lists to TIFF:
Export["floating.tiff", RandomReal[1., {10, 10, 3}], {"TIFF", "Data"}, "BitDepth" -> 32]Import[%, "BitDepth"]ColorSpace (1)
By default, the native color space of the image is used for export:
i = [image];Export["image.tif", i]Import[%, "ColorSpace"]Export["image.tif", i, ColorSpace -> "CMYK"]Import[%, "ColorSpace"]CompressionLevel (1)
By default, with some image encodings, an automatic compression level is used:
i = [image];Export["image.tif", i, "ImageEncoding" -> "ZIP"]FileSize[%]Specify the compression level:
Export["image.tif", i, "ImageEncoding" -> "ZIP", CompressionLevel -> 1]//FileSizeCompare the file size for different compression levels:
Table[FileSize@Export["image.tif", i, "ImageEncoding" -> "ZIP", CompressionLevel -> c], {c, 0, 1, .1}]//ListLinePlot"ControlAppearance" (1)
Control the appearance of a multi-frame TIFF from a Manipulate:
m = Manipulate[Blur[[image], r], {r, 1, 10}]By default, the controls are also included:
ImportString[ExportString[m, "TIFF"], "Image"]ImportString[ExportString[m, "TIFF", "ControlAppearance" -> None], "Image"]"ColorMapLength" (1)
Dithering (1)
"ImageEncoding" (1)
"ImageTopOrientation" (1)
By default, the upright image is exported using "ImageTopOrientation"->Top:
i = [image];Export["image.tif", i]Import[%]Export["image.tif", i, "ImageTopOrientation" -> Left]Import["image.tif"]Import using the original orientation:
Import["image.tif", "ImageTopOrientation" -> Top]IncludeMetaInformation (1)
By default, all available metadata is exported:
image = [image];Export["test.tif", image]Options[Import["test.tif"], MetaInformation]//ShortSpecify the metadata to include:
Export["test.tif", image, IncludeMetaInformation -> "Exif"]Options[Import["test.tif"], MetaInformation]//ShortExport["test.tif", image, IncludeMetaInformation -> None]Some metadata may automatically get generated:
Options[Import["test.tif"], MetaInformation]//Short"QuantizationMethod" (1)
RasterSize (1)
By default, the image is exported in the full resolution:
i = [image];ImageDimensions[i]Export["test.tif", i]Import[%, "RasterSize"]Specify the raster size of the exported image:
Export["test.tif", i, RasterSize -> 47]Import[%, "RasterSize"]Tech Notes
Related Guides
History
Introduced in 1999 (4.0) | Updated in 2018 (11.3) ▪ 2020 (12.1) ▪ 2020 (12.2) ▪ 2022 (13.2) ▪ 2024 (14.1) ▪ 2026 (15.0)