Skip to content

Commit

Permalink
Removed qmin and qmax since minQuantizer and maxQuantizer are deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jan 25, 2025
1 parent aef330b commit 94da9ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
8 changes: 1 addition & 7 deletions docs/handbook/image-file-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1358,15 +1358,9 @@ as 8-bit RGB(A).

The :py:meth:`~PIL.Image.Image.save` method supports the following options:

**qmin** / **qmax**
Integer, 0-63. The quality of images created by an AVIF encoder are
controlled by minimum and maximum quantizer values. The higher these
values are, the worse the quality.

**quality**
Integer, 0-100, defaults to 75. 0 gives the smallest size and poorest
quality, 100 the largest and best quality. Setting "qmin" or "qmax" will override
this.
quality, 100 the largest and best quality.

**subsampling**
If present, sets the subsampling for the encoder. Defaults to ``4:2:0``.
Expand Down
4 changes: 0 additions & 4 deletions src/PIL/AvifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ def _save(

is_single_frame = total == 1

qmin = info.get("qmin", -1)
qmax = info.get("qmax", -1)
quality = info.get("quality", 75)
if not isinstance(quality, int) or quality < 0 or quality > 100:
msg = "Invalid quality setting"
Expand Down Expand Up @@ -218,8 +216,6 @@ def _save(
im.size[0],
im.size[1],
subsampling,
qmin,
qmax,
quality,
speed,
max_threads,
Expand Down
17 changes: 4 additions & 13 deletions src/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
avifEncoder *encoder;

char *subsampling;
int qmin;
int qmax;
int quality;
int speed;
int exif_orientation;
Expand All @@ -255,12 +253,10 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {

if (!PyArg_ParseTuple(
args,
"IIsiiiiissiiOOSSiSO",
"IIsiiissiiOOSSiSO",
&width,
&height,
&subsampling,
&qmin,
&qmax,
&quality,
&speed,
&max_threads,
Expand Down Expand Up @@ -327,17 +323,12 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
_codec_available("aom", AVIF_CODEC_FLAG_CAN_ENCODE));
encoder->maxThreads = is_aom_encode && max_threads > 64 ? 64 : max_threads;

if (qmin == -1 || qmax == -1) {
#if AVIF_VERSION >= 1000000
encoder->quality = quality;
encoder->quality = quality;
#else
encoder->minQuantizer = normalize_quantize_value(64 - quality);
encoder->maxQuantizer = normalize_quantize_value(100 - quality);
encoder->minQuantizer = normalize_quantize_value(64 - quality);
encoder->maxQuantizer = normalize_quantize_value(100 - quality);
#endif
} else {
encoder->minQuantizer = normalize_quantize_value(qmin);
encoder->maxQuantizer = normalize_quantize_value(qmax);
}

if (strcmp(codec, "auto") == 0) {
encoder->codecChoice = AVIF_CODEC_CHOICE_AUTO;
Expand Down

0 comments on commit 94da9ee

Please sign in to comment.