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).
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,
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.
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");
}
}