Calling PDF Optimization increases the size of PDF

Here is the PDF I’m working with

This PDF is growing in size after the optimization calls.

Here is the code:

           `using (MemoryStream saveStream = new MemoryStream())
            {
                var optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions();

                optimizationOptions.ImageCompressionOptions.CompressImages = CompressImages;

                if (CompressImages)
                {
                    optimizationOptions.ImageCompressionOptions.ImageQuality = ImageQuality;
                    optimizationOptions.ImageCompressionOptions.ResizeImages = ResizeImages;

                    if (ResizeImages)
                    {
                        optimizationOptions.ImageCompressionOptions.MaxResolution = MaxResolution;
                    }
                }

                optimizationOptions.ImageCompressionOptions.Version =
                    GetCompressionVersion(ImageCompressionVersion);
                optimizationOptions.LinkDuplcateStreams = LinkDuplicateStreams;
                optimizationOptions.AllowReusePageContent = AllowReusePageContent;
                optimizationOptions.UnembedFonts = UnembedFonts;
                doc.OptimizeSize = true;
                doc.OptimizeResources(optimizationOptions);
                doc.Save(saveStream);

                resultBytes = saveStream.GetBuffer();
            }`

@jasondecisions,

Can you please add the values you did not include in your snippet?

That way, I can try to replicate the problem.

The easiest way to figure out if your snipper is okay, paste it in another method, and it will show you what you are missing.

Compress Images = True
Image Quality = 75
Resize Images = True
Max Resolution = 300
Image Compression Version = Standard
Link Duplicate Streams = True
Allow Reuse Page Content = True
Uembed Fonts = True

@jasondecisions,

It is because you give a higher quality than the original with the int MaxResolution. Lower it and you will see the result.

Thank you so much!