Free Support Forum -

Optimizing PDF with JBIG2 image destroys image


if I try to optimize a PDF (Example.pdf (3.0 KB)) File containing a JBIG2 image, sometimes the images get completly destroyed (Example_optimized.pdf (3.3 KB)). I use the follow method to optimize the PDF file.

private static void Optimize(Document doc)
  var optimizationOptions = new Document.OptimizationOptions
    AllowReusePageContent = false,
    LinkDuplcateStreams = false,
    RemoveUnusedObjects = false,
    RemoveUnusedStreams = false,
    CompressImages = true,
    ImageQuality = 50,
    MaxResoultion = 125,
    ResizeImages = true,
    RemovePrivateInfo = false

  doc.OptimizeResources (optimizationOptions);

Is it possible to exclude JBIG2 images from beeing optimized or altered in any way? I used Aspose.PDF Assembly Version 18.1 and 18.6.1 in both cases I got the same result.

Original looks like this: before.png (2.0 KB)

After optimization it looks like this: after.png (2.3 KB)


Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue in our environment. We have logged an investigation ticket with ID PDFNET-45026 to further investigate if JBIG2 images can be excluded while optimizing a PDF file. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.


this Bug seems not to be limited to JBIG2 images. It happens with TIFF images too, if one of the following compressions is used: CCITT Group 3 Fax or CCITT Group 4 Fax. It seems the problem is if the image is 1 bit color depth with no alpha channel.


Thank you for sharing your findings.

Would you please share a source and generated PDF file which is having this problem with TIFF images. This will help us address your concerns even better.

Hi @Farhan.Raza,

This is the source PDF containing multiple TIFF Images PDF15 containing TIFF color and 1bpp.pdf (538.7 KB). The first two images are the problem they are 1bit per pixel with no alpha channel images the first is compressed using “CCITT Group 3 Fax” and the second image uses “CCITTT Group 4 Fax”. The other TIFF in this PDF uses JPEG, Pack Bits, Deflate, LZW, and no compression at all. This are all color images and they will be omptimized without problem. The result after optimizing the PDF with the code above results in this PDF result.pdf (241.5 KB)


Thank you for sharing requested data with us.

We have recorded your findings under the same ticket in our issue management system. We will let you know as soon as the ticket will be resolved.