Imagesharp: Resize from large source to small thumbnail produces deformed top pixel rows

Created on 9 Sep 2019  路  11Comments  路  Source: SixLabors/ImageSharp

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have verified that I am running the latest version of ImageSharp
  • [ ] I have verified if the problem exist in both DEBUG and RELEASE mode
  • [x] I have searched open and closed issues to ensure it has not already been reported

Description

Downsizing a large image can cause oddly sampled pixels in the top rows of pixels (I only noticed it in the top rows at least).

I tested multiple samplers. All of them displayed similar results.

Steps to Reproduce

using (var image = Image.Load(flowersJpg))
{
    image.Mutate(i => i.Resize(new ResizeOptions
    {
        Size = new Size(300, 300),
        Mode = ResizeMode.Crop
    }));

    image.SaveAsJpeg(outputStream);
}

System Configuration

  • ImageSharp version: 1.0.0-beta0007
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): Windows 10 (1903)
  • .NET Framework version: 4.7.1
  • Additional information:

Source Image

flowers

Example results

Resized with ImageSharp
flowers_imagesharp

Resized with ImageResizer
flowers_imageresizer

transforms bug

Most helpful comment

@netwavebe Here's the output following my fix. @patrikwlund @scleaver Your images will resize correctly once merged. Thanks for your patience. 馃憤

CanResizeLargeImageWithCropMode_Rgba32_issue1006-incorrect-resize

All 11 comments

@scleaver Can you include the source images directly in this issue please, Just in case they get removed or updated on your servers. Thanks!

I think the issue is caused by the size of the source image.

group-ideas
family-groups2

Thanks @scleaver

@antonfirsov one for you I think. Let me know if you need a second pair of eyes.

I'm having the same issue. This is the top (zoomed in) of a 1980x5520 jpeg cropped to 480x600:

CGPW460_2018

I can provide the original image if needed.

@netwavebe Please do. Thanks!

Original image is 1980 x 5520:

CGPW460_2018

This image cropped to 480 x 600:

CGPW460_2018_cropped_480x600

The top distortion is probably very visible here because we're cropping a lot in this image...

@netwavebe I'm assuming you're simply passing the new width and height with ResizeMode.Crop yeah?

@JimBobSquarePants Yes, exactly!

@netwavebe Here's the output following my fix. @patrikwlund @scleaver Your images will resize correctly once merged. Thanks for your patience. 馃憤

CanResizeLargeImageWithCropMode_Rgba32_issue1006-incorrect-resize

@JimBobSquarePants : Awesome! 馃憤
@scleaver : Once there is a new version, we need to update Orchard Core dev!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DAGA86 picture DAGA86  路  3Comments

Inumedia picture Inumedia  路  3Comments

JimBobSquarePants picture JimBobSquarePants  路  3Comments

jarroda picture jarroda  路  3Comments

agoretsky picture agoretsky  路  4Comments