This documentation is for the old version. Go to the latest Graphics Mill docs

TiffWriter Class

This class enables you to write TIFF images.

Namespace: Aurigma.GraphicsMill.Codecs
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public NotInheritable Class TiffWriter _
	Inherits FormatWriter _
	Implements IMetadataWriteSupport
C#
public sealed class TiffWriter : FormatWriter, IMetadataWriteSupport

Remarks

TIFF format is one of the most comprehensive image formats. It was designed to promote the interchange of digital image data. The general scenario TIFF format was invented for, assumes that scanning or painting software creates a TIFF file, which can then be read and incorporated into a document or publication by an application such as a desktop publishing package. It is also widely used to retrieve facsimile messages.

This image format is rather versatile and have a lot of modifications. It supports most Graphics Mill for .NET pixel formats even such exotic ones like Format80bppAcmyk. It also can store multiple images in the single file (mostly used for fax images and other documents stored as 1-bit bitmaps).

TIFF files can also contain Adobe® resources, XMP, EXIF and IPTC data.

Examples

You can use TiffWriter class instead of the Save(String, IEncoderOptions) method of the Bitmap. In particular it enables you to save the image asynchronously.

The TiffWriter class usage is demonstrated below:

Visual Basic
Dim dir As String = "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\"
Dim images As String() = {"Blue hills.jpg", "Sunset.jpg", "Water lilies.jpg", "Winter.jpg"}

Dim bitmap As New Aurigma.GraphicsMill.Bitmap

Dim writer As New Aurigma.GraphicsMill.Codecs.TiffWriter("C:\multipage.tif")

For Each image As String In images
    bitmap.Load(dir & image)

    Dim frame As New Aurigma.GraphicsMill.Codecs.TiffFrame
    frame.Compression = Aurigma.GraphicsMill.Codecs.CompressionType.Lzw
    frame.SetBitmap(bitmap)

    writer.AddFrame(frame)

    frame.Dispose()
Next

bitmap.Dispose()

writer.Dispose()
C#
string dir = @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\";
String[] images = {"Blue hills.jpg", "Sunset.jpg", "Water lilies.jpg", "Winter.jpg"};

using (Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap())
{
    using(Aurigma.GraphicsMill.Codecs.TiffWriter writer =
              new Aurigma.GraphicsMill.Codecs.TiffWriter(@"C:\multipage.tif"))
    {
        foreach (string image in images)
        {
            bitmap.Load(dir + image);

            using (Aurigma.GraphicsMill.Codecs.TiffFrame frame =
                       new Aurigma.GraphicsMill.Codecs.TiffFrame())
            {
                frame.Compression = Aurigma.GraphicsMill.Codecs.CompressionType.Lzw;
                frame.SetBitmap(bitmap);
                writer.AddFrame(frame);
            }
        }
    }
}

TIFF files can store EXIF and IPTC data blocks. Graphics Mill for .NET allows you extracting this data from the TIFF file and save it into another TIFF file (as well as into the other file format which supports EXIF and IPTC). This code sample demonstrates how to add the EXIF and IPTC data to the file:

Visual Basic
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg")
Dim writer As New Aurigma.GraphicsMill.Codecs.TiffWriter("C:\Mountain.tif")

'EXIF
Dim exif As New Aurigma.GraphicsMill.Codecs.ExifDictionary
exif(Aurigma.GraphicsMill.Codecs.ExifDictionary.Software) = "Aurigma Graphics Mill"

writer.Exif = exif

'IPTC
Dim iptc As New Aurigma.GraphicsMill.Codecs.IptcDictionary
iptc(Aurigma.GraphicsMill.Codecs.IptcDictionary.Category) = "Nature"
iptc(Aurigma.GraphicsMill.Codecs.IptcDictionary.CopyrightNotice) = "Aurigma Inc."
iptc(Aurigma.GraphicsMill.Codecs.IptcDictionary.Keyword) = "mountain"

writer.Iptc = iptc

'Adobe resource blocks
Dim adobeResources As New Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary
'Create new adobe image resource block with the required metadata
Dim arBlock As New Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", New Byte() {1})
'Set this block to the item with 0x040A ID (copyright flag)
adobeResources.Item(&H40A) = arBlock

writer.AdobeResources = adobeResources

'XMP
Dim xmp As New Aurigma.GraphicsMill.Codecs.XmpData()
'Create a node with the required metadata
Dim node As New Aurigma.GraphicsMill.Codecs.XmpValueNode( _
    Aurigma.GraphicsMill.Codecs.XmpNodeType.SimpleProperty, _
    "John Doe", _
    Aurigma.GraphicsMill.Codecs.XmpTagNames.DCCreator)
xmp.AddNode(node)

writer.Xmp = xmp.Save()

Dim frame As New Aurigma.GraphicsMill.Codecs.TiffFrame(50)

frame.SetBitmap(bitmap)

bitmap.Dispose()

writer.AddFrame(frame)

frame.Dispose()

writer.Dispose()
C#
using (Aurigma.GraphicsMill.Bitmap bitmap = 
           new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.jpg"))
{                
    using (Aurigma.GraphicsMill.Codecs.TiffWriter writer = 
               new Aurigma.GraphicsMill.Codecs.TiffWriter(@"C:\Mountain.tif"))
    {
        //EXIF
        Aurigma.GraphicsMill.Codecs.ExifDictionary exif =
            new Aurigma.GraphicsMill.Codecs.ExifDictionary();
        exif[Aurigma.GraphicsMill.Codecs.ExifDictionary.Software] = "Aurigma Graphics Mill";

        writer.Exif = exif;
    
        //IPTC
        Aurigma.GraphicsMill.Codecs.IptcDictionary iptc =
            new Aurigma.GraphicsMill.Codecs.IptcDictionary();
        iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.Category] = "Nature";
        iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.CopyrightNotice] = "Aurigma Inc.";
        iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.Keyword] = "mountain";

        writer.Iptc = iptc;

        //Adobe resource blocks
        Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary adobeResources =
            new Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary();
        //Create new adobe image resource block with the required metadata
        Aurigma.GraphicsMill.Codecs.AdobeResourceBlock arBlock = new
            Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", new byte[] { 1 });
        //Set this block to the item with 0x040A ID (copyright flag)
        adobeResources[0x040A] = arBlock;

        writer.AdobeResources = adobeResources;

        //XMP
        Aurigma.GraphicsMill.Codecs.XmpData xmp = new Aurigma.GraphicsMill.Codecs.XmpData();
        //Create a node with the required metadata
        Aurigma.GraphicsMill.Codecs.XmpValueNode node = new
            Aurigma.GraphicsMill.Codecs.XmpValueNode(
                Aurigma.GraphicsMill.Codecs.XmpNodeType.SimpleProperty,
                "John Doe",
                Aurigma.GraphicsMill.Codecs.XmpTagNames.DCCreator);
        xmp.AddNode(node);

        writer.Xmp = xmp.Save();

        using (Aurigma.GraphicsMill.Codecs.TiffFrame frame = 
                   new Aurigma.GraphicsMill.Codecs.TiffFrame(50))
        {
            frame.SetBitmap(bitmap);

            writer.AddFrame(frame);
        }
    }
}

Inheritance Hierarchy

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

Object Model








Supported Pixel Formats

Member NameDescription
Format1bppIndexed1 bit per pixel. Indexed.
Format4bppIndexed4 bits per pixel. Indexed.
Format8bppIndexed8 bits per pixel. Indexed.
Format8bppGrayScale8 bits per pixel. Grayscale. 8 bits are used for luminosity level.
Format16bppGrayScale16 bits per pixel. Grayscale. All 16 bits are used for luminosity level (extended pixel format).
Format16bppAGrayScale16 bits per pixel. Grayscale with alpha channel. 8 bits are used for alpha channel and other 8 bits are used for luminosity level.
Format32bppAGrayScale32 bits per pixel. Grayscale with alpha channel. 16 bits are used for alpha channel and other 16 bits are used for luminosity level (extended pixel format).
Format24bppRgb24 bits per pixel. RGB. 8 bits each are used for the red, green, and blue components.
Format32bppRgb32 bits per pixel. RGB. 8 bits each are used for the red, green, and blue components. The rest 8 bits are unused.
Format32bppArgb32 bits per pixel. RGB with alpha channel. 8 bits each are used for the alpha, red, green, and blue components.
Format48bppRgb48 bits per pixel. RGB. 16 bits each are used for the red, green, and blue components (extended pixel format).
Format64bppArgb64 bits per pixel. RGB with alpha channel. 16 bits each are used for the alpha, red, green, and blue components (extended pixel format).
Format32bppCmyk32 bits per pixel. CMYK. 8 bits each are used for the cyan, magenta, yellow, and black components.
Format40bppAcmyk40 bits per pixel. CMYK with alpha channel. 8 bits each are used for the alpha, cyan, magenta, yellow, and black components.
Format64bppCmyk64 bits per pixel. CMYK. 16 bits each are used for the cyan, magenta, yellow, and black components (extended pixel format).
Format80bppAcmyk80 bits per pixel. CMYK with alpha channel. 16 bits each are used for the alpha, cyan, magenta, yellow, and black components (extended pixel format).

See Also

Reference