Huge file size when converting color PDF to TIFF

Hello dear Aspose Support,

my problems with the converting of PDF to TIFF just never end.

I’m desperately trying to find a way to convert a color PDF file to TIF with the two pretty normal expectations:

  1. The quality of the PDF file contents remains visually the same. This means that it’s not an option to set the color depth to Format8bpp, because I’m getting a 256Bit color, which looks terrible. If I had the option to chose 16bpp then maybe everything would have been fine.

  2. The size of the generated TIFF file remains roughly the same as the PDF file or slightly larger, if that’s not possible.

What I have now is that my generated TIFF files are x15 larger than the original PDF files. By converting a < 2MB PDF file I’m getting a >33MB TIF file, which is very bad to say the least.

Is there a sensible way to convert PDF to TIFF with the above mentioned “logical” requirements?

I’m attaching a sample console application, which can be used to reproduce the problem. I’m currently working with the version 10.3.0.0 of Aspose.Pdf.dll.

Please add this dll to the Bin folder. Please add also the Aspose.Total.lic file in the Bin folder. Only then the sample application will work.

You will find in the sub folder “test_files” three test files. Rename please one of them to pdf.pdf and the test application will take this file and convert it to pdf.pdf.tif in the same folder.

As suggested in the live chat, I want to ask if this issue can be fixed quicker if we buy priority support. It’s meanwhile clear to me personally that there is no real chance that you fix it on self initiative.

Btw, please do consider that this case and also the case described in https://forum.aspose.com/t/31175

are not some weird special customer wishes. Both issues are core problems and I can’t imagine those issues are present in such a higher version of your product Aspose.Pdf.

I consider both issues a valuable feedback for the improving of your products.

Regards
Vasil Tonev

Hi Vasil

Thanks for your inquiry. Please note if you convert attached PDF to TIFF(colored) using Adobe Acrobat it will also generate TIFF file with almost same size with 24-bit image that Aspose.Pdf for PDF generates with Default(32-bit).

However to reduce the image size you need reduce the resolution along with other ColorDepth options. As a workaround you can post process the TIFF image with Aspose.Imaging for .NET. It will further reduce file size of TIFF.

Please check following code snippet, Aspose.Pdf for .NET generate almost 14MB TIFF of 2MB PDF document and Aspose.Pdf for .NET further reduces it to almost 8MB. Hopefully it will help you to accomplish the task.

var pdfDocument = new Aspose.Pdf.Document(sourceFilePath);

// Create TiffSettings object
var tiffSettings = new Aspose.Pdf.Devices.TiffSettings();
tiffSettings.Compression = preserveColors ? Aspose.Pdf.Devices.CompressionType.LZW : Aspose.Pdf.Devices.CompressionType.CCITT4;
tiffSettings.Depth = preserveColors ? Aspose.Pdf.Devices.ColorDepth.Default : Aspose.Pdf.Devices.ColorDepth.Default;
tiffSettings.SkipBlankPages = false;

Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(96);

MemoryStream ms = new MemoryStream();

// Create TIFF device
Aspose.Pdf.Devices.TiffDevice tiffDevice = new Aspose.Pdf.Devices.TiffDevice(resolution, tiffSettings);
tiffDevice.Process(pdfDocument, ms);

ms.WriteTo(new FileStream("E:/data/Pdf2Tiff.tiff", FileMode.Create));
ms.Position = 0;

using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(ms))
{
    // image.Dither(DitheringMethod.FloydSteinbergDithering, 1);
    using (MemoryStream tiffStream = new MemoryStream())
    {
        Aspose.Imaging.ImageOptions.TiffOptions tiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffDeflateRGB);
        tiffOptions.ResolutionSettings = new ResolutionSetting(96, 96);

        image.Save(tiffStream, tiffOptions);

        tiffStream.WriteTo(new FileStream("E:/data/Tiff2Tiff.tiff", FileMode.Create));
        tiffStream.Position = 0;
    }
}

Best Regards,

Hi Vasil,

Please note purchase of enhanced support increases issue precedence over normal support and development team start investigating the issue and plan its fix on priority basis. Purchasing paid support will definitely raise your issue priority but resolution or hotfix is subject to the complexity and priority of issue.

Thanks for your feedback. Yes, definitely customer feedback help us to improve our Products.

For file size issue, please try to reduce TIFF file size as suggested above and for memory consumption issue our product team is already looking into the ticket logged PDFNEWNET-39139 for the issue. It is a complex issue, we will update you as soon as we made some significant progress toward issue resolution.

We are sorry for the inconvenience caused.

Best Regards,

Hi Tilal,


just tested the further otimization you suggested. It’s actually doing exactly what you’ve described - reducing the size of the created file a with 1/3.
I see that the resulting file has 24bit color. Is there a way to reduce it to 16Bit? This will cut additional filesize and I’m ok with the quality loss.

Thanks in advance for any suggestions.

Best regards
Vasil Tonev

Hi Vasil,

We are sorry for the delayed response. My colleague from Aspose.Imaging is looking into the issue to change the image color depth and will update you soon.


Best Regards,
Hi Vasil,

Please note that we have investigated the issue related to reducing Bitdepth of a TIFF image. After initial investigation, we have noticed that Bitdepth setting is not working as expected, so we have logged the ticket IMAGING-35075 for further investigation and will keep you updated about the progress.

In the meanwhile you can try the following code snippet to reduce the size of the TIFF image.

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"D:\imaging_files\Tiff2Tiff.tiff"))
{
Aspose.Imaging.ImageOptions.TiffOptions saveOptions =
new Aspose.Imaging.ImageOptions.TiffOptions(Aspose.Imaging.FileFormats.Tiff.Enums.TiffExpectedFormat.Default);

saveOptions.Compression = Aspose.Imaging.FileFormats.Tiff.Enums.TiffCompressions.Jpeg;
saveOptions.Photometric = Aspose.Imaging.FileFormats.Tiff.Enums.TiffPhotometrics.Rgb;

image.Save(@"D:\imaging_files\Tiff2Tiff_ouput1.tiff", saveOptions);
}

The issues you have found earlier (filed as PDFNEWNET-39139) have been fixed in Aspose.Pdf for .NET 12.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.