Skip to content

Commit

Permalink
fix: disable decoder strictness for clap and pixi properties (#57)
Browse files Browse the repository at this point in the history
fixes #28
  • Loading branch information
fdintino authored Jul 8, 2024
1 parent fb3a89c commit 506b7ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pillow_avif/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,14 @@ AvifDecoderNew(PyObject *self_, PyObject *args) {
max_threads = default_max_threads;
}
self->decoder->maxThreads = max_threads;
#endif
#if AVIF_VERSION >= 90200
// Turn off libavif's 'clap' (clean aperture) property validation.
self->decoder->strictFlags &= ~AVIF_STRICT_CLAP_VALID;
// Allow the PixelInformationProperty ('pixi') to be missing in AV1 image
// items. libheif v1.11.0 and older does not add the 'pixi' item property to
// AV1 image items.
self->decoder->strictFlags &= ~AVIF_STRICT_PIXI_REQUIRED;
#endif
self->decoder->codecChoice = codec;

Expand Down
Binary file added tests/images/chimera-missing-pixi.avif
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/test_file_avif.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ def test_p_mode_transparency(self):

assert_image_similar(im_png.convert("RGBA"), Image.open(buf_out), 1)

def test_decoder_strict_flags(self):
# This would fail if full avif strictFlags were enabled
with Image.open("%s/tests/images/chimera-missing-pixi.avif" % CURR_DIR) as im:
assert im.size == (480, 270)


class TestAvifAnimation:
@contextmanager
Expand Down

0 comments on commit 506b7ad

Please sign in to comment.