Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable decoder strictness for clap and pixi properties #57

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading