php 8.1 avif 错误 (docker): 没有可用的编解码器
php 8.1 avif error (docker): No codec available
我有 php 8.1 通过 docker 和 avif 功能不工作。
警告:imageavif():avif 错误 - 无法编码图像:第 5/var/www/test.php 中没有可用的编解码器
Docker 文件:
FROM php:8.1-fpm
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
libicu-dev \
libpng-dev \
libwebp-dev \
libfreetype6-dev \
libavif-dev \
libaom-dev \
libxpm-dev \
libjpeg62-turbo-dev
RUN docker-php-ext-install -j$(nproc) pdo_mysql mysqli bcmath sockets calendar gettext \
&& docker-php-ext-configure gd --with-freetype --with-webp --with-jpeg --with-avif --with-xpm \
&& docker-php-ext-install gd \
&& docker-php-ext-enable gd \
&& docker-php-ext-configure intl && docker-php-ext-install intl \
&& docker-php-ext-configure exif && docker-php-ext-install exif && docker-php-ext-enable exif \
&& pecl install xdebug-3.1.3 && docker-php-ext-enable xdebug
WORKDIR /var/www
PHP 信息:
enter image description here
enter image description here
我的test.php:
<?php
ini_set('display_errors', 1);
var_dump(imageavif(imagecreatetruecolor(8, 8), "/tmp/test")); // true
var_dump(file_get_contents("/tmp/test")); // empty string
die();
像这样重写 Dockerfile:
FROM php:8.1-fpm
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions gd
我有 php 8.1 通过 docker 和 avif 功能不工作。
警告:imageavif():avif 错误 - 无法编码图像:第 5/var/www/test.php 中没有可用的编解码器
Docker 文件:
FROM php:8.1-fpm
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
libicu-dev \
libpng-dev \
libwebp-dev \
libfreetype6-dev \
libavif-dev \
libaom-dev \
libxpm-dev \
libjpeg62-turbo-dev
RUN docker-php-ext-install -j$(nproc) pdo_mysql mysqli bcmath sockets calendar gettext \
&& docker-php-ext-configure gd --with-freetype --with-webp --with-jpeg --with-avif --with-xpm \
&& docker-php-ext-install gd \
&& docker-php-ext-enable gd \
&& docker-php-ext-configure intl && docker-php-ext-install intl \
&& docker-php-ext-configure exif && docker-php-ext-install exif && docker-php-ext-enable exif \
&& pecl install xdebug-3.1.3 && docker-php-ext-enable xdebug
WORKDIR /var/www
PHP 信息: enter image description here enter image description here
我的test.php:
<?php
ini_set('display_errors', 1);
var_dump(imageavif(imagecreatetruecolor(8, 8), "/tmp/test")); // true
var_dump(file_get_contents("/tmp/test")); // empty string
die();
像这样重写 Dockerfile:
FROM php:8.1-fpm
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions gd