Compressed TIFF not seeing impressive effect (sometimes its size is even larger)

Our team is given the task to see how well a TIFF file with multiple pages can be compressed without sacrificing too much quality by using Aspose.Imaging. However we found out the size of the resulting TIFF file after applying the compression options sometimes is even larger than the original one. (a 1,291 KB tiff file after compression becomes a 1,326 KB one). In cases where the file size did become smaller, the compression effect is not very impressing. Is that the best the code can do? (a 42,500 KB tiff file after compression becomes a 40,496 KB one).


We are not very knowledgeable about all the settings in the compression options. We already spend lots of time browsing through Aspose.Imaging’s example project trying to borrow some code snippets to fulfill our task but not very successful. We already used your Aspose.Pdf to optimize our PDF files and are thinking about compressing TIFF files in other area. Are we on the right track selecting Aspose.Imaging trying to compress TIFF files? Will Aspose.Pdf provide the feature like that already?

Please find our code snippet in the attachment. Thank you for your help!

Hi,

I have observed the information shared by you and request you to please provide the source Tiff image and if possible working code sample in the form of text file. We will investigate the issue on provision of requested information.

Many Thanks,

Please find the following in the zip:
1. FA-aspose.cs.txt – code snippet for optimizing PDF streaming and PDF/TIFF size compression
2. PDF Files - 5940804F 04_GI SECTION FS Results.pdf, 6009187F and 18_PI SECTION FS Results.pdf
3. TIFF Files - 78976-2011.tif and BANKRUPTCY_SEARCH.tif
4, ReadMe.txt - this file

Q/A for Aspose.pdf
1. When we apply both streaming & file size optimization (in OptimizePdf() method), are we still getting the same streaming capability? Applying streaming Optimization was our original goal acquiring the Aspose.pdf product. We don’t want to lose this functionality when we compress the file.
2. After applying the streaming & file size optimization, the two PDF files result in larger files. The large PDF file (too big to include) size shrinks from 62,688 KB to 47,691 KB. It’s not very impressive. We were told SimpleText & iLovePdf are doing better in compression. (iLovePdf produces 12,396 KB from 62,688 KB)

Q/A for Aspose.Imaging
1. After applying the file size compression, “78976-2011.tif” implodes from 1,291 KB to 1,326KB. “BANKRUPTCY_SEARCH.tif” shrinks in size but we lose the color. We tried commenting out “outputSettings.Palette = ColorPaletteHelper.Create4BitGrayscale(false);” but the program won’t compile successfully.

Hi Roy,

Thanks for sharing the additional details.

I have added an issue with ID IMAGINGNET-2350 in our issue tracking system to further investigate and resolve the issue w.r.t Aspose.Imaging end. We will share the feedback with you once it will be shared further by our product team. Moreover, for QA issue reported related to Aspose.Pdf, we will also share the feedback with you in that regard.

We are sorry for your inconvenience,

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.

@rlou,

We have completed investigation of following Aspose.Imaging related requirements.

Unfortunately, there is no universal way for all cases to make the output TIFF image smaller, so it needs to look thoroughly at individual frames and analyze original settings for each frame. We have used JHove for such analysis and it is available for free. We executed jhove-gui.bat and choose Edit->Select Module->TIFF-hul. Then we calibrated settings to make the output file as smaller as possible.

For “78976-2011.tif” you can shrink the file size from 1321002 bytes to 590106 bytes using CCITT Fax compression using following sample code:

string dir = @"c:\aspose.work\IMAGINGNET\2350\";

// Case #1
// All 10 frames are black-white images compressed with LZW method. See the corresponding JHove log [jhove_78976-2011_tif.txt]
// Because only pure black and white colors are used without anti-aliasing, we can apply CCITT Fax compression for the whole image,
// because it is more effective than LZW for bi-level images.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "78976-2011.tif"))
{
TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.TiffCcittFax4);
image.Save(dir + "78976-2011 Out.tif", outputSettings);
}
{code}

For "BANKRUPTCY_SEARCH.tif" you can shrink the file size from 110700 bytes to 79716 bytes using Deflate compression:
{code}
// Case #2
    // Individual settings for each frame.
    using (TiffImage inputImage = (TiffImage)Aspose.Imaging.Image.Load(dir + "BANKRUPTCY_SEARCH.tif"))
    {
    TiffFrame[] inputFrames = inputImage.Frames;

    // Frame #1
    // The source frame is a palettized 8-bit multi-color image compressed with LZW. See the corresponding JHove log [jhove_BANKRUPTCY_SEARCH_tif.txt].
    TiffOptions frame1Options = new TiffOptions(TiffExpectedFormat.Default)
    {
        BitsPerSample = new ushort[] { 8 },
        Compression = TiffCompressions.Deflate,
        Photometric = TiffPhotometrics.Palette,
        //Palette = ColorPaletteHelper.GetCloseImagePalette(inputFrames[0], 1 << 8),
        Palette = inputFrames[0].FrameOptions.Palette,
    };

    // Frame #2
    // The source frame is a palettized 8-bit black-white image compressed with LZW. See the corresponding JHove log [jhove_BANKRUPTCY_SEARCH_tif.txt].
    // This image contains smoothed text, so additional colors (not only pure black and white) are required to achieve the effect of anti-aliasing.
    // So we can't apply CCITT Fax compression without quality loss.
    TiffOptions frame2Options = new TiffOptions(TiffExpectedFormat.Default)
    {
        BitsPerSample = new ushort[] { 8 },
        Compression = TiffCompressions.Deflate,
        Photometric = TiffPhotometrics.Palette,
        //Palette = ColorPaletteHelper.GetCloseImagePalette(inputFrames[1], 1 << 8),
        Palette = inputFrames[1].FrameOptions.Palette,
    };

    // Compose new TIFF image
    TiffFrame[] outputFrames = new TiffFrame[2];
    outputFrames[0] = TiffFrame.CreateFrameFrom(inputFrames[0], frame1Options);
    outputFrames[1] = TiffFrame.CreateFrameFrom(inputFrames[1], frame2Options);

    using (TiffImage outputImage = new TiffImage(outputFrames))
    {
        outputImage.Save(dir + "BANKRUPTCY_SEARCH Out.tif");
    }

    }