On Tue, 18 Nov 2008 06:02:28 -0800, GiJeet <gi****@yahoo.comwrote:
Hello, we have an app that scans documents into TIFF format and we
need to transfer them over the internet. If anyone knows of a SDK we
can use that can compress TIFFs on the fly or even if it can compress
them so they take up less space on the server, would be appreciated.
Actually any info on handling tiff files programatically would be
appreciated as I know very little about tiffs.
What kind of compression are you looking for?
You can use the GzipStream class to compress arbitrary data. But,
depending on your original TIFF, it may not compress much, if at all.
That is, if it's already in a compressed form (TIFF supports a variety of
compression methods), additional compression may not help, and even if
it's not, GzipStream isn't optimized for image compression.
You can use the classes in the System.Drawing.Imaging namespace to do
things like read the TIFF in as an Image instance and then save that Image
instance back to a file or stream in a different format. If the format
has to remain as a TIFF, your ability to compress it may be limited or
non-existent, unless it's permissible to actually change the image
itself. In that case, you could "compress" the image simply by reducing
its resolution, by creating a smaller Bitmap instance and copying the
original to the smaller one before saving it from the smaller one (halving
each dimension will result in a 4x reduction in size simply from that
process alone).
If the format doesn't need to remain as TIFF, then you also can try using
PNG (lossless) or JPEG (lossy) output. Unfortunately, .NET doesn't have
much elaborate support for PNG and so you won't necessarily get the
optimal compression out of it, but at least it will do some compression.
With JPEG you can control the compression/quality setting, which as long
as it's permissible to modify the image data in the process of compression
can produce very good compression results.
But first, you need to figure out what it means to "compress" the data and
what requirements you have with respect to preserving the original image
data.
Pete