-
Notifications
You must be signed in to change notification settings - Fork 824
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
AVIF support #1314
Comments
Hi,
|
I opened python-pillow/Pillow#5201, which would make it possible for thumbor to support the format. |
Any news ? |
https://github.com/libvips/libvips It supports a good range of image formats, including JPEG, JPEG2000, JPEG-XL, TIFF, PNG, WebP, HEIC, AVIF, FITS, Matlab, OpenEXR, PDF, SVG, HDR, PPM / PGM / PFM, CSV, GIF, Analyze, NIfTI, DeepZoom, and OpenSlide. |
You can try the ImageMagick engine. You'll need Thumbor from master, though. Let me know if it works, please. |
It's been taking a while to get the pillow PR merged. To be fair to the pillow developers, it's not a trivial new feature. Until that PR lands I've created a standalone package, pillow-avif-plugin, that adds AVIF support to Pillow. Also, unlike my pillow PR—which only works in python 3—my standalone package has wheels built against python 2. This is because the latest stable version of thumbor is still python 2-only. I'm currently testing out an extension of thumbor and thumbor-video-engine on https://www.theatlantic.com/ that adds auto-AVIF support. If you visit the site in chrome, you'll see a bunch of AVIF images being served in the Network tab in the web inspector. The source code for that isn't publicly available, but if it goes well I'm planning on creating a package for it. |
@fdintino I have used pillow avif plugin, it worked nice. But I dont know how to apply it into thumbor. Example I want to crop image, then convert it to avif image. I read a lots but nothing found. Can you give some guide? Thanks so much |
Do you know whether browsers inform whether they support AVIF using the accepts header? |
Chrome supports image/avif, and has it in the Accept headers for images. And Firefox does as well if the experimental flag is enabled. Sorry I haven't posted an update here yet. The code required to extend the auto_webp functionality to auto_avif isn't trivial: you need to extend On top of that you need a custom image engine that allows you to control things like the quality and codec of the AVIF encode via settings. And you need to make sure that the result_storage stores the auto-avif images in a separate location (whether that's the file_storage or tc_aws). I've also written code to use the thumbor threadpool to perform the AVIF encoding in the background. The first time an AVIF image is requested for an auto-avif capable image, it returns whatever non-AVIF format would be the default (with a short cache TTL) while it queues up a background encode. Once the encoding is complete in the background thread, it saves the AVIF image to result storage, after which point requests for that image that Accept: image/avif get served the image from storage. I ran into some oddities while working on this feature. For instance: Chrome will happily serve up a JPEG image that's encoded with 3 RGB channels but has a CMYK color profile, but it will refuse to do the same for an AVIF image (which has YUV channels). Images that have RGB data but CMYK color profiles are probably pretty uncommon generally, but they crop up fairly often when you're working with images that were originally intended for print. So I had to write a function that checks the color profile and transforms it to sRGB if necessary. All of which is to say that there's still some work to do (mainly documentation and packaging) before it can be published in a public repository. But I still intend to do so. |
This issue is stale because it has been open 30 days with no activity. Remove the stale label or add a comment, or this issue will be closed in 5 days. You can always re-open if you still feel this is still an issue. Tag @heynemann for more information. |
AVIF is spreading, see https://caniuse.com/?search=avif Bumping this issue (stale-bot 🎉 ) |
I will bootcamp this task later. This seems like a good L3 task. |
@heynemann Adding avif directly to thumbor as a PR would certainly be easier for me than maintaining an extension, if that's something you would welcome |
I would @fdintino but we will probably revamp how we handle alternate image formats to remove webp as a special case and just let web formats be extensible. I think that's a better point to add than to just add a bunch more if-else statements (we do have enough of those as it is). |
This issue is stale because it has been open 30 days with no activity. Remove the stale label or add a comment, or this issue will be closed in 5 days. You can always re-open if you still feel this is still an issue. Tag @heynemann for more information. |
@heynemann would you be open to my attempting such a refactor and opening it as a PR? I've written code for theatlantic.com that supports auto-webp, auto-avif, and auto-h265 (for animated gifs on safari). It's not open source, largely because it's such a hack. But the experience of extending thumbor to support it has made me pretty familiar with the auto-convert code, and has given me an understanding of where the pain-points are. |
Definitely!!! |
share your code, let's taste it |
@heynemann Would love to see it as well! Thank you! |
This issue is stale because it has been open 30 days with no activity. Remove the stale label or add a comment, or this issue will be closed in 5 days. You can always re-open if you still feel this is still an issue. Tag @heynemann for more information. |
Posting a comment to keep this issue open. |
+1 |
Still need. |
+1 |
2 similar comments
+1 |
+1 |
just wanted to mention that macOS Ventura and iOS 16 have added support for AVIF. this means Safari 16 will support AVIF on latest macOS and iOS, which is gonna bump global browser support (currently 71%) to well over 80%. i think this makes support for AVIF pretty critical and only increasing in importance from here forward. |
This issue is stale because it has been open 30 days with no activity. Remove the stale label or add a comment, or this issue will be closed in 5 days. You can always re-open if you still feel this is still an issue. Tag @heynemann for more information. |
commenting to keep active |
This issue is stale because it has been open 30 days with no activity. Remove the stale label or add a comment, or this issue will be closed in 15 days. You can always re-open if you still feel this is still an issue. Tag @heynemann for more information. |
I think this issue need be keep open. |
This issue is stale because it has been open 30 days with no activity. Remove the stale label or add a comment, or this issue will be closed in 15 days. You can always re-open if you still feel this is still an issue. Tag @heynemann for more information. |
bump |
pretty cool to see the stale bot resulting in a PR being revived! #1476 (comment) |
You can now use this feature here Release 7.2.0 Thank you @fdintino 🚀 |
cool! So i guess there should be a dynamic thumbor response to serve webp/jpeg/gif to google image bot? Or is possible in frontend a way to fit in html the fallback in ? |
Could AVIF support expected to be added at some point similarly to
webp
in format filters?The text was updated successfully, but these errors were encountered: