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

Free Support Forum - aspose.com

No option to fix the color depth in imaging

Hi,

I am trying to convert Image to tiff but we would like to convert it to some specific color depth: ex 8bppRGB.
I could not find any option for that. It takes automatic bit depth but we want to fix that due to some legislation. Please let us know any option for that or any workaround?

aa.zip (43.9 KB)

@atyagi39

Can you please share the output file with error along with used sample code. Please also share that which Aspose.Imaging version you have used on your end.

Here is our code. And there is no error in output. Only thing is that output tiff is of 24 bit depth. We need bit depth of 8 but there is no option to set it.
using (var image = Aspose.Imaging.Image.Load(fileDetail.FileInfo.FullName))
{
var options = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffLzwRgb);
options.ResolutionSettings = new Aspose.Imaging.ResolutionSetting(300, 300);
image.Save(fileDetail.OutputPath, options);
}

@atyagi39

We are checking this on our end and will share the feedback with you soon.

Hi,

Any update on this? Can you tells us the status.

Hi @atyagi39, we have investigated issue and found, that Aspose.Imaging supports 8 bit per sample palette images, but it works incorrect. We prepared ticket IMAGINGNET-4924 and you’ll be able to convert after fix. Here is sample code that saves image in 8bpp tiff:

using (var image = (RasterImage)Aspose.Imaging.Image.Load(@"template.png"))
{
    TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);
    ResolutionSetting res = new ResolutionSetting(300, 300); // 300 x 300 DPI
    outputSettings.BitsPerSample = new ushort[] { 8 };
    outputSettings.Compression = TiffCompressions.Lzw;
    outputSettings.Photometric = TiffPhotometrics.Palette;
    outputSettings.Palette = ColorPaletteHelper.Create8Bit();
    outputSettings.ResolutionSettings = res;

    image.Save(@"output.tiff", outputSettings);
}