You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let IcoEncoder, CurEncoder and AniEncoder choose the PNG filter for PNG frames
#3214
IcoEncoder, CurEncoder and AniEncoder create the PngEncoder for PNG-compressed frames inside IconEncoderCore, with fixed settings. FilterMethod is never set, so every PNG frame uses the default filter, Paeth. PngEncoder exposes FilterMethod, but the icon encoders offer no way to pass a different one.
Why it matters
Which filter compresses best depends a lot on the artwork, and icon and cursor art (flat colours, anti-aliased edges, large transparent areas) often does much better with something other than Paeth. These are 2,070 real cursor images (32–256 px), re-encoded with PngEncoder with only FilterMethod changed:
Filter
Total size
Paeth (what the icon encoders write today)
7,931,881 B
Adaptive
7,269,124 B (−8.4 %)
None
5,732,551 B (−27.7 %)
Since no single filter is best for every image, the caller should be able to choose.
Proposal
Add an optional filter setting for PNG frames to the icon encoders and pass it to the PngEncoder that IconEncoderCore creates:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Follow-up to #3213, as suggested there.
Problem
IcoEncoder,CurEncoderandAniEncodercreate thePngEncoderfor PNG-compressed frames insideIconEncoderCore, with fixed settings.FilterMethodis never set, so every PNG frame uses the default filter, Paeth.PngEncoderexposesFilterMethod, but the icon encoders offer no way to pass a different one.Why it matters
Which filter compresses best depends a lot on the artwork, and icon and cursor art (flat colours, anti-aliased edges, large transparent areas) often does much better with something other than Paeth. These are 2,070 real cursor images (32–256 px), re-encoded with
PngEncoderwith onlyFilterMethodchanged:Since no single filter is best for every image, the caller should be able to choose.
Proposal
Add an optional filter setting for PNG frames to the icon encoders and pass it to the
PngEncoderthatIconEncoderCorecreates:nullkeeps today's behaviour, so existing output stays byte-identical.IconEncoderCore, so one setting covers ICO, CUR and ANI.IconFrameCompression.Pngare affected; BMP frames don't change.An alternative would be to accept a configured
PngEncoderfor PNG frames, which would also expose settings such asCompressionLevel.All reactions