JpegEncodeOptions
How ImageKodec.encodeJpeg and ImageKodec.encodeJpeg16 write a JPEG (#183): the process of ITU-T T.81, the entropy coding, the components and their sampling. Every parameter has a default, and the defaults write what ImageKodec.encodeJpeg writes from a quality alone: an 8-bit baseline file with the example Huffman tables of T.81 Annex K. The one change is grayscale, which by default writes a gray picture as one component.
The processes: a sequential DCT file (baseline SOF0 at 8 bits, extended SOF1 at 12), a progressive one (SOF2), the arithmetic-coded forms of both (SOF9, SOF10), and a lossless one (SOF3, or SOF11 with arithmetic). Hierarchical files are not written.
Throws
if a value is outside its range, or two options exclude each other, each named in the message
Constructors
Properties
arithmetic coding by T.81 Annex D's QM coder with the models of F.1.4, G.1.3 and H.1.2.3, in place of Huffman coding: commonly a tenth smaller than Huffman coding with tables built for the file, and read by fewer programs (no browser reads it).
the AC conditioning Kx, 1 to 63 (T.81 F.1.4.4.2). The three are written in a DAC segment, and set only with arithmetic.
the lower conditioning bound L of the DAC segment, 0 to 15, for the DC coefficients or the lossless differences (T.81 F.1.4.4.1.2). The default is T.81's.
the upper bound U, arithmeticDcLower to 15.
which encoder makes the coefficients. JpegEncoderKind.Jpegli honours every option of an 8-bit DCT file: its progressive, arithmetic and optimized files hold the coefficients of its baseline file, and its gray file is the luma of its colour one.
one component or three; see JpegGrayscale.
a lossless file of T.81 Annex H: the difference of each sample from the prediction of predictor, so ImageKodec.decode16 returns every bit. Three components are stored as RGB, with no colour transform, and none is subsampled.
Huffman tables built from the file's own symbol counts (T.81 K.2, limited to 16 bits by K.3), in a second pass, in place of the example tables: smaller and slower. A 12-bit or lossless Huffman file always gets them, since the example tables do not hold its larger categories. Not with arithmetic, which has no Huffman tables.
the bits a sample: 8, or 12 for a DCT file, which only ImageKodec.encodeJpeg16 writes; 2 to 16 for a lossless file. Each sample is the top precision bits of the 16-bit sample, which ImageKodec.decode16 widens back.
a progressive file by the scan script libjpeg uses by default: a first DC scan of every component at half precision, the AC coefficients of each component in bands by spectral selection and two steps of successive approximation, then the refinements. Its Huffman tables are always built for the file, since the example ones have no end-of-band runs.
the number of MCUs between restart markers, 0 for none, up to 65535. A lossless interval must hold whole rows of MCUs, as T.81 H.1.1 asks and libjpeg-turbo requires, which the encode checks against the width.
the chroma sampling of a three-component DCT file. A lossless file takes JpegSubsampling.Auto or JpegSubsampling.S444 only, and JpegEncoderKind.Jpegli JpegSubsampling.Auto or JpegSubsampling.S420 only, its matrices being tuned for 4:2:0.