此图像格式“JPEG”没有解码委托

问题描述 投票:0回答:1

我正在使用 Alpine 构建 docker 容器。最近更新后,我收到错误消息:

no decode delegate for this image format `JPEG'

当我列出支持的格式时,JPEG 似乎遗漏了:

$ magick -list format | grep JP
             see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
             and supplement 61 which adds JPEG-2000 encoding.
      JNG* PNG       rw-   JPEG Network Graphics
      PGX* PGX       rw-   JPEG 2000 uncompressed format

我想要处理的图像以“.jpg”结尾

已安装以下版本:

$ convert --version
Version: ImageMagick 7.1.1-32 Q16-HDRI aarch64 22207 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib heic jng jpeg jxl lcms ltdl lzma pangocairo png ps raw rsvg tiff webp x xml zlib zstd

看起来包含 jpeg!

我正在做的是使用 php 8.2.23 中的 Imagick php 类,特别是 getImageWidth() 和 getImageHeight() 方法。

如果我直接在控制台中使用

identify
convert
,它就可以工作。

宽度和高度用于计算比例并使用Dompdf创建pdf,其中包含图像文件。

知道什么可能导致此错误吗? JNG 包含 jpg/jpeg 图像吗?

编辑:phpinfo 的输出:

$ php -i | grep agick
imagick
imagick module => enabled
imagick module version => 3.7.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 7.1.1-32 Q16-HDRI x86_64 22207 https://imagemagick.org
Imagick using ImageMagick library version => ImageMagick 7.1.1-32 Q16-HDRI x86_64 22207 https://imagemagick.org
ImageMagick copyright => (C) 1999 ImageMagick Studio LLC
ImageMagick release date => 2024-05-05
ImageMagick number of supported formats:  => 198
ImageMagick supported formats => 3G2, 3GP, AAI, APNG, ART, ASHLAR, AVI, AVS, BAYER, BAYERA, BGR, BGRA, BGRO, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CUBE, CUR, CUT, DATA, DCM, DCX, DDS, DFONT, DOT, DPX, DXT1, DXT5, EPS2, EPS3, EPT, EPT2, EPT3, FARBFELD, FAX, FF, FILE, FITS, FL32, FLV, FRACTAL, FTP, FTS, FTXT, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GV, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JNG, JNX, JSON, KERNEL, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MSL, MTV, MVG, NULL, ORA, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PES, PFA, PFB, PFM, PGM, PGX, PHM, PICON, PICT, PIX, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, PPM, PS2, PS3, PSB, PSD, PWP, QOI, RADIAL-GRADIENT, RAS, RGB, RGB565, RGBA, RGBO, RGF, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, STEGANO, STRIMG, SUN, TEXT, TGA, THUMBNAIL, TILE, TIM, TM2, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBM, WMV, WPG, X, XBM, XC, XCF, XPM, XPS, XV, XWD, YAML, YCBCR, YCBCRA, YUV
imagick.allow_zero_dimension_images => 0 => 0
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 0 => 0

请注意,支持 198 种格式,但我在此列表中看不到 JPEG 或 JPG。我不确定这个 JNG 是否包含它们。

imagemagick dompdf
1个回答
0
投票

问题是,在较新的版本中,对 imagemagick 的 jpeg 支持现在位于不同的包中。

我现在通过加载

imagemagick-dev
以及
imagemagick-jpeg
设置我的 docker Alpine 镜像,另外还加载与我当前 php 版本相匹配的
php${PHP_SHORT}-pecl-imagick
,例如php83-pecl-imagick.

RUN apk add --no-cache \
        freetype-dev \
        libpng-dev \
        jpeg-dev \
        libjpeg-turbo-dev \
        imagemagick-dev \
        imagemagick-jpeg \
        php${PHP_SHORT}-pecl-imagick 

通过这样做,我的 Alpine docker 容器中就获得了 JPEG 支持:

$ magick -list format | grep JP
             see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
             and supplement 61 which adds JPEG-2000 encoding.
      JNG* PNG       rw-   JPEG Network Graphics
      JPE* JPEG      rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 3.0.3)
     JPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 3.0.3)
      JPG* JPEG      rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 3.0.3)
      JPS* JPEG      rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 3.0.3)
      MPO* JPEG      r--   Joint Photographic Experts Group JFIF format (libjpeg-turbo 3.0.3)
      PGX* PGX       rw-   JPEG 2000 uncompressed format
    PJPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (libjpeg-turbo 3.0.3)
© www.soinside.com 2019 - 2024. All rights reserved.