Skip to content

Commit

Permalink
Removed alpha_premultiplied
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 21, 2025
1 parent 10dfa63 commit 38f0830
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 28 deletions.
13 changes: 0 additions & 13 deletions Tests/test_file_avif.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,19 +662,6 @@ def test_heif_raises_unidentified_image_error(self) -> None:
with Image.open("Tests/images/avif/rgba10.heif"):
pass

@pytest.mark.parametrize("alpha_premultiplied", [False, True])
def test_alpha_premultiplied(
self, tmp_path: Path, alpha_premultiplied: bool
) -> None:
temp_file = str(tmp_path / "temp.avif")
color = (200, 200, 200, 1)
im = Image.new("RGBA", (1, 1), color)
im.save(temp_file, alpha_premultiplied=alpha_premultiplied)

expected = (255, 255, 255, 1) if alpha_premultiplied else color
with Image.open(temp_file) as reloaded:
assert reloaded.getpixel((0, 0)) == expected

def test_timestamp_and_duration(self, tmp_path: Path) -> None:
"""
Try passing a list of durations, and make sure the encoded
Expand Down
4 changes: 0 additions & 4 deletions docs/handbook/image-file-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ The :py:meth:`~PIL.Image.Image.save` method supports the following options:
and "tile_cols" both have their default values of zero. Requires libavif version
**0.11.0** or greater.

**alpha_premultiplied**
Encode the image with premultiplied alpha. Defaults to ``False``. Requires libavif
version **0.9.0** or greater.

**advanced**
Codec specific options. Requires libavif version **0.8.2** or greater.

Expand Down
2 changes: 0 additions & 2 deletions src/PIL/AvifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def _save(
range_ = info.get("range", "full")
tile_rows_log2 = info.get("tile_rows", 0)
tile_cols_log2 = info.get("tile_cols", 0)
alpha_premultiplied = bool(info.get("alpha_premultiplied", False))
autotiling = bool(info.get("autotiling", tile_rows_log2 == tile_cols_log2 == 0))

icc_profile = info.get("icc_profile", im.info.get("icc_profile"))
Expand Down Expand Up @@ -214,7 +213,6 @@ def _save(
range_,
tile_rows_log2,
tile_cols_log2,
alpha_premultiplied,
autotiling,
icc_profile or b"",
exif or b"",
Expand Down
10 changes: 1 addition & 9 deletions src/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
Py_buffer icc_buffer;
Py_buffer exif_buffer;
Py_buffer xmp_buffer;
int alpha_premultiplied;
int autotiling;
int tile_rows_log2;
int tile_cols_log2;
Expand All @@ -254,7 +253,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {

if (!PyArg_ParseTuple(
args,
"(II)siiissiippy*y*iy*O",
"(II)siiissiipy*y*iy*O",
&width,
&height,
&subsampling,
Expand All @@ -265,7 +264,6 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
&range,
&tile_rows_log2,
&tile_cols_log2,
&alpha_premultiplied,
&autotiling,
&icc_buffer,
&exif_buffer,
Expand Down Expand Up @@ -318,9 +316,6 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
image->height = height;

image->depth = 8;
#if AVIF_VERSION >= 90000
image->alphaPremultiplied = alpha_premultiplied ? AVIF_TRUE : AVIF_FALSE;
#endif

encoder = avifEncoderCreate();
if (!encoder) {
Expand Down Expand Up @@ -537,9 +532,6 @@ _encoder_add(AvifEncoderObject *self, PyObject *args) {
frame->yuvRange = image->yuvRange;
frame->yuvFormat = image->yuvFormat;
frame->depth = image->depth;
#if AVIF_VERSION >= 90000
frame->alphaPremultiplied = image->alphaPremultiplied;
#endif
}

avifRGBImageSetDefaults(&rgb, frame);
Expand Down

0 comments on commit 38f0830

Please sign in to comment.