- Issue created by @greg.harvey
- π³πΏNew Zealand quietone
If this problem was discovered on a version of Drupal that is not 11.x, add that information in the issue summary and leave the version at 11.x. In Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies β . Also mentioned on the version β section of the list of issue fields documentation. Thanks.
- First commit to issue fork.
- Merge request !12601ignore php warnings from imageavif(), codec may not be installed β (Open) created by nicrodgers
- π¬π§United Kingdom nicrodgers Monmouthshire, UK
We were experiencing this php warning in our behat test suite after upgrading from 11.x to 11.2
It's caused by a combination of old linux system (in this case, Debian 11) and PHP misbehaving.
On affected systems, you can reproduce the error by running
$ php -r 'var_dump(imageavif(imagecreatetruecolor(8, 8), "/tmp/test"));' PHP Warning: imageavif(): avif error - Could not encode image: No codec available in Command line code on line 1 Warning: imageavif(): avif error - Could not encode image: No codec available in Command line code on line 1 bool(true)
As you can see, php thinks it has avif support because it's returning true (you can also see this in the phpinfo output within the gd section) but the reality is that it's unable to create avif files because the codec is missing and gives that warning.
There's a bug on php.net for it:
https://bugs.php.net/bug.php?id=81217The php bug has been closed as not a PHP bug - they say:
So, it seems that the root cause of this issue is that the libaom versions currently provided by Debian APT and Alpine APK systems are not functional (AFAIK they are compiled without the required BUILD_SHARED_LIBS=1, but I may be wrong here).
So, in order to make imageavif() and imagecreatefromavif() work, you need to do everything by hand:1. compile and install libaom
2. compile and install libdav1d (to decode AV1)
3. compile and install libyuv (used by libavif to better handle YUV decoding)
4. compile and install libavif
5. compile and install the gd PHP extension (with the --with-avif flag)For an example about how that can be done in Debian (so, Ubuntu too) and Alpine, you can take a look at https://github.com/mlocati/docker-php-extension-installer
Personally I think the php team are being dismissive here. Clearly it is a bug that could be better handled in php, because on the one hand php is saying YES, AVIF is supported here, and then on the other, when you try to use it it errors out because the codec is missing. But we are where we are.
For Drupal, I think the easy fix here is to suppress the warning from the imageavif() command within checkAvifSupport(). The function correctly returns FALSE on the affected systems so I think it's fine to suppress the php warning.
- πΊπΈUnited States smustgrave
Temped to tag for tests but don't know what they would be, but summary still needs to be updated please.