We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Resample .tiff image (24bpp) to 8bpp


for archiving documents (.tiff scans) in a document management system I would like to “normalize” them prior to uploading to have only 8bpp rgb palette. This is also to save some space.

I just cannot get this to work.

Currently I’m using something like this:

var outputSettings = new TiffOptions();
outputSettings.BitsPerSample = new ushort[]{ 4 };
outputSettings.ImageDescription += " (processed)";
outputSettings.Photometric = TiffPhotometrics.MinIsWhite;
outputSettings.Compression = TiffCompressions.Lzw;

This is of course something else entirely. But for some reason I just cannot figure out the correct settings for 8bit color images.

Any hints?

Best regards,

Hi Steviee,

Thank you for contacting Aspose support.

What we understand your problem description, you probably wish to convert the images to Gray Scale. Please check the following piece of code that we have tested on our end while using the latest version of Aspose.Imaging for .NET 2.4.0. Also attached are the input and output file for your reference.


byte[] stream = System.IO.File.ReadAllBytes(myDir + “koala.jpg”);
MemoryStream memstream = new MemoryStream(stream);
Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(memstream);

Aspose.Imaging.ImageOptions.TiffOptions options = new Aspose.Imaging.ImageOptions.TiffOptions();
options.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Lzw;
options.BitsPerSample = new ushort[] { 8 };
options.Photometric = TiffPhotometrics.MinIsBlack;
options.ImageDescription += " (processed)";

image.Save(myDir + “output.tif”, options);

We suggest you to please check out the TiffOptions Configurations for better elaboration on this topic. In case you face any difficulty, please feel free to write back any time.


thank you for your answer. My “task” is to nomalize all images sent to us into the same format, that’s not that much of a disk-space-eater and to have it compatible with Java JAI (for legacy reasons).

Is there a way to quantize the images to some color format also? At least if the incoming file is not a grayscale file?

Best regards,

Hi Steviee,

Thank you for writing back.

The source code shared in my previous response is actually performing the Color Quantization on the input image by reducing the number of color channels. You may see from the attached io.zip that the input image has RGB (3 channel colors) whereas the result is a grryscale with single channel.

Please feel free to write back in case you have any ambiguity.