xl-converter icon indicating copy to clipboard operation
xl-converter copied to clipboard

Add distance slider for JPEG XL.

Open AniXL opened this issue 9 months ago • 1 comments

Feature Description

One of three ways to implement this.

  1. Add an option to replace quality slider in advanced settings
  2. Replace and make quality slider optional instead. (Preferred)
  3. Remove quality slider entirely in favor of distance slider.

Technical Details

Distance is very useful for quickly encoding image with expectations more tilted towards quality than the size or when choosing quality between 0-100 is difficult.

Existing Implementations

JPEG XL's encoder itself.

AniXL avatar Mar 29 '25 11:03 AniXL

Quality in cjxl is internally mapped to distance. Using one or the other results in an identical file. Quality is just a commonly understood abstraction.

This is the libjxl implementation:

float JxlEncoderDistanceFromQuality(float quality) {
  return quality >= 100.0 ? 0.0
         : quality >= 30
             ? 0.1 + (100 - quality) * 0.09
             : 53.0 / 3000.0 * quality * quality - 23.0 / 20.0 * quality + 25.0;
}

Corresponding values:

Quality Distance
100 0.0
90 1.0
80 1.9
70 2.8
60 3.7
50 4.6
40 5.5
30 6.4
20 9.0(6)
10 15.2(6)
0 25.0

JacobDev1 avatar Mar 29 '25 13:03 JacobDev1

Quality in cjxl is internally mapped to distance. Using one or the other results in an identical file. Quality is just a commonly understood abstraction.

This is the libjxl implementation:

float JxlEncoderDistanceFromQuality(float quality) { return quality >= 100.0 ? 0.0 : quality >= 30 ? 0.1 + (100 - quality) * 0.09 : 53.0 / 3000.0 * quality * quality - 23.0 / 20.0 * quality + 25.0; } Corresponding values:

Quality Distance 100 0.0 90 1.0 80 1.9 70 2.8 60 3.7 50 4.6 40 5.5 30 6.4 20 9.0(6) 10 15.2(6) 0 25.0

Oh I see. Then is a tooltip on the quality slider possible? If not, you can close this issue.

Thank you very much :)

AniXL avatar May 01 '25 14:05 AniXL

If you really need distance, you can use the table above for the reference.

If more people ask, I'll consider it, but generally people prefer to use the Quality rate control in image converters. If this provided a tangible benefit, sure, but here it's just an abstraction. It does require a fundamental change to the UI logic so maybe another time.

JacobDev1 avatar May 02 '25 06:05 JacobDev1