4

我最近将我的 PHP 版本升级到 8.1-fpm,并将 Debian 升级到 Bullseye。我在某处读到 Bullseye 附带 AVIF 支持,但是当我尝试使用时imageavif(),我收到以下错误:

PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function imageavif()

我在服务器上运行了“php -i | grep AVIF”,它返回:

ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, H, HALD, HDR, HEIC, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPG, MRW, MSL, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV

我怎么imageavif()去上班?我错过了什么吗?

编辑:我运行了函数“print_r(gd_info());” 这是结果数组:

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] => 
)

好像我有 GD,但没有设置它的 AVIF 支持。如何让它支持 AVIF?

另外,我目前正在使用imagewebp(),该功能工作得很好。

编辑:感谢Nico Haase将我指向 Ondřej Surý 的 PHP 存储库的 GitHub 问题 - https://github.com/oerdnj/deb.sury.org/issues/1641

在此期间,我能做些什么来让imageavif()工作不会太过分,还是最好只是等待?

4

1 回答 1

0

GD 扩展依赖于 libavif 包来提供底层的 AVIF 编解码器。GD 扩展需要 libavif 0.8.2 或更高版本。

Ubuntu/Debian

apt install libavif-dev

RHEL/Fedora

dnf install libavif-devel

安装依赖项后,可以使用 ./configure 脚本中的新 --with-avif 标志使用 AVIF 支持编译 PHP。

./buildconf --force
./configure --enable-gd --with-avif

请注意,上面的 ./configure 命令只是一个示例;对于生产系统,请确保也启用其他扩展。

来源:https ://php.watch/versions/8.1/gd-avif

于 2022-02-05T22:44:34.107 回答