PngEncoder image size increases by 200% to 300% when specifying ColorType #3042
-
Prerequisites
ImageSharp version3.1.12 Other ImageSharp packages and versions3.1.11 Environment (Operating system, version and so on)Windows 11 .NET Framework version.NET 10, C# 14 DescriptionI 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 property so it's clearer how it's meant to be used? Steps to Reproduce
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 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
I’ve converted this to a discussion since it is a question not an issue. What is the encoded format (color type) of your textures? My guess would be palette based in which case it would be expected that using a different color type would increase file size since you are encoding pixel data not simply and index to a palette entry. |
Beta Was this translation helpful? Give feedback.
I’ve converted this to a discussion since it is a question not an issue.
What is the encoded format (color type) of your textures? My guess would be palette based in which case it would be expected that using a different color type would increase file size since you are encoding pixel data not simply and index to a palette entry.