deb.sury.org icon indicating copy to clipboard operation
deb.sury.org copied to clipboard

php8.1-gd missing AVIF support

Open SagePtr opened this issue 2 years ago • 6 comments

Frequently asked questions

Describe the bug php8.1-gd does not include AVIF support.

To Reproduce

  1. Install php8.1-cli and php8.1-gd from either ppa:ondrej/php (Ubuntu) or packages.sury.org (Debian)
  2. 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

SagePtr avatar Sep 17 '21 12:09 SagePtr

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. 😊

videochums avatar Dec 19 '21 18:12 videochums

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.

GreenReaper avatar Dec 19 '21 20:12 GreenReaper

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.

videochums avatar Dec 19 '21 21:12 videochums

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.

GreenReaper avatar Dec 19 '21 21:12 GreenReaper

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?

videochums avatar Dec 19 '21 22:12 videochums

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... 😅

GreenReaper avatar Dec 19 '21 23:12 GreenReaper

When it will be available for 8.1?

PELock avatar Sep 21 '22 19:09 PELock

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?

juban avatar Oct 18 '22 14:10 juban

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

oerdnj avatar Oct 24 '22 10:10 oerdnj

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.

oerdnj avatar Oct 24 '22 10:10 oerdnj

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

oerdnj avatar Oct 24 '22 11:10 oerdnj

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

oerdnj avatar Oct 24 '22 11:10 oerdnj

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)

SagePtr avatar Oct 24 '22 23:10 SagePtr

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?

PELock avatar Feb 28 '23 14:02 PELock

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?

oerdnj avatar Feb 28 '23 15:02 oerdnj

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?

alexscott64 avatar Sep 05 '23 01:09 alexscott64

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 avatar Sep 05 '23 01:09 rfay

@rfay I'm using Ubuntu 22.04 on amd64 (its just running on an EC2 instance)

alexscott64 avatar Sep 05 '23 04:09 alexscott64

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.

oerdnj avatar Sep 05 '23 05:09 oerdnj