Open HyeockJinKim opened 1 year ago
Change https://go.dev/cl/476017 mentions this issue: image/png: Add huffmanOnly compression level to png
Are you proposing adding a new API to the image/png package? (Adding an exported constant is a new API.) If so, you'll need to follow the proposal process, see https://golang.org/s/proposal . Thanks.
Is it better to edit this issue (#59023) now as a template for a proposal? Or should I follow the link below to create a new issue as a template for a proposal? https://github.com/golang/proposal/blob/master/go2-language-changes.md
Thanks for your help.
@HyeockJinKim Either way is fine. Thanks.
I've created it according to the proposal template. Can you review it? @ianlancetaylor
It would also be nice to work on supporting all zlib compression levels from 1-9, would you mind if I put that in the proposal as well?
Sure, you can update the proposal. But you used the wrong template. You used the one for a language or incompatible library change (Go 2) not the one for a simple additional proposal. May be easier to start a new issue at this point. Thanks.
I've rewritten it, please review it again. :cry:
CC @nigeltao
Adding const HuffmanOnly CompressionLevel = -4
to package png
LGTM.
Optionally, if you also want to implement this (below) in image/png/writer.go
, then that LGTM too.
// Positive CompressionLevel values are reserved to mean a numeric zlib
// compression level, although that is not implemented yet.
In hindsight, it would have been nice if the numeric values were consistent (and, perhaps, that 0 meant "default"). But it's too late to change existing constants.
Shall I add to CL to receive compression levels of 1-9?
I'm OK with that, but I'd also wait until there's a formal response to the proposal.
Problem:
The HuffmanOnly option, which only performs Huffman encoding, is supported by the zlib library, but not by png using zlib.
Solution
Add a HuffmanOnly
const
to image/png.Golang developer can pass the HuffmanOnly option with the code below and get a PNG with only huffman encoding.