Click here to Skip to main content
Click here to Skip to main content

A simple TIFF management class

, 15 Dec 2004
Rate this:
Please Sign up or sign in to vote.
Using GDI+ to parse TIFF files.


Compared to legacy GDI, the GDI+ that comes with .NET framework is a lot more powerful. This article describes a very simple class that will be used to parse the multi-page TIFF files. The operations include split, join and convert TIFF compression encoder.

Using the code

For those of you playing with fax or OCR software, you might be bored with the various TIFF encoder formats. EncoderValue provided by GDI+ contains most of the compression encoder information that applies to an image. By default, the images saved with Image.Save() are using the LZW encoder while most of the fax software in the market use CCITT standard. Therefore, you should consider carefully when you are dealing with a TIFF image. Nearly all the methods in the TiffManager provide an encoder parameter to handle the encoding part.

/// <summary>
/// This function will output the image
/// to a TIFF file with specific compression format
/// </summary>
/// <param name="outPutDirectory">
///     The splited images' directory</param>
/// <param name="format">The codec for compressing</param>
/// <returns>splited file name array list</returns>
public ArrayList SplitTiffImage(string outPutDirectory,EncoderValue format)
  string fileStartString = outPutDirectory + "\\" + 
  ArrayList splitedFileNames=new ArrayList();
    Guid objGuid=image.FrameDimensionsList[0];
    FrameDimension objDimension=new FrameDimension(objGuid);

    //Saves every frame as a separate file.
    Encoder enc=Encoder.Compression;
    int curFrame=0;
    for (int i=0;i<_PageNumber;i++)
      EncoderParameters ep=new EncoderParameters(1);
      ep.Param[0]=new EncoderParameter(enc,(long)format);
      ImageCodecInfo info=GetEncoderInfo("image/tiff");

      //Save the master bitmap
      string fileName=string.Format("{0}{1}.TIF", 
             fileStartString, i.ToString());
  catch (Exception)

  return splitedFileNames;

The various signatures of the TiffManager are listed below:

public void ConvertTiffFormat(string strNewImageFileName, 
                              EncoderValue compressEncoder);
public Image GetSpecificPage(int pageNumber);
public void JoinTiffImages(string[] imageFiles, string outFile, 
                           EncoderValue compressEncoder);
public void RemoveAPage(int pageNumber, EncoderValue compressEncoder, 
                        string strFileName);
public ArrayList SplitTiffImage(string outPutDirectory, EncoderValue format);

Points of Interest

This is really a simple TIFF handling class. You can dive deeper by implementing resolution conversions etc.


  • Dec.15, 2004.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
Trying to be a .NET developer

Comments and Discussions

Generalthanks Pinprofessionalhansoctantan14-Apr-14 4:27 
SuggestionGetting error while deleting sptitted images PinmemberMember 1005124617-Mar-14 3:55 
Questioncombine two multipage page tiff in single multipage Tiff Pinmemberarventh14-Mar-12 21:14 
AnswerRe: combine two multipage page tiff in single multipage Tiff PinmemberdavH16-Apr-12 6:43 
GeneralMy vote of 5 Pinmembertyagu_anaykus12-Mar-12 6:54 
QuestionDiscovering image disk size PinmemberMember 859395730-Jan-12 12:27 
I am attempting to discover the formatted image size before it is written to the disk. The reason behind this is to limit the file size of the combined .tiff file.
Does anyone have an idea on how to do this? My initial thoughts were to create a MemoryStream and continually write the compressed images to this.
QuestionWhich EncoderValue to be used for SpllitTiffImage PinmemberRupeshNYadav15-Jul-11 2:24 
AnswerRe: Which EncoderValue to be used for SpllitTiffImage PinmemberCheery_an12-Jul-12 20:20 
AnswerCool!! PinmemberPalle Hansen26-Apr-11 3:21 
GeneralI want to write it response.write Pinmemberrajendra Kulkarni21-Jun-10 16:44 
GeneralNonsense, it can do nothing PinmemberFrenet27-Mar-09 18:02 
QuestionHow to use the code? Pinmember_rush_29-Dec-08 23:36 
GeneralProblem reading TIFF Imagees Pinmembermalkowitz7-Dec-08 22:23 
GeneralRe: Problem reading TIFF Imagees [modified] PinmemberJason Vogel9-Dec-08 9:15 
QuestionRe: Problem reading TIFF Imagees Pinmemberahmarshi5-Feb-09 5:44 
AnswerRe: Problem reading TIFF Imagees [modified] Pinmemberckcool26-May-09 21:52 
QuestionCan C# read geoTiff file? PinmemberFrank Meng14-Sep-07 20:22 
GeneralRe: Can C# read geoTiff file? PinmemberWill Wayne25-Mar-08 12:54 
Questioni cant't merge MultiFrame tif? Pinmemberjackiehali22-Nov-06 20:13 
AnswerRe: i cant't merge MultiFrame tif? PinmemberExcise14-Nov-07 9:17 
AnswerRe: i cant't merge MultiFrame tif? PinmemberWill Wayne25-Mar-08 13:14 
GeneralGetFileNameStartString have a bug. PinmemberFreddy Hernandez22-Nov-06 5:12 
QuestionFind out compression type of TIFF file? PinmemberGiGgZ17-Feb-06 7:15 
AnswerRe: Find out compression type of TIFF file? Pinmemberparagp14-Sep-06 5:42 
GeneralRe: Find out compression type of TIFF file? PinmemberMichael Epner18-Sep-06 7:57 
GeneralRe: Find out compression type of TIFF file? PinmemberVelislavG13-Jul-07 4:09 
GeneralRe: Find out compression type of TIFF file? PinmemberH@is@here28-Sep-07 2:34 
GeneralRe: Find out compression type of TIFF file? PinmemberWill Wayne25-Mar-08 13:19 
GeneralRe: Find out compression type of TIFF file? PinmemberAlan Burkhart3-Aug-09 15:46 
GeneralRe: Find out compression type of TIFF file? PinmemberH@is@here4-Aug-09 3:25 
AnswerRe: Find out compression type of TIFF file? Pinmembermaxxnostra20-May-08 9:59 
GeneralDispose() error when image left unassigned PinsussArjo Kalisvaart19-Aug-05 1:05 
General16bpp tiff greyscale PinmemberNiles Davis1-Aug-05 1:59 
GeneralGeneral GDI error PinmemberPhilip W15-Jul-05 5:18 
GeneralRe: General GDI error PinmemberPhilip W30-Aug-05 23:15 
GeneralRe: General GDI error PinmemberNotProfessional15-Sep-05 17:08 
GeneralRe: General GDI error PinmemberStephanGreiwe17-May-06 3:07 
GeneralRe: General GDI error PinmemberMember 296928311-Feb-09 8:59 
GeneralRe: General GDI error Pinmemberrohitmahadik8-Jul-10 1:09 
GeneralRe: General GDI error Pinmemberrajendra Kulkarni21-Jun-10 16:47 
Generalgood information &amp; nice article Pinmemberjdalberg22-Feb-05 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 15 Dec 2004
Article Copyright 2004 by NotProfessional
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid