Loosing image quality after resizing image

Hello Team,

We are trying to resize image using aspose.imaging latest version. In that, if source image width is greater than 572 then we are trying to resize that image to 572 width. we are able to resize image but we noted that image quality is loosing after resizing. We have also tried by setting horizontal and vertical resolution but no luck. I have attached sample application. Please refer it and suggest us how can we maintain image quality as per source image after resize it to width 572?

ResizeImage.zip (5.2 MB)

@siriussynoptek
Hello!
The problems with the quality loss are normal for resizing, especially if you have many texts placed on the image. And in this problem the horizontal/vertical resolutions can not help you anyway. But you can try to use another type of resizing that can give you better result. For example ResizeType.BilinearResample, ResizeType.AdaptiveResample or ResizeType.CubicBSpline, in my opinion, might help you.

Hi…
Thank you for suggestion. We have tried different ResizeType that you have suggested. In that,when we resize image using ResizeType.AdaptiveResample, generated image have some fuzzy background. How can we make background transparent(as per the source image) when resize image using ResizeType.AdaptiveResample? for your referrence, I have attached image.resize.jpg (72.3 KB)

Here, Images are of dynamic with different extension like JPEG, JIF, PNG etc. We don’t know whether all images contains many text or not. So can you please tell us which ResizeType will always give us best quality image compare to other ResizeType? Please suggest another solution if you have, to get best image quality when resize image.

@siriussynoptek
As you may see we’re supporting so many resize types, because there is no one, which better suites for every image. So it’s a client decision which resize type is applicable for the concrete case and I can add to the above list of more qualitative resize types, HighQualityResample, which is used by default in Free Online Resize Images, Photos, Pictures with High output Quality application

Can you please give your suggestion for this issue?

@siriussynoptek
Thank you for coming back.
As you probably know jpeg does not support transparency and we think, that resize and transparency are separate concerns.
Please provide your source code and source image to let us reproduce and address the issue.

Hi…
Please find attached zip for sample application and source image.
ResizeImage.zip (5.2 MB)

@siriussynoptek
We’ve observed your example and may share with you the following results and conclusions:

  1. Resize results from your source image - file resize.jpg in the attachment clear-resize.zip (1.1 MB)
  2. Resize results from another clear-source.jpg source image - file clear-resize.jpg
  3. Resize results from another clear-source.png source image - file clear-resize.png

Our observations and conclusions are following:

  1. Resize quality depends on the quality of the input image. For example, your input sample has some artifacts on the white background, which you can easily find trying to fill it by color. So better quality of sample image always produces better results.
  2. Results quality depends on the source image format. Jpeg is a lossy format, so better results, in some cases, can be obtained using png instead.
  3. Although always there is space for improvement and considering the quality of the current results, we did not find the issue significant for further consideration.

Feel free to contact us if you need further clarifications on the subject matter.

Hi…
We have checked clear-source.png and clear-resize.png image shared by you and found that clear-resize.png image background is not as per clear-source.png image background. As per your observations, is clear-source.png has some artifacts on the white background? Please see highlighted portion in attached image.
clear-source.jpg (273.9 KB)

@siriussynoptek
Although clear-source.png has some artifacts on white background, you may increase the quality of the resulting image background for this case using the following code:

string[] sources = {  "clear-source.png" };
            foreach(string source in sources)
            {
                var localImagePath = source;
                var resizeImagePath = localImagePath.Replace("source","resize");
                using (RasterImage sourceImg = (RasterImage)Image.Load(localImagePath))
                {
                    if (sourceImg.Width > 762)
                    {
                        sourceImg.ResizeWidthProportionally(762, ResizeType.AdaptiveResample);
                        // This is mostly important to make the background sharp white for such case
                        sourceImg.ReplaceColor(Color.White, 10, Color.White);
                        sourceImg.Save(resizeImagePath.Replace("resize", ResizeType.AdaptiveResample.ToString()), new PngOptions { ColorType = PngColorType.TruecolorWithAlpha } );
                    }
                }
            }

Expected result : clear-AdaptiveResample.jpg (120.8 KB)