-
-
Notifications
You must be signed in to change notification settings - Fork 887
Closed
Labels
Description
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
andRELEASE
mode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
3.1.4
Other ImageSharp packages and versions
NA
Environment (Operating system, version and so on)
NA
.NET Framework version
net8
Description
When a new PngEncoder
is created with custom FilterMethod
it always produces the same file size,
i.e. the FilterMethod
is being ignored.
Example:
var encoder = new PngEncoder
{
FilterMethod = PngFilterMethod.Paeth,
};
I found only one usage of this property here
ImageSharp/src/ImageSharp/Formats/Png/PngEncoderCore.cs
Lines 1522 to 1526 in 10e9c49
if (!encoder.FilterMethod.HasValue) | |
{ | |
// Specification recommends default filter method None for paletted images and Paeth for others. | |
this.filterMethod = this.colorType is PngColorType.Palette ? PngFilterMethod.None : PngFilterMethod.Paeth; | |
} |
i.e. filterMethod
is assigned only if encoder.FilterMethod
is null
,
otherwise, it is always 0 (PngFilterMethod.None
).
Steps to Reproduce
SixLabors.ImageSharp.Image img = null!;
var paethFilterStream = new MemoryStream();
img.Save(paethFilterStream, new PngEncoder
{
FilterMethod = PngFilterMethod.Paeth,
});
var noneFilterStream = new MemoryStream();
img.Save(noneFilterStream , new PngEncoder
{
FilterMethod = PngFilterMethod.None,
});
Assert.NotEquals(paethFilterStream.Length, noneFilterStream.Length);
Images
No response