Click here to Skip to main content
11,922,026 members (38,113 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
I am looking for some tools that will allow me to create a TIFF document and then save it to a folder. If there isn't any built in tools, please recommend an add-on package.

Thank you
Posted 12-Feb-13 13:02pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

.Net does not have great tools for handling the TIFF format built in, at work we use LibTiff.Net[^], which is free and open-source.
Sergey Alexandrovich Kryukov 12-Feb-13 18:34pm
Sure, a 5.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I actually started to look t this last week but couldn't get any support ( which I can understand since it's free). I am looking to create a laboratory report. In one of their examples they build a bridge.

using BitMiracle.LibTiff.Classic;
namespace WriteTiff
    class Program
        static void Main(string[] args)
            byte[] buffer = new byte[25 * 144]
                // boring hex omitted
            // Open the TIFF file
            using (Tiff image = Tiff.Open("output.tif", "w"))
                if (image == null)
                    System.Console.Error.WriteLine("Could not open output.tif for writing");
                // We need to set some values for basic tags before we can add any data
                image.SetField(TiffTag.IMAGEWIDTH, 25 * 8);
                image.SetField(TiffTag.IMAGELENGTH, 144);
                image.SetField(TiffTag.BITSPERSAMPLE, 1);
                image.SetField(TiffTag.SAMPLESPERPIXEL, 1);
                image.SetField(TiffTag.ROWSPERSTRIP, 144);
                image.SetField(TiffTag.COMPRESSION, Compression.CCITTFAX4);
                image.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISWHITE);
                image.SetField(TiffTag.FILLORDER, FillOrder.MSB2LSB);
                image.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
                image.SetField(TiffTag.XRESOLUTION, 150.0);
                image.SetField(TiffTag.YRESOLUTION, 150.0);
                image.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.INCH);
                // Write the information to the file
                image.WriteEncodedStrip(0, buffer, 25 * 144);
                // file will be auto-closed during disposal
                // but you can close image yourself

Let's say I want to create a TIFF file that contains says "Hello World" in bold. Can you please supply an example of how I would code this with LibTiff?

Thank you.
lewax00 12-Feb-13 19:11pm
It's in an example that isn't obvious, but check: it shows how to render strings onto it. In the future, if you need clarification on an answer, please use the "Have a Question or Comment?" button below the answer it's in reference too, otherwise that person will not get a notification (I only checked back because I had a new comment from someone else). It works out better for everyone that way :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 493
1 Dave Kreskowiak 285
2 Sergey Alexandrovich Kryukov 243
3 Richard MacCutchan 155
4 ppolymorphe 135
0 OriginalGriff 7,231
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,356
3 George Jonsson 2,865
4 Suvendu Shekhar Giri 2,216

Advertise | Privacy | Mobile
Web02 | 2.8.151120.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100