deb.sury.org
deb.sury.org copied to clipboard
php8.1-gd missing AVIF support
Frequently asked questions
- [x] I have read Frequenty Asked Questions
Describe the bug php8.1-gd does not include AVIF support.
To Reproduce
- Install php8.1-cli and php8.1-gd from either ppa:ondrej/php (Ubuntu) or packages.sury.org (Debian)
- Run
php -i | grep AVIF
Expected behavior
Output should be:
AVIF Support => enabled
Distribution (please complete the following information):
- OS: Ubuntu Focal, Ubuntu Hirsute, Debian Bullseye (didn't test on other distros)
- Architecture: amd64
- Repository: ppa:ondrej/php, packages.sury.org
Package(s) (please complete the following information):
php8.1-gd:
Installed: 8.1.0~rc1-1+ubuntu20.04.1+deb.sury.org+1
Candidate: 8.1.0~rc1-1+ubuntu20.04.1+deb.sury.org+1
Version table:
*** 8.1.0~rc1-1+ubuntu20.04.1+deb.sury.org+1 500
500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages
100 /var/lib/dpkg/status
Additional context
Updated to PHP8.1 and Debian 11.2 recently and this is still an issue.
Running gd_info()
in PHP returns the following array (note the lack of AVIF Support):
Array ( [GD Version] => 2.3.0 [FreeType Support] => 1 [FreeType Linkage] => with freetype [GIF Read Support] => 1 [GIF Create Support] => 1 [JPEG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => 1 [XBM Support] => 1 [WebP Support] => 1 [BMP Support] => 1 [AVIF Support] => [TGA Read Support] => 1 [JIS-mapped Japanese Font Support] => )
I would love to use imageavif() so I hope this issue gets remedied. 😊
I think it'd be cool too, however I see libavif and dav1d are only on Debian Buster as backports - I'm not sure it's kosher to rely on another backport for basic graphics functionality on a platform. The major(?) version on Bullseye also differs from that on Bookworm, which may be an issue. Perhaps these or other issues make it complex to add.
I see. I read somewhere that avif functionality would be an added feature for Bullseye but I guess that wasn't accurate information. Or, perhaps they were just talking about for ImageMagick, not GD.
Oh, I just remembered where I read it: Debian 11 and up ... provide libavif-dev/libavif-devel packages in their default software repositories.
The library is in Bullseye, yes but not Debian 10 Buster. It is only available as a backport in Buster (though said backport is currently outdated) - so either this repo would have to depend on a backport for that distribution, or ship the libraries itself.
But this repository is provided for both stable, oldstable and LTS versions of Debian, which includes Buster and Debian 9 Stretch, and indeed (as a paid feature) Debian 8 Jessie.
I do not know the policy for varying levels of feature support depending on features in the base operating system, but I imagine it adds complexity.
So, the PHP8.1 repository would have to work with all of those Debian versions and that's why avif functionality isn't readily available? Because making it work just for Bullseye would be complicated? If so, that makes sense.
Just for clarity, I'm running Bullseye on my server (Debian 11.2) and avif support isn't available for GD but avif functionality is available for ImageMagick which I can see after running php -i | grep AVIF
.
In the meantime, is there any way for individuals to add imageavif() functionality to PHP themselves that wouldn't be too excessive? Or would it be best to wait for progress to be made on this issue?
That's my thought on why it may not have happened yet. I'm not a maintainer here, but I imagine just getting a package of PHP 8.1 out which works at all on so many platforms might have been the priority.
Of course you could get the source by adding deb.sury.org's deb-src lines to the apt config, and build packages yourself after tweaking the configuration, then install the result. This might be seen as "too excessive," though; and note that build dependencies may conflict with those provided by the system (which you may be using to compile other things).
In this case, though, there's an additional catch: the PHP extension relies on libGD for processing, but as your output shows it is only at 2.3.0 (or 2.2.5 for Debian 9/10) while AVIF support was added in 2.3.2 (there is now a 2.3.3). So the packaged version of the library itself in Debian/Ubuntu needs to be brought up to date with newer source code. Unfortunately libGD's main package maintainer, Ondřej Surý, is often busy with other projects... 😅
When it will be available for 8.1?
As mentioned by @rfay here https://github.com/drud/ddev/issues/4292, we're facing a similar issue where we can't use imageavif
or imagecreatefromavif
functions in latest DDEV container (Docker) which is based on Debian 11 (bullseye) images from this repository with PHP8.1. However, AVIF support is well listed by php info but a warning is thrown anytime the functions are called: imageavif(): AVIF image support has been disabled
. Looks like the underlying AVIF lib is missing somehow (PHP does't give much information about the issue beside the warning) and installing libavif-dev
doesn't solve the issue.
Has there been any progress to fix that or any workaround?
The AVIF and HEIF support has been enabled for Debian Bullseye+ and Ubuntu Jammy+ and has been explicitly disabled for Debian Buster, Ubuntu Bionic, and Ubuntu Focal because the required libraries are not available. I don't really want to get into the business of backporting libavif and libheif for old Debian and Ubuntu releases.
DEB_CODENAME := $(shell sh -c '. /etc/os-release; echo "$${VERSION_CODENAME}"')
ifeq ($(DEB_CODENAME),$(filter $(DEB_CODENAME),buster bionic focal))
CONFIGURE_AVIF := --without-avif
CONFIGURE_HEIF := --without-heif
else
CONFIGURE_AVIF := --with-avif=/usr
CONFIGURE_HEIF := --with-heif=/usr
endif
I've just noticed that I've added libavif-dev and libheif-dev as Dependencies to libgd2-dev package, but forgot to add those to Build-Dependencies for libgd2 itself, that's why it has been missing. This has been remedied in 2.3.3-7 package that will soon hit the archives.
Then it will have to wait for the next round of PHP update as I don't want to rebuild the PHP 8.1 just to add this while the next release is around the corner.
Ok, this looks better:
12:47:56 Support for gd/gd2 images: no
12:47:56 Support for Zlib: yes
12:47:56 Support for PNG library: yes
12:47:56 Support for JPEG library: yes
12:47:56 Support for WebP library: yes
12:47:56 Support for HEIF library: yes
12:47:56 Support for AVIF library: yes
12:47:56 Support for TIFF library: yes
12:47:56 Support for Freetype 2.x library: yes
12:47:56 Support for Fontconfig library: yes
12:47:56 Support for Xpm library: yes
12:47:56 Support for liq library: no
12:47:56 Support for complex text: no
12:47:56 Support for pthreads: yes
And jammy:
Support for gd/gd2 images: no
Support for Zlib: yes
Support for PNG library: yes
Support for JPEG library: yes
Support for WebP library: yes
Support for HEIF library: yes
Support for AVIF library: yes
Support for TIFF library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: yes
Support for liq library: no
Support for complex text: no
Support for pthreads: yes
Checked it on the new PHP 8.2-RC4 build (on Ubuntu jammy), works good for both read/write UPD: PHP 8.1.12 works good too (on Ubuntu jammy at least)
Hey @oerdnj I dunno what's going on, I have PHP Version 8.1.16, Debian GNU/Linux 11 (bullseye), libavif-dev & libavif9 installed, AVIF listed as enabled in GD table form phpinfo(), yet I get
imageavif(): avif error - Could not encode image: No codec available
whenever I try to use it.
Is it OS issue or this PHP version issue?
I think it's this: https://github.com/libgd/libgd/issues/770#issuecomment-928474891 and this: https://bugs.launchpad.net/ubuntu/+source/libavif/+bug/1943658
What's your libavif version?
I might just be dense, but I'm on Jammy + have libavif-dev, I've run sudo apt-get update / upgrade / dist-upgrade and restarted apache, but still have no support for imagecreatefromavif
even though it says AVIF support is enabled via php -i. Is there something else I have to do to get it enabled?
I don't know if you're using amd64 or arm64 @alexscott64 but if you're using arm64 (Apple Silicon), there are loads of things wrong with a variety of packages on arm64, especially with php8.1. So test with php8.2.
@rfay I'm using Ubuntu 22.04 on amd64 (its just running on an EC2 instance)
I might just be dense, but I'm on Jammy + have libavif-dev, I've run sudo apt-get update / upgrade / dist-upgrade and restarted apache, but still have no support for
imagecreatefromavif
even though it says AVIF support is enabled via php -i. Is there something else I have to do to get it enabled?
Don't. Open a new issue and fill in all the required details first.