Problem/Motivation
AVIF image file format is getting traction in browsers' support.
Write up with examples https://jakearchibald.com/2020/avif-has-landed/
This issue is proposing to implement support to this image format in Drupal core's GD Toolkit.
When this issue was opened, browser support for AVIF was roughly 62%. It's now roughly 94%. This is getting close to the level of support for WEBP, which is roughly 96%, and is the format Drupal uses for image styles in the standard profile.
Done:
- libgd should support the AVIF format - DONE, first release supporting is 2.3.2, released on: March 6, 2021
- a PHP version supporting an IMAGETYPE_AVIF constant - upstream PR https://github.com/php/php-src/pull/5127 - supported with PHP 8.1
- a DrupalCI testbot container should be available for testing.
- #3239935: Refactor ToolkitGdTest
- a bot with a PHP 8.1. instance compiled with
libavifsupport - a PHP 8.2 bot to test getimagesize() on AVIF
- #3116611: Add a requirements check for GD support of allowed image types
- Bots having PHP instances that can fully support AVIF files - currently the bots' PHP, 8.1 and 8.2, cannot save files via
imageavif(), the (bundled?) GD library is missing an appropriate codec supporting the write. (Also see https://bugs.php.net/bug.php?id=81217 , https://github.com/php/php-src/pull/7526 )
Proposed resolution
Extend the GD toolkit to support AVIF too.
Remaining tasks
Figure out what to do about the fact that AVIF has to be compiled into PHP and that automatic detection is hard.
https://github.com/libgd/libgd/issues/782
https://github.com/php/php-src/pull/7526
User interface changes
new conversion format available for image effect "convert"
API changes
no
Data model changes
no
Release notes snippet
GDToolkit now supports the AVIF image format.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3202016
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3202016-let-gdtoolkit-support
changes, plain diff MR !936
Comments
Comment #2
mondrakeComment #3
benmorss commentedThanks for creating this issue... this is exciting!
The relevant libgd release is on its way.
I imagine Drupal uses PHP's
getimagesize()function, which will need support here as you mention... is that right? Is anything else needed?Comment #4
mondrakeYes, that's right. We'll then need a PHP version compiled with AVIF support released, and a DrupalCI testbot running it to allow testing. Unless we want to take a different implementation path than what happened for WebP.
Comment #5
mondrakelibgd 2.3.2 released today
Comment #6
andypostUpdated IS with existing issue for PHP https://bugs.php.net/bug.php?id=78832
Comment #7
mondrakeThere’s a GitHub PR to add Avif support to getimagesize, https://github.com/php/php-src/pull/5127
Comment #8
benmorss commentedThere's already a PR to add AVIF support to
getimagesize()? That's spectacular!Talking to PHP core maintainers this weekend, I learned that PHP's GD diverged from libgd long ago. So my libgd PR needs to be adapted for the PHP codebase.
Fortunately that's mostly a matter of allowing it to build with libavif, customizing the main code, and a few other things.
Comment #9
avpadernoComment #10
hestenetI will coordinate with @mixologic on the process to make a testbot available.
Comment #11
wim leersSuper exciting, thanks so much @benmorss! 😊
Comment #12
andypostMeantime I used to try use avif via brand new ffi PHP extension https://github.com/andypost/php-ffi-libavif
Looks it's enough just 3 library structures and functions to read size, so promising to get support in PHP 8.1 but then a question of conversion appears...
Right now only imagemagick (not graphicsmagick yet) can be used via dgo.to/imagemagick
PS: PHP pecl extension imagick for PHP 8 just got alpha release
Comment #13
benmorss commentedI've started doing the work to propagate the libgd support into PHP's bundled gd fork. The PHP folks tell me there shouldn't be trouble getting this into PHP 8.1.
I just won't get to finish this up until April. (Unless, of course, someone gets inspired to do it sooner 😃)
But, yep, imagemagick already supports AVIF via libheif. I haven't tried out their implementation, so I don't know what they've chosen for encoding defaults and the like.
Comment #15
andypostSupport for bundled libgd commited via https://github.com/php/php-src/pull/7026
The implementation AVIF support for getimagesize() and imagecreatefromstring() looks ready, so chances are high to get support in 8.1
Comment #16
benmorss commentedIndeed, it's looking good! https://github.com/php/php-src/pull/7091 will add that support, and it's in review right now.
The algorithm I used to determine whether an image's AVIF comes right from Joe Drago, a core maintainer of libavif.
Note that there's no reliable way to determine an AVIF image's size without lots of context, so PHP will simply return 0's for height and width. But it will tell you definitely whether the image's indeed an AVIF.
Comment #17
andypostLast brick landed into PHP 8.1! Thank you @benmorss a lot to make it happen!
Comment #18
mondrake#17 great news!
That's weird... and inconsistent with other image types. But, OK. For the purpose of this issue, this means that AVIF files will not be able to be 'lazy-loaded' like other files. Since the toolkit is invoked also to return height and width, when an AVIF will be in the scope, the toolkit will have to load the file even if it's not going to be manipulated by toolkit ops.
Comment #19
andypostComment #21
mondrakeFirst try. Will fail for any PHP below 8.1.
Comment #22
mondrakeWe need to wait for #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves).
Comment #23
andypostBeta1 ready to be build https://downloads.php.net/~ramsey/
Using
--with-avif(requireslibavif-dev) and build-inlibgdit could be tested (asked @mixologic)Comment #24
andypostCurrently only polishing PR left for coming beta-RC times https://github.com/php/php-src/pull/7253
Comment #25
benmorss commentedSorry I missed the recent comments here! @andypost, thanks for trying this out and making comments in the PHP repo as you find things.
To @mondrake:
I agree. Joe Drago, a lead on libavif, has simply told me there's no simple way to reliably get an AVIF image's height and width. Of course, if you link to libavif, you can do it that way. The problem here is that
getimagesize()does not use gd.On the other hand, if you create a GD image with
imagecreatefromavif(), you can get its width and height usingimagesx()andimagesy(). Does that help at all?Comment #26
mondrake#25 @benmorss yep that's what we need to end up doing. The point here is that
imagecreatefromavif()will load to memory the entire image file with IO overhead and possibly its processing before it is available to GD functions. On the web, sometimes (many times) it's sufficient to know h/w to fill in the appropriate html attributes for the<img>tags, so that HTML pages can be rendered appropriately. With other formats, it's very handy to get it viagetimagesize()'cause it won't need to load the entire image file, it's more or less able to get that info from an initial portion of the file, like magics for MIME type identifications.In #2244359: Lazy-load GD resource in GDToolkit, we made Drupal's GD toolkit load the resource (in PHP 8, the
GDImageobject) only when the toolkit needs to manipulate it (scaling, resizing, etc etc). With AVIF we'll have to load the image file completely everytime, which is less optimal.Comment #27
andypost@mondrake the
imagecreatefromavif()using memory stream implementation IIRC so it will not load whole file when only metadata requiredComment #28
mondrake#27 @andypost good then - still we'll have to adjust the toolkit not to lazy load in case of AVIF.
Comment #29
benmorss commented#26 @mondrake yeah, I know it's sadly quite inefficient to go through the overhead of creating the gd image just to get its size. I saw how simple it is for PHP to get dimensions for other types of images. I wish AVIF was the same!
Joe points out that libavif itself doesn't take much work to read an image and get to the point where it knows things like its size. I guess we could use libavif in this way, but I can only imagine the complexities that would come with providing and running a binary along with Drupal 😭
Comment #30
mondrakeToolkitGdTest::testManipulations()is a monster that dates back to simpletest when multiple tests were performed in a single method to avoid multiple installations. In the era of Kernel tests, it's better split it in more understandable bits.The test under 8.1 returns segmentation faults which is not good news.
Comment #31
benmorss commentedYour test hit a segfault?
Have you reported that in the PHP project? It sounds concerning.
Comment #32
mondrakeThere’s still too much noise in Drupal core itself running on PHP 8.1, I wouldn’t start pulling my hair yet.
I am waiting for AVIF support to be available on GitHub Actions https://github.com/shivammathur/php-builder/issues/12 so to do some isolated tests there.
Comment #33
andypost@mondrake you could use Alpinelinux testing repo to build your image
Comment #34
benmorss commented@mondrake, as far as
getimagesize()goes, tentative good news: some folks at Google who specialize in AVIF are working on writing something compact that could be used to get the size of an AVIF image. If they succeed, I'll submit a patch for PHP 8.2.Comment #35
andypostI think we could add extra logic around
getimagesize()because AVIF could have a set of image sizes so making "thumbnails" logic needs changes to select the most optimized base to applyimagestyle's pluginsComment #36
mondrakeSe we definitely have a segmentation fault with AVIF. I suspect it's when saving an AVIF image to storage, since converting an AVIF to a GIF/PNG/WEBP works (even if we do not have the expected colors at corners).
I also suspect it is due to saving to a stream wrapper.
EDIT - segfault is not related to stream wrapper - it's just
imageavif()failing.Comment #37
mondrake@benmorss re #31 it looks like this is already known, https://bugs.php.net/bug.php?id=81217
Comment #38
mondrakeIt would be good to do also #3116611: Add a requirements check for GD support of allowed image types before this issue. New image types add new requirements in terms of libraries to be available, we do not really have ways to prevent WSODs at the moment if the GD toolkit tries to call 'expected' functions that are however not compiled in.
Comment #39
benmorss commented@mondrake, is this then caused by the lack of an AVIF codec?
If so, it was fixed in the GD project . I've asked Pierre if he could replicate this work in PHP....
Comment #40
mondrakeI do not know, but that seems a possibility. Is there an issue on github or php.net we can link here?
Comment #41
andypost@mondrake @benmorss I did fix it only in alpine:edge with https://git.alpinelinux.org/aports/commit/?id=e4fba93fd9d83f520645469cae...
Moreover version of "libavif" in alpine 3.14 is 0.9.1 so I asked maintainer to upgrade it https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/25866
Comment #42
andypostI'm packaging
skilldlabs/php:81image and it works for meComment #43
benmorss commented#3202016-40: Let GDToolkit support AVIF image format @mondrake: yes!
libgd: https://github.com/libgd/libgd/issues/770
php: https://bugs.php.net/bug.php?id=81217
Comment #44
andypost@benmorss any idea why libavif is not displaying version of library via
phpinfo()I think it could be handy looking like other image-types doing itComment #45
benmorss commented@mondrake re #41... thanks for adding that to alpine!
This AVIF support has been designed to work with libavif with version >=0.8.2. Though of course later is better.
I realize that we didn't require a particular version of libavif in PHP. Should change that.
Comment #46
benmorss commented@andypost #44: it's because we never added this to
phpinfo()🙄.Looks like that would be a simple change to gd.c. When I get a minute, I can submit a PR.
Comment #47
andypostFiled PR https://github.com/php/php-src/pull/7526 to simplify debug
Comment #48
mondrakeI spinned off the refactoring of ToolkitGdTest into a issue of its own, #3239935: Refactor ToolkitGdTest.
In HEAD this test is in pretty miserable state, it's very hard to add image types to the tests; the refactoring I started here would be helpful for readability regardless of adding AVIF. Reviews appreciated ;)
Comment #49
andypostFYI displaying of version string for libraries only possible when PHP is built with bundled GD
Comment #50
mondrakeComment #52
andypostSupport for
getimagesize()just yet commitedComment #53
andypostComment #54
catchIs this now [PP-2]?
Comment #55
andypostI bet it depends on only one child issue
Comment #56
andypostNot sure it should be blocked on tests refactoring
Avif is bundled in 8.1 or disabled as other formats are
Comment #57
mondrake@andypost retargeted MR to D10, feel free to take this over
Comment #58
xjmDiscussed with @catch and @andypost. This issue requires PHP 8.1, so cannot be backported to 9.5. That means we would not have branch parity between 10.0 and 9.5 for this functionality. However, if no deprecations are required to add support for it, it could theoretically be backported to 10.0.x if it is ready in time for the beta deadline. It can also go into 10.1.x.
Per @catch:
Tagging for RM review so we can evaluate it one final time before committing to 10.0.x without 9.5.x.
Comment #59
mondrakeNote: full
getimagesize()support for AVIF is only added in PHP 8.2https://github.com/php/php-src/commit/38460c2c94a0d4b110060951a1a5657522...
Comment #60
mondrakeComment #61
mondrakeComment #62
mondrakeWorking on the rebase.
Comment #63
mondrakeWe would also need a PHP 8.2 bot to test getimagesize() on AVIF returns proper height and width.
Comment #64
mondrakeWe also need a PHP instance compiled with
libavifsupport. See also https://github.com/shivammathur/php-builder/issues/12That's likely the reason for the 'Segmentation fault' test failures in latest version of the MR.
Comment #65
mondrakeSee issue summary.
Comment #66
mondrakeComment #67
andypostIn related issue I've explained how to add this support #3283449-17: Create a DrupalCI Environment for PHP 8.2
Moreover you can use alpinelinux php8/php81 packages which has support, also there's pre-build docker images we are using https://hub.docker.com/r/skilldlabs/php/tags/?page=1&name=81
Comment #68
mondrakeComment #69
mondrakeComment #70
mondrakeComment #71
pere orgaNote that AVIF images are terribly slow to create, and are usually suitable to be generated offline. As Drupal generates image styles when the page loads, that could actually harm the visitor experience the first time.
Ideally, AVIF images could be generated when images are uploaded (I think in WordPress they are trying to do that).
JPEG XL format would be more suitable for online conversion, but unfortunately is still unsupported in all browsers.
Comment #72
andypost@Pere Orga true, the creation is not that fast but there's enough solutions in contrib to pre-generate/warm images.
Moreover there's #2986669: Split ImageStyle into the config entity and a separate event-based image processing service
Comment #73
MixologicI've updated both the 8.1 and 8.2 containers to use debian bullseye now, so we should have a more modern version of avif compiled in.
Comment #74
mondrake@Mixologic great thanks! Rebased, let’s see now how it flies.
Comment #75
andypostRe-queued as phantomjs failed
Comment #76
mondrakeAlbeit small, we do have progress after #73. Now the AVIF image saving tests no longer produce a segmentation fault, but a more palatable
imageavif(): avif error - Could not encode image: No codec availableSo we still have a problem with availability of the codec to actually save GD to an AVIF file - https://bugs.php.net/bug.php?id=81217
AVIF support seems still too fragile to me... how many real world PHP 8.1 installations out there will have all the dots and the bars to support it? For sure we need to put in place whatever we can to detect possible issues, after #3116611: Add a requirements check for GD support of allowed image types will be in.
Comment #77
hestenetA new testing environment called: "9.3.x-dev test with PHP 8.1 & MySQL 5.7 w/Bullseye Upgrades" has been added, which may be useful here.
Comment #78
andypost@hestenet I did rebase but there's no way run new pipeline as issue using Merge Requestsorry https://www.drupal.org/pift-ci-job/2446376 after sometime it said MR is mergeable and allowed to start custom
Comment #79
andypostSadly tests fail even more
Comment #80
hestenet@andypost - ah bummer. Any guesses what else we might need to configure to get the codec in there properly?
Comment #81
benmorss commentedJust wandering back in here for a minute, without having seen the details of your work - so if this comment is irrelevant, please ignore.
But did you build libavif with a codec? When I worked with it, I remember using aom.
Comment #82
andypostIt needs both
aom-devanddav1d-devto build libavif to support encode and decodeIn Alpinelinux we use https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/libavif/...
Comment #83
mondrakeWould it be possible to detect WITHIN PHP if libavif is built with such libraries?
gd_info()is only checking if GD was compiled with libavif AFAICS, regardless of codecs being included or notComment #84
andypost@mondrake I filed https://github.com/libgd/libgd/issues/782 and related PR to PHP but both needs work
Comment #85
andypostUsing the patch from https://github.com/php/php-src/pull/7526 I see following output
EDIT I bet
dav1dis optional asaomalready provides decoderComment #86
mondrakeThank you for #85, I added a comment to the github PR - please lobby there :)
Comment #87
mondrakeComment #88
mondrakeSince the feature is targeting D10.1, the conditional support based on PHP version is no longer relevant. Updating IS.
Comment #89
andypost8.2 CI image is ready now so requeued https://www.drupal.org/pift-ci-job/2488891
Comment #90
mondrakeComment #91
mondrakeComment #92
mondrakeSo the patch per se is OK now, what we miss is Codec implemented in the bots' PHP instances. With Codec installed, it should be green.
With PHP 8.1. this has a knock-out effect of a segfault when trying to save the image; with PHP 8.2, an error is thrown, which is better, at least with #2583041: GD toolkit & operations should catch \Throwable to fail gracefully in case of errors we'd probably be able to prevent WSOD.
PHP misses a solution to self-detect if AVIF is fully supported or not, unfortunately. Right now, with no codec, the status report will still tell you that AVIF is supported.
Comment #93
hestenetDrupalCI's PHP 8.1 and 8.2 containers have been recompiled, they now have both libavf and libaom:
Hopefully that does it, but let us know if it looks like anything else should be added to the container.
Comment #94
mondrakeThank you! I rerun the tests - they still fail, though. We’re still at the same status as in #92.
Comment #95
mondrakeJust throwing a thought (beware: not a PHP build expert :))
Could it be this is because the bot's PHP instances use the bundled GD library, and not the externally linked one? That's at least my take from #2921123-65: Adjust Rectangle class to calculate rotated image dimensions according to libgd 2.2.2+. In that case, that seems not the usual case on *nix machines, see comment https://github.com/php/php-src/pull/7526#issuecomment-1214957123
Comment #96
andypostPHP should be built with bundled GD but it needs configuration
--with-avif+ see #41https://git.alpinelinux.org/aports/tree/community/php81/APKBUILD#n266
Comment #97
hestenetThe 'with-avif' flag is already set:
PHP 8.1:
PHP 8.2
Note: we generate dockerfiles using an M4 template: https://git.drupalcode.org/project/drupalci_environments/-/blob/producti...
And finally here's the build log for the last run.
EDIT: I think this part of @andypost's comment may be what's missing: https://git.alpinelinux.org/aports/commit/?id=e4fba93fd9d83f520645469cae...
Comment #98
andypostFiled MR to finally fix
libavif#3283449-37: Create a DrupalCI Environment for PHP 8.2TL'DR library needs suffix to be installed from backports
Comment #99
hestenetRequeued tests on the MR to see if changes from #3283449-44: Create a DrupalCI Environment for PHP 8.2 work..
Comment #100
mondrakeThe 8.1 test run is green, and the 8.2 one is not failing on the GdToolkit test -> AVIF is now working on the bots!! Thanks to @andypost, @Mixologic and @hestenet for the great work here and in Slack
The biggest question now is: do we want to support AVIF right now, when getting PHP setup right is non-trivial, and it's not possible to detect if all bits and pieces are correctly in place?
gd_info()can tell us if AVIF is enabled, but that's not enough: if the codec is not installed, there is no way to understand it until an error occurs e.g. trying to save an AVIF image.Comment #101
mondrakeComment #102
andypostTrying to save file when no encoder enabled will throw but it looks like weird way to test codec absence
Comment #103
hestenetI think coming up with some form of automatic detection of support (+ really good documentation) is going to be crucial, given how tough it was for us to get all the pieces together even in our test environments.
Comment #104
mondrakethat's what https://github.com/libgd/libgd/issues/782 and https://github.com/php/php-src/pull/7526 would tentatively provide, respectively for GDlib and PHP embedded GD. But they both seem still quite far, and will likely be addressed only in future versions of both...
Comment #105
andypostCreated follow-up #3325219: Remove workaround for PHP < 8.2 in GDToolkit when core require 8.2+
Comment #106
andypostadded the todo-link and rebased for current 10.1.x
Comment #107
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #108
mondrakeRebased
Comment #109
andypostit's RTBC IMO but needs summary update and CR, probably release note as well
Comment #110
kim.pepperAdded a simple CR and RN snippet https://www.drupal.org/node/3348348
Comment #111
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #112
andypostRebased and applied suggestion for strict comparison
Comment #113
quietone commentedFYI, it seem there are problems with the diff.
Comment #114
mstrelan commented@quietone that seems like a gitlab issue. The .patch URL (instead of .diff) shows the binary content of the avif file.
Comment #115
quietone commented@mstrelan, thanks. I forgot about the .patch version
Comment #116
catchI think we can add support independently, but both this and the existing webp support make #3213491: Add fallback format support to responsive images more important so that sites can actually use it. Adding as a related issue.
Does the GD toolkit already handle whether the webserver has support for AVIF - i.e. does it only show in the list of options if it's actually going to work?
Comment #117
andypostThe check was added in #3116611: Add a requirements check for GD support of allowed image types
but not every place in core using the filtered list of formats, probably there was an issue about add general requirements check
Comment #118
andypostThere's a set, hope it addresses #116 points
Comment #119
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #120
andypostThere's binary file in patch, so to apply patch it needs to download it and apply using
git apply 936.patchor usepatch -p1 -i 936.diff(it should be downloaded https://git.drupalcode.org/project/drupal/-/merge_requests/936.diff using .diff instead of .patch)Comment #121
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #122
nod_Comment #123
mondrake@catch re #116 - yes the toolkit will tell if AVIF is available, but that check is unfortunately not enough. In order to have FULL support, PHP needs to be compiled with an AVIF codec, and that’s non-trivial, see #100 and #103; besides, there’s no way to detect automatically if the codec is installed, see #104.
Comment #124
catchThanks @mondrake I had read that earlier in the issue but had forgotten about it by now - I've added both of those to the issue summary. Also thanks to @andypost for opening them and working on them!
I wonder a bit if we should do some kind of kludgy support detection by catching the error in the meantime until those issues are fixed (or at least until AVIF is more widely available?), not sure where to put that though and if it's expensive we might have to cache the results or something.
Comment #125
andypostMeantime animated AVIS added to latest Firefox https://www.mozilla.org/en-US/firefox/113.0/releasenotes/
Comment #126
jwilson3Given the bleeding edge support (php 8.2) for AVIF, and complexity in it being compiled into PHP, it occurred to me that there should be an option to work around those limitations in contrib space. Alas, there is no conversion image style effect feature that I could find, so I opened up a feature request in what seemed like the most logical place to put it.
#3360072: Add an AVIF conversion image styles effect
Sadly that module doesn't seem like it has been getting a lot of love, use, or maintenance for a few years now.
Comment #128
smustgrave commentedCan MR be updated for 11.x
Also open thread mentions needing a follow up if that could be created also before the new branch is made.
Comment #129
smustgrave commentedReading wrong commit forget the follow-up part.
Comment #130
mondrake@andypost done, I guess this needs a rebase now
Comment #131
andypostRebased
Comment #132
smustgrave commentedChanges look good and all tests green.
Comment #133
mondrakeUnfortunately there’s no solution for #124 yet, and IMHO getting this in as it is now would be very fragile.
NW for #124.
NOTE: the Imagemagick toolkit is a working alternative (as long as the Imagemagick binary can support AVIF itself).
Comment #134
andypostRebased and sqashed commits into 2 for 11.x branch
Comment #135
andypostFiled upgrade of PHP 8.3 CI image to latest Debian stable, AVIF is shipped now with
libaomdependency fixedhttps://git.drupalcode.org/project/drupalci_environments/-/merge_request...
Comment #136
andypostUpdated is with https://jakearchibald.com/2020/avif-has-landed/ which perfectly explains benefits
Comment #137
andypostI think we can add to reports if no AVIF support available so people can read logs to get why imagecreatefromavif() or imageavif() are not found to solve #124
Comment #138
mstrelan commentedUnfortunately these functions still exist, even if avif is not supported. I did find the following code (found in https://bugs.php.net/bug.php?id=81217) would trigger a warning:
I've tried to test for this in the status report using a pattern I found in \Drupal\Core\Render\ElementInfoManager::buildInfo. This works in my very limited test of two environments, one supporting AVIF, one not.
Comment #139
mondrakeRebased
Comment #140
luksakI needed that for AVIF to work with imagemagick, but probably that is needed for GD as well: #3362088: ExtensionMimeTypeGuesser doesn't support .avif
Comment #141
mondrakeI put some caching around @mstrelan solution + added some info in status report if AVIF write support is broken.
This fits #124 I think so back to NR.
IMHO the CR should be expanded with some hints on how to fix the lack of the codec or of the binding of libavif. That’s above me though, help appreciated.
Comment #142
smustgrave commentedNot sure correct status, but #141 mentions change record updates. Which is technically apart of the review process.
Comment #143
mondrakephp/php-src just committed Image format detection false positives with external GD #12019. This will likely only hit PHP 8.4.
Comment #144
andypostCore's CI images are not yet using external GD https://git.drupalcode.org/project/drupalci_environments/-/blob/producti...
Comment #145
andypostNot sure CR should elaborate how specific distros can install codec if it missing, it's unrelated to core
Comment #146
smustgrave commentedBrought up in #needs-review-queue-initative in slack. Was mentioned by @catch that
and that parts will need the release manager review.
Comment #147
smustgrave commentedWonder if anyone has any update for the previous comment?
Comment #148
jwilson3I also don't know much about fixing this by compiling PHP, but I can add that the avif contrib module allows selection of different processors beyond just the GD option, including https://github.com/kornelski/cavif-rs (via the avif_lib add-on module). So maybe the CR could point people to the issue I linked above if they're not able to compile PHP with the codec support on their hosting environment. #3360072: Add an AVIF conversion image styles effect
Comment #149
larowlanThe code here looks good to me.
The needs release manager review tag was added in 9.x era when we were discussing min PHP requirements.
I don't think we need it anymore - especially as we're into 11.x territory where 8.2+ will be available.
I think the remaining tasks here are to update the CR with instructions for folks on how to add avif support to their version of PHP
Tagging as NW for that.
Great work here folks
Comment #150
heddnWe are in Drupal 11.1-land now. Which will require PHP 8.3. I've updated the related CR to include libavif installation instructions. Back to NR.
Comment #151
andypostMerged 11.x and removed PHP 8.2 related workaround
I simplified check to prevent checking avif writes if no readonly support
Comment #152
smustgrave commentedMoving to NW for open questions on MR.
Comment #154
acbramley commentedAll threads resolved and a green pipeline 🥳
Comment #155
heddnLGTM. All concerns addressed.
Comment #156
alexpottMade a couple of suggestions on the issue.
Comment #157
andypostThank you, applied clean-up!
Comment #158
andypostbtw it could use follow-up to add UI to configure quality and speed for images in terms of #3372932: [Meta] High-performance images (nearly) out of the box
ref https://www.php.net/manual/function.imageavif.php
Comment #159
alexpottAdded some more comments to the MR.
Comment #160
andypostI see no reason to use cache except of
staticvariable because this check should happen only once while PHP is runningComment #161
andypostRemoved cache as this kind of checks should be cached statically, also removed useless logging of error
Comment #162
andypostThanks Alex! I did rebase on top of 11.x and reverted all unrelated changes
Comment #163
smustgrave commentedBelieve feedback for this one has been addressed
Comment #164
mstrelan commentedWould be great to get this in 11.2
Comment #165
mstrelan commentedAdded some info to the issue summary about browser support, which is now around 94%.
Comment #166
alexpottCommitted 71c58d6 and pushed to 11.x. Thanks!
Fixed gitattributes on commit to make .avif files easier to manage - this resolves #113
Comment #171
longwaveThis is more of a highlight than something that needs a release note.
Comment #172
cilefen commented