Tiff Converts to Bitonal on Save

I am attempting to manipluate a bmp and save as a tiff with some modifications like size, dpi, and color/b&w/grayscale.
B&W and grayscale are working fine but when choosing the color, it always saves black and white (bitonal).

Here is the code block. I can confirm that filepath is indeed a color bitmap image file. Thank you.

RasterImage img = (RasterImage)Aspose.Imaging.Image.Load(filepath);

            int newWidth = img.Width;
            int newHeight = img.Height;

            if (newWidth > _tiffParameters.MaxWidth)
                newWidth = _tiffParameters.MaxWidth;
            if (newHeight > _tiffParameters.MaxHeight)
                newHeight = _tiffParameters.MaxHeight;


            if(newWidth != img.Width)
                img.Resize(_tiffParameters.MaxWidth, _tiffParameters.MaxHeight);

            TiffOptions options = new TiffOptions(TiffExpectedFormat.Default);
            
            options.Xresolution = new TiffRational((uint)_tiffParameters.Dpi);
            options.Yresolution = new TiffRational((uint)_tiffParameters.Dpi);
            options.ResolutionUnit = TiffResolutionUnits.Inch;

            if (_tiffParams.ColorScale == ColorScale.BITON)
                options.Palette = ColorPaletteHelper.CreateMonochrome();
            else if (_tiffParams.ColorScale == ColorScale.GRAYS)
                options.Palette = ColorPaletteHelper.Create4BitGrayscale(false);
            
            String newFilePath = filepath.Replace(pathReplace, pathValue);

            if(!Directory.Exists(Path.GetDirectoryName(newFilePath)))
                Directory.CreateDirectory(Path.GetDirectoryName(newFilePath));
            

            using (TiffImage tiffImage = new TiffImage(new TiffFrame(img)))
            {

                tiffImage.Save(newFilePath, options);
            }

@bbarbermetasource

Can you please share the source TIFF file along with generated output on your end so that we may investigate that further on our end to help you out.

It comes in as the 1-orig.bmp and outputs as a black and white tiff (1.tiff)

1.zip (488.4 KB)

@bbarbermetasource

We need to investigate the issue further on our end. A ticket with ID IMAGINGNET-4676 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Any progress here?

@bbarbermetasource

We have investigated the issue on our end and observed that the specified behavior of the library is not an error. The API has performed as desired.

The following code specifies exactly the format to be received : The default tiff format is no compression with B/W 1 bit per pixel only format.

TiffOptions options = new TiffOptions(TiffExpectedFormat.Default);

You can refer to following documentation for further reading:
https://reference.aspose.com/imaging/net/aspose.imaging.fileformats.tiff.enums/tiffexpectedformat

In order to change the tiff output format, it is not enough to simply set the palette. You need to set several parameters at once: Compression, Photometric, BitsPerSample, and sometimes AlphaStorage.

In order not to understand all of them, TiffExpectedFormat profiles were invented, which configure the necessary options.

Please use the suggested code:

using (RasterImage img = (RasterImage)Aspose.Imaging.Image.Load(filepath))
{
    int newWidth = img.Width;
    int newHeight = img.Height;

    if (newWidth > _tiffParameters.MaxWidth)
        newWidth = _tiffParameters.MaxWidth;
    if (newHeight > _tiffParameters.MaxHeight)
        newHeight = _tiffParameters.MaxHeight;

    if(newWidth != img.Width)
        img.Resize(_tiffParameters.MaxWidth, _tiffParameters.MaxHeight);

    TiffOptions options;

    if (_tiffParams.ColorScale == ColorScale.BITON)
    {
        options = new TiffOptions(TiffExpectedFormat.Default);
        options.Palette = ColorPaletteHelper.CreateMonochrome();
    }
    else 
    {
        options = new TiffOptions(TiffExpectedFormat.TiffLzwRgb); // for example, or any other format
    }

    if (_tiffParams.ColorScale == ColorScale.GRAYS)
    {
        options.Palette = ColorPaletteHelper.Create4BitGrayscale(false);
    }

    options.Xresolution = new TiffRational((uint)_tiffParameters.Dpi);
    options.Yresolution = new TiffRational((uint)_tiffParameters.Dpi);
    options.ResolutionUnit = TiffResolutionUnits.Inch;

    String newFilePath = filepath.Replace(pathReplace, pathValue);

    if(!Directory.Exists(Path.GetDirectoryName(newFilePath)))
        Directory.CreateDirectory(Path.GetDirectoryName(newFilePath));

    img.Save(newFilePath, options);
}