Skip to content

Black borders on mutate (image resize with background color) #1986

@romanov

Description

@romanov

Prerequisites

  • [+] I have written a descriptive issue title
  • [+] 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
  • [+] I have searched open and closed issues to ensure it has not already been reported

Description

Hello,

i'm trying to resize the following test image (1500x1500) to 250x350px and keep white background:

https://ibb.co/Yk6kqBc

Steps to Reproduce

  1. Upload the image above to the local folder
  2. Encode it with the following code
var encoder = new WebpEncoder
{
    Quality = 100,
    Method = WebpEncodingMethod.BestQuality,
};

var resizeOptions = new ResizeOptions
{
    Mode = ResizeMode.Pad,
    Size = new Size(250, 350)
};

using var image = Image.Load(fileName, out var imageFormat);
image.Mutate(x => x.Resize(resizeOptions).BackgroundColor(Color.White));
image.SaveAsWebp(newFileName, encoder);

Expected result (green box in the middle, white background):

expected

Actual result (green box in the middle, black background):

actual

System Configuration

  • ImageSharp version: 2.0.0
  • Other ImageSharp packages and versions: n/a
  • Environment (Operating system, version and so on): Microsoft Windows [Version 10.0.19043.1466]
  • .NET Framework version: NET 6 Console app & ASP.NET CORE
  • Additional information: n/a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions