php8 Imagick库缺失jpeg、png、tiff等格式的问题

参考:

linux环境下安装php_imagick扩展,linux php ImageMagick缺少jpg,png,tiff格式
imagick扩展不支持jpg

1. docker镜像编译

直接下载使用:docker pull cffycls/phpswoole:imagick-dev
或重新手动编译imagick依赖

FROM phpswoole/swoole:php8.0-alpine

RUN sed -i 's/https/http/' /etc/apk/repositories \
    && sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
    && apk --update add tzdata \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && apk del tzdata \
    && rm -rf /var/cache/apk/*
# PHPIZE_DEPS 参考于: https://github.com/hyperf/hyperf-docker/blob/master/8.1/alpine/swoole/Dockerfile
ENV PHPIZE_DEPS="autoconf dpkg-dev dpkg file g++ gcc libc-dev make php8-dev php8-pear pkgconf re2c pcre-dev pcre2-dev zlib-dev libtool automake"
ENV IMAGICK_DEPS="libgomp libzip zstd-libs imagemagick-dev"

COPY ./ /tmp/

RUN set -ex \
    && pecl update-channels \
    && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
    \
    && apk add $IMAGICK_DEPS \
#  最新版支持列表 https://download.imagemagick.org/ImageMagick/download/delegates/
#  20220517.安装 jpeg
#     && wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz \
    && cd /tmp/ && tar -zxf jpegsrc.v9b.tar.gz && cd jpeg-9b/ \
    && ./configure --prefix=/usr/local/jpeg/ \
    && make -j4 && make install -j4 \
    && ls -l /usr/local/jpeg \
#     && wget https://download.imagemagick.org/ImageMagick/download/delegates/libpng-1.6.31.tar.gz \
    && cd /tmp/ && tar -zxf libpng-1.6.31.tar.gz && cd libpng-1.6.31/ \
    && ./configure --prefix=/usr/local/png/ \
    && make -j4 && make install -j4 \
    && ls -l /usr/local/png \
    \
#     && wget https://download.imagemagick.org/ImageMagick/download/delegates/freetype-2.8.1.tar.gz \
    && cd /tmp/ && tar -zxf freetype-2.8.1.tar.gz && cd freetype-2.8.1/ \
    && ./configure --prefix=/usr/local/freetype/ \
    && make -j4 && make install -j4 \
    && ls -l /usr/local/freetype \
    \
#     && wget https://download.imagemagick.org/ImageMagick/download/delegates/tiff-4.0.8.tar.gz \
    && cd /tmp/ && tar -zxf tiff-4.0.8.tar.gz && cd tiff-4.0.8/ \
    && ./configure --prefix=/usr/local/tiff/ \
    && make -j4 && make install -j4 \
    && ls -l /usr/local/tiff \
    \
    \
    #  安装 ImageMagick
#    && wget http://www.imagemagick.org/download/ImageMagick.tar.gz \
    && cd /tmp/ && tar -zxf ImageMagick.tar.gz && cd ImageMagick-7.1.0-34/ \
    && ./configure --prefix=/usr/local/imagemagick \
    CPPFLAGS="-I/usr/local/jpeg -I/usr/local/jpeg/include -I/usr/local/png -I/usr/local/png/include -I/usr/local/freetype -I/usr/local/freetype/include -I/usr/local/tiff -I/usr/local/tiff/include" \
    LDFLAGS="-L/usr/local/lib -L/usr/local/jpeg/lib -L/usr/local/png/lib -L/usr/local/freetype/lib -L/usr/local/tiff/lib" \
    && make -j4 && make install -j4 \
    && ls -l /usr/local/imagemagick \
    \
    \
    #  安装 ImageMagick
#  git ssl问题无法下载,在浏览器下载复制
    && cd /tmp/imagick-master/ \
    && phpize \
    && ./configure --with-php-config=/usr/local/bin/php-config --with-imagick=/usr/local/imagemagick \
    && make -j4 && make install -j4 \
    \
    && /usr/local/imagemagick/bin/convert --version \
    && docker-php-ext-enable imagick \
    # ---------- clear works ----------
    && apk del .build-deps \
    && rm -rf /var/cache/apk/* /tmp/*

你可能感兴趣的:(php8 Imagick库缺失jpeg、png、tiff等格式的问题)