I am trying to figure out a way to crop large TIFF images in .NET. Specifically, I am trying to do this operation on a GeoTiff, a TIFF that allows georeferencing information to be embedded within itself. For those unfamiliar with this type of dataset, it is fully compliant with TIFF 6.0 and is usually huge in size; many times in the gigabyte range.
I've been messing around with the System.Windows.Media.Imaging namespace to try to accomplish this task. However, the size of the tiff to be cropped causes out of memory errors. Can anyone point me to some information showing how to crop an image without reading input image into memory at the onset?
FYI - I am fully aware that GDAL is more than capable for this task. However, without getting into unecessary details, deploying GDAL with my app is not an option at this point for several reasons, hence my desire to do this with native .NET classes. However, if there are other 3rd party .NET libraries that could be of use, I'm all ears.
Have a look at libtiff. You want to load the image by scanlines (or by strips, if that's how the image is formatted). Obviously, you still need enough memory to hold an entire scanline (or strip), but it's way more feasible than loading the entire image into memory.
There seems to be a .NET version of the library, and it looks like it's free and open source (unlike some of their other apps).