Many Quality Issues in Black & White Image Generation

Hello Aspose Team

We Faced Too many quality issues In Black & White Image Generation for products (Cell, Slide, Pdf). So Please provide a solution As a priority.

  1. Cell
    Consider Bellow Screes sort to understand the problem.
    Excel.png (218.2 KB)

Sample Code

Aspose.Cells.License cellLicense = new Aspose.Cells.License();
cellLicense.SetLicense("Aspose.Total.NET.lic");

Workbook _workbook = new Workbook(new FileStream(@"Sub Process Batches.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite));

Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.HorizontalResolution = 300;
options.VerticalResolution = 300;
options.ImageType = Aspose.Cells.Drawing.ImageType.Tiff;
options.SetDesiredSize(2550, 3100);
options.PrintingPage = PrintingPageType.IgnoreBlank;
options.TiffBinarizationMethod = Aspose.Cells.Rendering.ImageBinarizationMethod.Threshold;
options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionCCITT4;

for (int i = 0; i < _workbook.Worksheets.Count; i++)
{
    SheetRender sr = new SheetRender(_workbook.Worksheets[i], options);
    for (int j = 0; j < sr.PageCount; j++)
    {
        sr.ToImage(j, @"string.Format("_{0:" + "D6" + "}", i) + ".tiff");
    }
}

Required Files: Cell Quality Issue.zip (1.4 MB)

  1. Slide
    Consider Bellow Screes sort to understand the problem.
    Issue Explain.png (182.4 KB)

Sample Code

Aspose.Slides.License slidLicense = new Aspose.Slides.License();
slidLicense.SetLicense("Aspose.Total.NET.lic");

Presentation _document = new Presentation(new FileStream(@"Embedded Bluetooth.pptx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite));

Aspose.Slides.Export.TiffOptions options = new Aspose.Slides.Export.TiffOptions();
options.DpiX = 300;
options.DpiY = 300;
options.ImageSize = new System.Drawing.Size((int)(8.5 * 300), (int)(11 * 300));
options.CompressionType = Aspose.Slides.Export.TiffCompressionTypes.CCITT3;
options.ShowHiddenSlides = true;
_document.SlideSize.SetSize(SlideSizeType.Widescreen, SlideSizeScaleType.EnsureFit);
int[] slidIndex = new int[1];
for (int i = 0; i < _document.Slides.Count; i++)
{
    
    slidIndex[0] = i + 1;
    _document.Save(@"string.Format("_{0:" + "D6" + "}", i) + ".tiff"
                , slidIndex, Aspose.Slides.Export.SaveFormat.Tiff, options);
}

Required Files: PPT Quality Issue.zip (968.4 KB)

  1. PDF
    Consider Bellow Screes sort to understand the problem.
    Issue_1.jpg (247.4 KB)
    Issue_2.png (321.3 KB)

Sample Code

Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense("Aspose.Total.NET.lic");           
            
Aspose.Pdf.Document _document = new Aspose.Pdf.Document(new FileStream(@"GENERAL.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
TiffSettings options = new TiffSettings();
options.Compression = CompressionType.CCITT4;
Resolution resolutionObj = new Resolution(300);
TiffDevice tiffDevice = new TiffDevice(2550, 3100, resolutionObj, options);
for (int j = 1; j <= _document.Pages.Count; j++)
{
    try
    {
        using (FileStream imageStream = new FileStream(@"string.Format("_{0:" + "D6" + "}", j) + ".tif", FileMode.Create))
        {
            tiffDevice.Process(_document, j, j, imageStream);
            imageStream.Close();
        }
    }
    catch (Exception ex)
    { }
}

Required Files: Pdf Quality Issue.zip (2.3 MB)

Note: we must require compression, resolution, and Size.

@hemalp,

  1. I tested your scenario/case regarding Aspose.Cells using your template Excel file and found the quality issue with the output images. I guess this is due to CCITT4 compression type which may not render graphics or images fine. I think you should use other better compression types. For example, you may try using CompressionLZW which can give you good quality. Also, if you need to render images in black and white, you may also set BlackAndWhite Boolean attribute of worksheet’s PageSetup to true. So, it will give you your desired quality results. See the sample code segment for your reference.
    e.g.
    Sample code:
.......
            options.PrintingPage = PrintingPageType.IgnoreBlank;
            options.TiffBinarizationMethod = Aspose.Cells.Rendering.ImageBinarizationMethod.Threshold;
            options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionLZW;

            for (int i = 0; i < _workbook.Worksheets.Count; i++)
            {
                PageSetup pageSeup = _workbook.Worksheets[i].PageSetup;
                pageSeup.BlackAndWhite = true;
                SheetRender sr = new SheetRender(_workbook.Worksheets[i], options);
                for (int j = 0; j < sr.PageCount; j++)
                {

                }
            }
......

Regarding your issues for Aspose.PDF and Aspose.Slides, our respective teams will evaluate the problems soon.

@hemalp,
As for Aspose.Slides, the CCITT3 compression type is only used for bitonal (black-and-white) images, whereas your expected output images contain gray pixels (so the text looks better). We cannot change the API for your requirements because it will no longer match the GDI parameters (Tiff encoder parameters). But you can use the ISlide.GetThumbnail method to create raster images from slides, and then convert the resulting bitmaps to TIFF with any set of parameters. I hope this will help you.

@hemalp

For Aspose.PDF, we have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55168

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@amjad.sahi
I already apply pageSeup.BlackAndWhite = true
but while applying CCITT4 the compression. It not work Properly like bellow Image
Excel.png (218.2 KB)

Required Files: Cell quality Issue.zip (20.7 KB)

Note: We can not apply LZW Compression, Because Some of the viewer technology have not support LZW compression.

-> You Need to implement ColorMode Property (Which is already Available in Aspose.Word)
options.ColorMode = ColorMode.Grayscale;

@andrey.potapov
The Reason for not Using GetThumbnail is we are not able to archive the CCITT4 compression to generate .tif file.
GetThumbnail Compression issue.png (9.7 KB)

Sample Code

Aspose.Slides.License slidLicense = new Aspose.Slides.License();
slidLicense.SetLicense("Aspose.Total.NET.lic");
var fs = new FileStream(@"Embedded Bluetooth.pptx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Presentation _document = new Presentation(fs);

Aspose.Slides.Export.TiffOptions options = new Aspose.Slides.Export.TiffOptions();
options.DpiX = 300;
options.DpiY = 300;
options.ImageSize = new System.Drawing.Size((int)(11 * 300), (int)(8.5 * 300));
options.CompressionType = Aspose.Slides.Export.TiffCompressionTypes.CCITT4;
options.ShowHiddenSlides = true;
_document.SlideSize.SetSize(SlideSizeType.Widescreen, SlideSizeScaleType.EnsureFit);
int[] slidIndex = new int[1];
for (int i = 0; i < _document.Slides.Count; i++)
{
    using (Bitmap bmp = _document.Slides[i].GetThumbnail(options))
    {
        bmp.Save(@"string.Format("_{0:" + "D6" + "}", i) + ".tif", System.Drawing.Imaging.ImageFormat.Tiff);
    }
}

Required Files: GetThumbnail Compression Issue.zip (296.9 KB)

-> You Need to implement ColorMode Property (Which is already Available in Aspose.Word)
options.ColorMode = ColorMode.Grayscale;

@hemalp,

As we found the issue regarding image quality you mentioned by using your sample Excel file so we will log a ticket for it. We need to evaluate your issue in details.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-53831

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Any Update On this point?

@hemalp

Your excepted result is actually a dithering result. You can get the result by setting:

options.TiffBinarizationMethod = Aspose.Cells.Rendering.ImageBinarizationMethod.FloydSteinbergDithering;

However, the performance is affected as you reported at this post.

@hemalp,

We will continue the discussion here: