Image intensity increases when converting image stream on Linux box

Hello,

We are trying to generate image but the output is different in Linux than windows. We have posted our queries in Aspose.Imaging forum but they have replied us that the issue is in Aspose.PDF in rasterization process. Following is the reference of Aspose.Imaging forum conversation. Please have a look and guide us to resolve this issue. Thanks.

https://forum.aspose.com/t/image-intensity-increases-when-converting-image-stream-on-linux/260727

@jsign,

I see you already check with the Imaging team. But I need more information to escalate the issue to a ticket.

I was reading the code snippet, and it is incomplete.

What is doc? a new doc? Are you reading it from a source?

Please put here the whole snippet and any input files required for the dev team to replicate this issue.

Below is the code snippet. Also attaching the document I have used as an input.

Input Document :

sample.pdf (3.0 KB)

Code Snippet :

using (MemoryStream imageStream = new MemoryStream())
                {
                    var pngDevice = new PngDevice();
                    //  Generate Image
                    pngDevice.Process(doc.Pages[pageCount], imageStream);
                    string aratio = string.Empty, height = string.Empty;
                    //Scale Image using Aspose.Imaging
                    try
                    {
                        using (var img = Aspose.Imaging.Image.Load(new MemoryStream(imageStream.ToArray())))
                        {
                            float ratio;
                            int newWidth;
                            int newHeight;

                            if (scaleImages)
                            {
                                ratio = scaleRatio;
                                newWidth = (int)(img.Width * ratio);
                                newHeight = (int)(img.Height * ratio);
                            }
                            else
                            {
                                ratio = 0;
                                newWidth = img.Width;
                                newHeight = img.Height;
                            }

                            aratio = ratio.ToString(CultureInfo.InvariantCulture);

                            height = newHeight.ToString();
                            img.Resize(newWidth, newHeight, Aspose.Imaging.ResizeType.HighQualityResample);

                            
                            byte[] encryptedFile = null;
                            using (Stream generateImageStream = new MemoryStream())
                            {
                                img.Save(generateImageStream);

                                //Encrypt Image using private key                                   
                                var b = new byte[generateImageStream.Length];
                                generateImageStream.Read(b, 0, b.Length);
                                generateImageStream.Position = 0;
                                encryptedFile = CommonExtensions.EncryptByteArray(b, model.PrivateKey);
                            }
                            pages = string.Concat("image", pageCount, model.ImageExtension);
                            ratios = aratio;
                            allheights = height;
                            PdfFileInfo info = new PdfFileInfo(doc);
                            rectHeight = info.GetPageHeight(pageCount);
                            rectWidth = info.GetPageWidth(pageCount);
                            allRectHeight = string.Concat(allRectHeight, pageCount, ":", rectWidth + ",", rectHeight, "#");
                            pageDetailModel.Add(new PageDetailModel
                            {
                                ImageId = "image" + pageCount + model.ImageExtension,
                                ImageUrl = Guid.NewGuid().ToString(),
                                Ratio = aratio,
                                AllHeights = height,
                                RectHeight = rectHeight,
                                RectWidth = rectWidth,
                                Fields = fields,
                                AllRectHeightWidth = pageCount + ":" + rectWidth + "," + rectHeight,
                                ImageStream = encryptedFile != null && encryptedFile.Length > 0 ? new MemoryStream(encryptedFile) : null
                            });
                        }
                    }
                    catch (Exception)
                    {
                        //Ignore
                    }
                }

@jsign
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-53772

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.