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.0.0.0.0.297 (.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.

AddCS (C#)
// open a TiffFile 
TiffFile oneTiff = new TiffFile();
oneTiff.Read(streamOne);
// access a TiffDirectory
TiffDirectory image = oneTiff.images[0];
// access TiffTagCollection
TiffTagCollection tags = image.Tags;
// add Tiff Tags (add copy-right)
Tags.Add(33432, "DotImage");
// add Tiff Tags
string datetime = "2005:07:26 09:31:23";
Tags.Add(306, datetime, TiffTagDataType.Ascii);
// save
oneTiff.Save(targetStream);
addVB (Visual Basic)
' open a TiffFile 
Dim oneTiff As TiffFile = New TiffFile()
oneTiff.Read(streamOne)
' access to a TiffDirectory
Dim image As TiffDirectory = oneTiff.images(0) 
' access to TiffTagCollection
Dim tags As TiffTagCollection = image.Tags 
' add Tiff Tags (add copy-right)
Tags.Add(33432, "DotImage")
' add Tiff Tags
Dim datetime As String = "2005:07:26 09:31:23" 
Tags.Add(306, datetime, TiffTagDataType.Ascii)
' save
oneTiff.Save(targetStream)

Demonstrates how to insert a page into an existing TIFF

InsertPageCS (C#)
using (Stream fs = new FileStream("1_multi.tif", FileMode.Open, FileAccess.Read, FileShare.Read))
{
    TiffFile tFile = new TiffFile();
    tFile.Read(fs);
    TiffDirectory tImage = new TiffDirectory(
        new AtalaImage(100, 100, PixelFormat.Pixel24bppBgr), 
        TiffCompression.JpegCompression);
    tFile.Images.Insert(1, tImage);
    tFile.Save("multi_.tif");
}
File.Delete("multi.tif");
System.IO.File.Move("multi_.tif", "multi.tif");
InsertPageVB (Visual Basic)
Dim fs As Stream = New FileStream("1_multi.tif", FileMode.Open, FileAccess.Read, FileShare.Read)
Dim tFile As TiffFile =  New TiffFile() 
tFile.Read(fs)
Dim tImage As TiffDirectory = New TiffDirectory( _
        New AtalaImage(100, 100, PixelFormat.Pixel24bppBgr), _
        TiffCompression.JpegCompression)
tFile.Images.Insert(1, tImage)
tFile.Save("multi_.tif")
File.Delete("multi.tif")
System.IO.File.Move("multi_.tif", "multi.tif")
See Also

Reference

TiffFile Overview