JxlEncoderDistanceFromQuality

Function JxlEncoderDistanceFromQuality 

Source
pub unsafe extern "C-unwind" fn JxlEncoderDistanceFromQuality(
    quality: f32,
) -> f32
Expand description

Maps JPEG-style quality factor to distance.

This function takes in input a JPEG-style quality factor quality and produces as output a distance value suitable to be used with JxlEncoderSetFrameDistance and JxlEncoderSetExtraChannelDistance.

The distance value influences the level of compression, with lower values indicating higher quality:

  • 0.0 implies lossless compression (however, note that calling JxlEncoderSetFrameLossless is required).
  • 1.0 represents a visually lossy compression, which is also the default setting.

The quality parameter, ranging up to 100, is inversely related to distance:

  • A quality of 100.0 maps to a distance of 0.0 (lossless).
  • A quality of 90.0 corresponds to a distance of 1.0.

Recommended Range:

  • distance: 0.5 to 3.0.
  • corresponding quality: approximately 96 to 68.

Allowed Range:

  • distance: 0.0 to 25.0.
  • corresponding quality: 100.0 to 0.0.

Note: the quality parameter has no consistent psychovisual meaning across different codecs and libraries. Using the mapping defined by JxlEncoderDistanceFromQuality will result in a visual quality roughly equivalent to what would be obtained with libjpeg-turbo with the same quality parameter, but that is by no means guaranteed; do not assume that the same quality value will result in similar file sizes and image quality across different codecs.