I am using Alpine to build a docker container. After recent updates I get the error message:
no decode delegate for this image format `JPEG'
When I list the supported formats JPEG seems to miss:
$ 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
The images I want to handle have the ending '.jpg'
The following version is installed:
$ 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
That looks like jpeg is included!
What I am doing is using the Imagick php class in php 8.2.23, especially the methods getImageWidth() and getImageHeight().
If I am using identify
or convert
directly in the console it works.
The width and height are used to calculate the ratio and create a pdf with Dompdf, which contains the image file.
Any idea what could cause this error? Does JNG include jpg/jpeg images?
Edit: output of 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
Please note that 198 formats are supported, but I cannot see JPEG or JPG in this list. I am not sure if this JNG includes them.
The problem was, that in the newer versions the jpeg support for imagemagick is now in a different package.
I set up my docker Alpine image now by loading imagemagick-dev
as well as imagemagick-jpeg
and additionally also loading the matching php${PHP_SHORT}-pecl-imagick
for my current phpversion e.g. 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
By doing this I then have my JPEG support in my Alpine docker container:
$ 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)