I'm looking for a library that can open and copy sections of a large TIFF file. I've looked at LibTiff.Net which opens the file very quickly but it doesn't have any functions for cropping or copying sections of the image. My image is 100,000 x 100,000 pixels upwards and creating a System.Drawing.Bitmap
of that size crashes the application so converting to a Bitmap
first is not an option.
Can anyone recommend a .NET library?
If your file is less than 4GB on disk than I recommend you to take another look at LibTiff.Net. Even with such large images you have some options.
First of all, check whether your image is tiled or stripped.
Tiff.IsTiled
method will give you the answer.If your image is tiled, than you probably shouldn't read it using
ReadScanline
method. It might be better to useReadEncodedTile
method in that case.If your images is stripped, than you can use
ReadScanline
andReadEncodedStrip
methods to read it.If you want to use something that expects
System.Drawing.Bitmap
than try usingReadRGBATile
orReadRGBAStrip
. These methods can be used to create bitmaps from portions of your image. There is no sample for this, but Convert color TIFF to a 32-bit System.Drawing.Bitmap should give you almost all required information about how to convert tile or strip of an image to a bitmap.EDIT:
LibTiff.Net 2.4.508 adds support for BigTiff so files larger than 4GB are also supported.