We already support streamtype=2 to skip producing JPEG tables, but
streamtype=1, which skips everything but the tables, was never implemented.
The streamtype=1 stub code dates to Git pre-history, so it's not
immediately clear why. Implement the missing support.
jpeg_write_tables() can't resume after a full output buffer (it fails with
JERR_CANT_SUSPEND), so it might seem that Pillow needs to pre-compute the
necessary buffer size. However, in the normal case of producing an
interchange stream, the tables are written via the same libjpeg codepath
during the first jpeg_write_scanlines() call, and table writes aren't
resumable there either. Thus, any buffer large enough for the normal case
will also be large enough for a tables-only file.
The streamtype option isn't documented and this commit doesn't change that.
It does add a test though.
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
16-bit quantization tables can appear at quality values below
about 25. These may cause compatibility problems. Maintain
baseline compatibility and avoid confusing users with warning
messages.
Don't force JPEG quantization to be baseline-compatible
Quantization values will not be limited to values 1..255 and may
be 16 bits if needed. This may cause compatibility issues.