-
Notifications
You must be signed in to change notification settings - Fork 13
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
Encoding with Image.save(..., "AVIF")
fails
#23
Comments
Are you able to encode the image using the |
Actually I wasn't, since libavif does not specify you have to enable additional apps like I configured with options Anyway, I can now, but I still get the same error. |
I ran into the same issue on CentOS 8 and 9. I am very confused by the error. It is being thrown by this check in libavif, which ensures that That particular Like @Sir-Photch, I was able to compile Unfortunately, github only provides ubuntu runners for linux so I cannot create a workflow that will reproduce the issue, but I'll try to reproduce this on a minimal docker image. |
What platform, architecture, and python version are you running? If there isn't a binary wheel available I can add one to CI. |
CentOS 8 and 9. AMD x86_64, python 3.10. The wheel already exists for this combo. I tried to reproduce the issue on a docker image with CentOS but wasn't quite successful, sorry. I'll keep trying and let you know if I do achieve a successful repro. |
Hi @fdintino. I'm also having the same issue, but was able to mitigate it with a small hack to _avif.c. Here's the patch:
This was a wild guess, and I don't know why this fixes it, but I'm assuming it's some race condition or some memory is getting corrupted. I know this isn't really a proper fix, but maybe it will point you or somebody with more intimate knowledge of the library in the right direction? System specsCentos 9 The following packages are installed via Conda:
I also tried this with The bug is present when installing pillow-avif-plugin either from the remote whl hosted on PyPi or installing locally from a git clone with Below follows my path of reasoning:I Googled "Encoding of color planes failed". Found this in libavif source: Searched all occurrences of Note the comment:
This leads me to believe that the Let's check in on the pillow plugin side. Right near the top we see a method called Looks like the encoder takes a Explanation of the param here: Let's just hard code this and see what happens: First let's repro: repro.py:
git clone https://github.com/fdintino/pillow-avif-plugin.git
Also most of the tests fail:
Let's try the patch: git apply my_patch.patch
No error and the output image is well-formed. After applying the patch, the test suite also looks good (save for one test failing because of some deprecated pytest feature) pytest tests
|
Ok! I found the cause. If you try to set encoder->numThreads to a value greater than 64, encoding fails. By default, pillow-avif-plugin sets numThreads to the number of cores on your machine. In my case, I have 96, so it will always fail. Propose setting a limit of 64 returned from init_max_threads: |
See this check in libavif source: |
Great sleuthing @yit-b! Do you plan to make a PR on |
Hi,
on Ubuntu 20.04.1 LTS, I am getting the following error when trying to save an image with avif format:
Since 20.04 does not provide libavif / libaom, I compiled them from source, versions being:
Are these the right versions / do I need other libraries as well?
The text was updated successfully, but these errors were encountered: