-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add AVIF plugin (decoder + encoder using libavif) #5201
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
Changes from 1 commit
3878b58
e2add24
e5494a2
8b8bbba
58ef692
d6a0a15
50b993a
671e3c8
658cdf3
7225cb9
3730bf2
c40bcbf
d76ae2f
9ad8311
de4c6c1
524d802
7b73d77
a56acd8
f5dc957
8d77678
4eaa6b7
bdb24f9
ddc8e7e
b585f9e
da2e18d
9b6e575
3a9a3ab
9328932
be02830
4135664
29c158d
4c63ea6
ce6bf21
4b29af4
38f0d10
1410d23
6cbad27
19ba2dd
4508f37
7de1212
e1509ee
0590f08
5761b44
38b9941
10dfa63
9abfdbc
d80ac3c
b4eec64
d552087
79f7339
46f4508
9bebf37
5da2113
0732554
9ea5e3d
fca6df2
024a894
2ba9356
fdc68e6
9e63868
eff2680
fb096e1
1276543
c8d0408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from io import BytesIO | ||
|
||
import pytest | ||
|
||
from PIL import Image | ||
|
||
from .helper import is_win32, skip_unless_feature | ||
|
||
# Limits for testing the leak | ||
mem_limit = 1024 * 1048576 | ||
stack_size = 8 * 1048576 | ||
iterations = int((mem_limit / stack_size) * 2) | ||
test_file = "Tests/images/avif/hopper.avif" | ||
|
||
pytestmark = [ | ||
pytest.mark.skipif(is_win32(), reason="requires Unix or macOS"), | ||
skip_unless_feature("avif"), | ||
] | ||
|
||
|
||
def test_leak_load(): | ||
from resource import RLIMIT_AS, RLIMIT_STACK, setrlimit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you importing this inside a function, and that twice (l. 22, l. 32)? I'd rather move the import to the top... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good question. This was copied from the leak test for jpeg2000 here. I suspect that was done because those imports will fail on windows (judging by the skip pytest mark above it). But those could be handled at the top of the file with an |
||
|
||
setrlimit(RLIMIT_STACK, (stack_size, stack_size)) | ||
setrlimit(RLIMIT_AS, (mem_limit, mem_limit)) | ||
for _ in range(iterations): | ||
with Image.open(test_file) as im: | ||
im.load() | ||
|
||
|
||
def test_leak_save(): | ||
from resource import RLIMIT_AS, RLIMIT_STACK, setrlimit | ||
|
||
setrlimit(RLIMIT_STACK, (stack_size, stack_size)) | ||
setrlimit(RLIMIT_AS, (mem_limit, mem_limit)) | ||
for _ in range(iterations): | ||
with Image.open(test_file) as im: | ||
im.load() | ||
test_output = BytesIO() | ||
im.save(test_output, "AVIF") | ||
test_output.seek(0) | ||
test_output.read() | ||
fdintino marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry if this has already been covered, can these images be distributed under Pillow's MIT-CMU licence?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure about
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've replaced rgba10.heif and chimera-missing-pixi.avif with images based off of 'hopper.png'. |
Uh oh!
There was an error while loading. Please reload this page.