Click or drag to resize

TiffFile Class

TiffFile is a class that allows access to a TIFF image file directly, without loading the image into memory. It represents a single TIFF document which can contain multiple pages.
Inheritance Hierarchy
SystemObject
  Atalasoft.Imaging.Codec.TiffTiffFile

Namespace:  Atalasoft.Imaging.Codec.Tiff
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public class TiffFile

The TiffFile type exposes the following members.

Constructors
  NameDescription
Public methodTiffFile
Creates a new TiffFile instance.
Top
Properties
  NameDescription
Public propertyImages
Gets the image collection that is part of this TiffFile.
Public propertyTolerateBadTiffStructure
Gets or sets a value indicating whether to accept truncated tiff files or not.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic memberGetPageCount
Returns the number of pages in a TIFF
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnError
Fires the Error event
Public methodRead(Stream)
Reads directories and tags for all pages.
Public methodRead(Stream, Int32)
Reads directories and tags for a specific page.
Public methodSave(Stream)
Saves the TiffFile to a Stream.
Public methodSave(String)
Saves the TiffFile to a file path.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
  NameDescription
Public eventCodecError
This event is used by the TiffFile object to report errors that occur when parsing a TiffDirectory.
Top
Examples
Add an arbitrary TIFF tag.
C#
TiffFile oneTiff = new TiffFile();
oneTiff.Read(inputStream);
// access a TiffDirectory
TiffDirectory image = oneTiff.Images[0];
// access TiffTagCollection
TiffTagCollection tags = image.Tags;
// add Tiff Tags (add copy-right)
tags.Add(new TiffTag(TiffTagID.Copyright, "DotImage"));
// add Tiff Tags
string datetime = "2005:07:26 09:31:23";
tags.Add(new TiffTag(TiffTagID.DateTime, datetime, TiffTagDataType.Ascii));
// save
oneTiff.Save(targetStream);
Demonstrates how to insert a page into an existing TIFF
C#
string sourceFileName = "1_multi.tif";
string tempFileName = "multi_.tif";

using (Stream fs = File.OpenRead(sourceFileName))
{
    TiffFile tFile = new TiffFile();
    tFile.Read(fs);
    using (TiffDirectory tImage = new TiffDirectory(new AtalaImage(100, 100, PixelFormat.Pixel24bppBgr),
        TiffCompression.JpegCompression))
    {
        tFile.Images.Insert(1, tImage);
        tFile.Save(tempFileName);
    }
}

File.Delete(sourceFileName);
System.IO.File.Move(tempFileName, sourceFileName);
See Also