Skip to content

Commit 64daf26

Browse files
committed
lib/lowleveljpeg: add MinimumBaselineQuality
1 parent 0c7f1a4 commit 64daf26

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/lowleveljpeg/quant.go

+19
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ const (
6868
// SetToStandardValues' quality parameter. It matches libjpeg's default
6969
// both in terms of numerical value and in behavior.
7070
DefaultQuality = 75
71+
72+
// MinimumBaselineQuality is lowest quality level where both the cjpeg
73+
// program (from the libjpeg C project) and this Go package will agree on
74+
// the exact quantization factors.
75+
//
76+
// It's still valid to pass a SetToStandardValues quality parameter value
77+
// below 24. But when doing so, passing the equivalent to cjpeg will print
78+
// a JTRC_16BIT_TABLES warning: "quantization tables are too coarse for
79+
// baseline JPEG". cjpeg will therefore produce extended (instead of
80+
// baseline) JPEGs, using 2 bytes (instead of 1 byte) per quantization
81+
// factor, allowing factors above 0xFF.
82+
//
83+
// This Go package will instead clamp such quantization factors to 0xFF.
84+
//
85+
// Both approaches are viable, producing valid JPEGs. This Go package, like
86+
// the Go standard library's image/jpeg package, simply chooses to always
87+
// produce baseline (instead of extended) JPEGs, for best compatibility
88+
// with other JPEG decoders.
89+
MinimumBaselineQuality = 24
7190
)
7291

7392
// SetToStandardValues sets b to one of two standard quantization tables

0 commit comments

Comments
 (0)