Reviewing TIFF options in detail

nnevod

Dmitry Matuzko

Posted on November 14, 2018

Reviewing TIFF options in detail

Aspose.Imaging uses ImageOptionsBase-based objects to set up file formats when saving or creating images. TIFF format, as such, is configured via instances of TiffOptions class. As I've noted in previous article, TiffOptions can also be read from loaded image, so you can get information about format's settings for the particular file. Most of the properties of TiffOptions apply to indivitual TiffFrames, with only few properties related to TiffImage as a collection of TiffFrames. Given multi-image nature of TIFF, I will refer to whole TIFF, represented as TiffImage as "file", and to individual images within, represented as TiffFrame, as "image" or "page".

TiffOptions provides facility to set up TIFF file format as you need. Most of the often used options are supported explicitly and are availible as properties. Changes applied to them will result in according processing of the image data, if needed. TiffOptions also provides a way of working directly with TIFF tags, so anything not explicitly supported by Aspose.Imaging can also be worked upon.

Here I will first describe the properties of TiffOptions, and after them I'll describe the TIFF-specific methods of TiffOptions, they are related to direct access to tag data.

Properties

Here are descriptions of explicitly availible properties specific to TiffOptions, roughly grouped by their scope

Metadata

Artist

Person who created the image.

Copyright

Copyright notice.

DateTime

Date and time of image creation.

DocumentName

The name of the document from which this image was scanned.

ExifIfd

Pointer to EXIF IFD of the TIFF file.

FileStandard

Either TIFF 6.0 Baseline or TIFF 6.0 Extended.

ImageDescription

The title of the image - comment or such. No 2-byte characters allowed.

InkNames

Names of the inks used in this image. Inks are colors of Separate photometric model.

PageName

Name of the page from which this image was scanned.

PageNumber

Page number of the page from which this image was scanned.

ScannerManufacturer

Name of the manufacturer of the scanner used to scan this image.

ScannerModel

Model of the scanner used to scan this image.

SoftwareType

Name and version of software that created this image (or firmware if created by hardware).

TargetPrinter

Description of the supposed printing environment.

XmpData

Metadata in XMP format, represented as XmpPacketWrapper (Aspose.Imaging API object to work with XMP metadata)

Dimension and positioning data

Orientation

Rotation and mirroring of the image.

ResolutionUnit

Resolution unit for the image - inch, centimeter etc.

Xposition

Offset of the left side of the image from the left side of the page it's on.

Xresolution

Resolution in pixels per resolution unit along horizonal axis.

Yposition

Offset of the top side of the image from the top side of the page it's on. TIFF's Y axis is downward, so this is positive value.

Yresolution

Resolution in pixels per resolution unit along vertical axis.

Image format

AlphaStorage

Defines how alpha is stored - premultiplied or not. Used when there are more than 3 samples per pixel.

BitsPerPixel

Amount of bits constituting data for single pixel, calculated from BitsPerSample and SamplesPerPixel.

BitsPerSample

Number of bits per color component. This is an array, as each component can have different bit count. When this is set, SamplesPerPixel will be set to array's length.

ByteOrder

This is a per-file setting, not per-image, describes endianness of the file.

Compression

Compression method used for image raster data.

FaxT4Options

Options for Group 3 Fax compression (T4) - 1D compression, 2D compression, no compression, or filling bits to byte boundaries (expanding data size).

FillOrder

Order of bits within bytes

IsExtraSamplesPresent

True if there are more samples in SamplesPerPixel than required by photometric setting.

IsTiled

True for tiled images. Large TIFF images are often split into tiles, which can reduce memory use when only part of the image has to be displayed/processed at once.

Photometric

Color space of the image data. BW with minimum as white, BW with minimum as black, RGB, paletted color, transparency mask (obsolete in TIFF v6.0), separate colors (typically used for CMYK), YCbCr, Cielab, Icclab, Itulab, Logl and Logluv are supported by Aspose.Imaging.

PlanarConfiguration

Describes wether colors are stored on separate planes or interleaved.

Predictor

Predictor for LZW compression - either none, or hozirontal difference.

SampleFormat

Numeric format of the sample - unsigned integer, signed integer, floating point, untyped, complex integer, complex floating point. Separate for each component.

SamplesPerPixel

Number of color components per pixel.

SubFileType

Type of data stored in subfile. Either just an image, thumbnail for another image in file, page, transparency mask or MRC image.

YCbCrCoefficients

Coefficients for transformation of RGB data to YCbCR.

YCbCrSusbsampling

Subsampling used for YCbCr image data.

Image data layout

It is closely related to image format, as it also outlays how raster data is located in file.

ImageLength

Height of the image in pixels as stated in TIFF tag.

ImageWidth

Width of the image in pixels as stated in TIFF tag.

RowsPerStrip

TIFF images can be organised into strips for faster IO and easier random access. This tag describes count of rows (lines) of image in single strip. Total count of strips per image can be calculated as follows: StripsPerImage = floor ((ImageLength + RowsPerStrip - 1) / RowsPerStrip).

StripOffsets

Offsets of the strips constituting the image, relative to beginning of file. This is used to locate actual image data in file, unless tiling is used, then TileOffsets is used.
It is recommended to keep array below 64k bytes in length, and keep strips below 64k bytes each as well.

StripByteCounts

Number of bytes in strips after compression.

TileWidth

Width of a tile in pixels (number of columns in a tile).
Horizontal, vertical and total tile counts can be calculated as follows:
TilesAcross = (ImageWidth + TileWidth - 1) / TileWidth
TilesDown = (ImageLength + TileLength - 1) / TileLength
TilesPerImage = TilesAcross * TilesDown.
Must be multiple of 16. Might be larger than ImageWidth, but this means either tiles are too large, or image is too small, so tiling is not optimal

TileLength

The tile length (height) in pixels. This is the number of rows(lines) in each tile. Must be a multiple of 16.

TileOffsets

Offsets of tiles in file, relative to beginning of file. Tiles are ordered left-to-right and top-to-bottom. If planar configuration is used, first series of offsets point to tiles of first component plane, then second series for second plane etc, so total count of offsets is total count of tiles multiplied by samples per pixel.

TileByteCounts

Count of bytes in tile after compression.

Color profiling and processing

ColorMap

Palette used for the image if it is paletted, as stored in file. Palette property is already loaded and processed palette. Length must correspond to formula: 3*(2^BitsPerSample).

IccProfile

Stream of color profile embedded in the image.

HalfToneHints

Values to control halftone function.

MaxSampleValue

Maximum allowed sample value in image, per each channel. 16-bit version.

MinSampleValue

Minimum allowed sample value in image, per each channel. 16-bit version.

PremultiplyComponents

Wether components must be premultiplied by color profile data.

SmaxSampleValue

Maximum allowed sample value in image, per each channel. 32-bit version.

SminSampleValue

Minimum allowed sample value in image, per each channel. 32-bit version.

Threshholding

Describes method used to convert grayscale images to BW.

Tag data

IsValid

True if this TiffOptions instance is validly formed, as some options might be conflicting. Use Validate() method to see errors.

Tags

Actual TIFF tags in "raw" form.

ValidTagCount

Count of valid TIFF tags in image, i.e. tags, that can be saved.

Whole file-related properties

ByteOrder

Repeating here, as it is actually TiffImage related - the only format property that is set for the whole file, not in pages's tags.

TotalPages

Just the count of pages in document, as such, is read-only, as it is changed when you add or remove pages.

Methods

Here are descriptions of TiffOptions-specific methods, mostly working with "raw" tags. Tags are stored as instances of descendants of TiffDataType class, they provide access to tag ID, type and value within the tag. Known tag ID list is availible as TiffTags enum.

AddTag

Adds new tag to image.

AddTags

Adds an array of tags to the image.

GetTagByType

Returns instance of tag by tag's ID, or null if no such tag is present.

GetValidTagCount

Returns count of valid tags in provided array of tags.

IsTagPresent

Checks if image contains tag with specified tag ID.

RemoveTag

Removes tag by tag ID.

Validate

Checks if combination of tags in this TiffOptions is valid.

That's all for now, stay tuned!

For more examples please visit the Aspose.Imaging GitHub page. There's also Twitter and Facebook pages for news on Aspose.Imaging.

💖 💪 🙅 🚩
nnevod
Dmitry Matuzko

Posted on November 14, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Reviewing TIFF options in detail
csharp Reviewing TIFF options in detail

November 14, 2018