-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Reduce AVIF wheel size? #8856
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
Comments
Maybe there is no need to carry multiple encoders and decoders? E.g. libaom covers both ends (and is libavif preferred for encoding), no need to build w/ and ship dav1d and rav1e+svt-av1 as well? That being said, libaom seems to be the largest of them all (at least on my machine/platform), and dav1d seems to be preferred for decoding speed... |
Package size changed from 5.1M unpacked to 54M PIL, is that mandatory? |
See also #5201 (comment) |
The ability to test/switch between codecs is a handy feature. |
This made me sad too because my PIL venv install went from 6.4MB to 59MB which made my container image much bigger :( |
If I had to choose a codec for removal, it would probably be rav1e. Development on rav1e has been a bit stagnant, and in my opinion AOM has come out ahead of it with the 3.12.0 release. Rav1e is also quite large. I'm running a build now without it to figure out what its contribution to the wheel size is. |
I recommend including libaom for the encoder and dav1d for the decoder. @fdintino Frankie: To build an encoder-only version of libaom, pass |
Experimenting with pillow-11.2.0.dev0-cp313-cp313-musllinux_1_2_x86_64.whl, I find
|
(For comparison, pillow-11.1.0-cp313-cp313-musllinux_1_2_x86_64.whl was 4.4 MB in the last release.) |
I've updated #8858 to only include the dav1d decoder and the aom encoder in the wheel. It roughly halves the size of the 11.2.0 wheels. |
Thanks all for working on this! Here's a comparison of file size in MB between #8858 (only aomenc and dav1d codecs) and #8869 (only aom codec), comparing each size to that of 11.1.0 from January.
Note 11.1.0 had 71 files compared to 81 for 11.2+, so a small part of the increase is down to extra wheels. The initial 11.2.0 was 4.4 times bigger than 11.1.0. These new PRs are 2.0 times (aomenc and dav1d) and 2.2 times bigger (aom), much more reasonable.
And @wantehchang said:
From this, #8858 (aomenc and dav1d codecs) sound like a better choice, plus the files are a bit smaller. |
Hi. Have you considered using the Limited API to drastically reduce the number of wheels? Also, you won't need to rebuild wheels for every Python release. |
This has burst the bubble on already constrained image sizes for serverless images - and a great many serverless functions use pillow. I'd love to see support for this migrated to an extras and available through standard package tool discovery. |
@PalmtopTiger @sspencer-arine Since we're late to deliver 11.2 in #8722 (in accordance with our own release schedule), those suggestions are more likely to be implemented in 11.3 (or 12?) I'm not familiar with the Limited API … and maybe we could do |
@aclark4life thank you - but is there guidance on how to omit AVIF and any other things that came in since 11.1 if we did a local build and distributed that internally as a custom 11.2 wheel? |
@sspencer-arine you don't really need to build it from source -- it is sufficient to remove avif support from the official whl by deleting $ ls -al pillow-11.2.0-cp312-cp312-win_amd64.whl
-rw-r--r--. ed ed 13807352 pillow-11.2.0-cp312-cp312-win_amd64.whl
$ zip -d pillow-11.2.0-cp312-cp312-win_amd64.whl PIL/_avif.pyi PIL/_avif.cp312-win_amd64.pyd
deleting: PIL/_avif.cp312-win_amd64.pyd
deleting: PIL/_avif.pyi
$ ls -al pillow-11.*-cp312-cp312-win_amd64.whl
-rw-r--r--. ed ed 2680119 pillow-11.2.0-cp312-cp312-win_amd64.whl
-rw-r--r--. ed ed 2626369 pillow-11.1.0-cp312-cp312-win_amd64.whl
this is not official advice, I'm just another user :-) |
If you're building from source, then by default Pillow won't include libavif if it's not present in your environment. If it is present, or you don't know and would like to ensure that it's not included, you can disable it using a build option - |
Those who were concerned about wheel sizes will be glad to know that Pillow 11.2.1 has now been released without libavif included in the wheels. |
Hey, are there any plans/ideas how to make it smaller and ship it without need of extra building on project side? |
@petrprikryl I suspect we'll have more decisions made before the next release but ideas welcome! |
@petrprikryl #8858 has every trick I've been able to come up with to reduce the binary size. On most platforms the increased uncompressed size is between 3 and 5 MB. I doubt it can be made much smaller—after some optimizations I made yesterday I am out of ideas—so the decision will probably center around whether that is a size to allow its inclusion in the distributed wheels. |
Thank you for all your work on #8858, it's much appreciated! With a quick calculation, the total size of all the wheels is up from ~260 MB to ~469 MB, about 1.8 times bigger. That's much better than the ~4 times we had originally and I think it's an acceptable increase. |
The AVIF .so has made the wheels about 4 times bigger: #8722 (comment)
Is there anything we can do to make it smaller?
The text was updated successfully, but these errors were encountered: