Skip to content

Commit

Permalink
image/png: Add huffmanOnly compression level to png
Browse files Browse the repository at this point in the history
Add the HuffmanOnly compression level to png,
which was only supported by the zlib library.
  • Loading branch information
HyeockJinKim committed Mar 14, 2023
1 parent 82bf129 commit 5088d2e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/image/png/fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func Fuzz(data []byte) int {
NoCompression,
BestSpeed,
BestCompression,
HuffmanOnly,
}
for _, l := range levels {
var w bytes.Buffer
Expand Down
1 change: 1 addition & 0 deletions src/image/png/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func FuzzDecode(f *testing.F) {
NoCompression,
BestSpeed,
BestCompression,
HuffmanOnly,
}
for _, l := range levels {
var w bytes.Buffer
Expand Down
3 changes: 3 additions & 0 deletions src/image/png/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
NoCompression CompressionLevel = -1
BestSpeed CompressionLevel = -2
BestCompression CompressionLevel = -3
HuffmanOnly CompressionLevel = -4

// Positive CompressionLevel values are reserved to mean a numeric zlib
// compression level, although that is not implemented yet.
Expand Down Expand Up @@ -578,6 +579,8 @@ func levelToZlib(l CompressionLevel) int {
return zlib.BestSpeed
case BestCompression:
return zlib.BestCompression
case HuffmanOnly:
return zlib.HuffmanOnly
default:
return zlib.DefaultCompression
}
Expand Down

0 comments on commit 5088d2e

Please sign in to comment.