Prerequisites
ImageSharp version
3.1.12
Other ImageSharp packages and versions
3.1.11
Environment (Operating system, version and so on)
Windows 11
.NET Framework version
.NET 10, C# 14
Description
I was trying to cut down on the size of the PNGs I was writing, so I tried looking through the PngEncoder properties to see if there were any hints I could give it as an optimization.
I noticed that PngEncoder.ColorType could be set to Rgb/RgbWithAlpha/Grayscale/GrayscaleWithAlpha, so it seemed plausible this was such a hint? (It's kind of hard to tell what PngEncoder.ColorType is meant to be, since its documentation isn't very helpful--it's just described as "the color type", which I had already inferred from the name.)
When I actually set this property, though, I find that the PNGs I write actually increase in size by anywhere from 200% to 300% (compared to when written without setting the property).
I wanted to verify if this was intended behavior, and also to ask if you could improve the documentation for this field so it's clearer how it's meant to be used?
Steps to Reproduce
- Load one of the following images into C# via ImageSharp, it should be an
Image<Rgb24>.
- Save it via the following two methods:
image.Save(
stream,
new PngEncoder {
SkipMetadata = true,
});
image.Save(
stream,
new PngEncoder {
SkipMetadata = true,
ColorType = PngColorType.Rgb
});
The image without ColorType set will be smaller than the input image, but the image with ColorType set to PngColorType.Rgb will be significantly larger.
Images
textures.zip
Prerequisites
DEBUGandRELEASEmodeImageSharp version
3.1.12
Other ImageSharp packages and versions
3.1.11
Environment (Operating system, version and so on)
Windows 11
.NET Framework version
.NET 10, C# 14
Description
I was trying to cut down on the size of the PNGs I was writing, so I tried looking through the PngEncoder properties to see if there were any hints I could give it as an optimization.
I noticed that PngEncoder.ColorType could be set to Rgb/RgbWithAlpha/Grayscale/GrayscaleWithAlpha, so it seemed plausible this was such a hint? (It's kind of hard to tell what PngEncoder.ColorType is meant to be, since its documentation isn't very helpful--it's just described as "the color type", which I had already inferred from the name.)
When I actually set this property, though, I find that the PNGs I write actually increase in size by anywhere from 200% to 300% (compared to when written without setting the property).
I wanted to verify if this was intended behavior, and also to ask if you could improve the documentation for this field so it's clearer how it's meant to be used?
Steps to Reproduce
Image<Rgb24>.The image without ColorType set will be smaller than the input image, but the image with ColorType set to PngColorType.Rgb will be significantly larger.
Images
textures.zip