I'm trying to use ImageMagick 7 in a Docker container. However it doesn't install any delegates, though I added libpng-dev
. When I try to get an image inside the container from https with this command:
magick https://www.nasa.gov/sites/default/files/thumbnails/image/moon_mosaic.png ./test.png
I get this message:
magick: no decode delegate for this image format `DAT' @ error/constitute.c/ReadImage/738.
This doesn't make sense, since it is a PNG
image and not a DAT
file.
Here my Dockerfile:
FROM debian:bullseye-slim
ARG IM_VERSION="7.1.0-37"
ARG IM_BUILD_FLAGS="--enable-shared --disable-static --without-modules --enable-delegate-build --disable-docs --with-heic=yes"
WORKDIR /app
RUN apt-get update && apt-get install -y wget && \
apt-get install -y build-essential curl libpng-dev && \
wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/${IM_VERSION}.tar.gz && \
tar xzf ${IM_VERSION}.tar.gz && \
rm ${IM_VERSION}.tar.gz && \
apt-get clean && \
apt-get autoremove
WORKDIR /app/ImageMagick-${IM_VERSION}
RUN sh ./configure ${IM_BUILD_FLAGS} && make -j && make install && ldconfig /usr/local/lib/
Here the output from the configure part of building ImageMagick:
configure:
==============================================================================
ImageMagick 7.1.0-37 is configured as follows. Please verify that this
configuration matches your expectations.
Host system type: x86_64-pc-linux-gnu
Build system type: x86_64-pc-linux-gnu
Option Value
------------------------------------------------------------------------------
Shared libraries --enable-shared=yes yes
Static libraries --enable-static=no no
Build utilities --with-utilities=yes yes
Module support --with-modules=no no
GNU ld --with-gnu-ld=yes yes
Quantum depth --with-quantum-depth=16 16
High Dynamic Range Imagery
--enable-hdri=yes yes
Install documentation: no
Memory allocation library:
JEMalloc --with-jemalloc=no no
TCMalloc --with-tcmalloc=no no
UMem --with-umem=no no
Delegate library configuration:
BZLIB --with-bzlib=yes no
Autotrace --with-autotrace=no no
DJVU --with-djvu=yes no
DPS --with-dps=yes no
FFTW --with-fftw=no no
FLIF --with-flif=no no
FlashPIX --with-fpx=yes no
FontConfig --with-fontconfig=yes no
FreeType --with-freetype=yes no
Ghostscript lib --with-gslib=no no
Graphviz --with-gvc=yes no
HEIC --with-heic=yes no
JBIG --with-jbig=yes no
JPEG v1 --with-jpeg=yes no
JPEG XL --with-jxl=no no
LCMS --with-lcms=yes no
LQR --with-lqr=yes no
LTDL --with-ltdl=no no
LZMA --with-lzma=yes no
Magick --with-magick-plus-plus=yes yes
OpenEXR --with-openexr=yes no
OpenJP2 --with-openjp2=yes no
PANGO --with-pango=yes no
PERL --with-perl=no no
PNG --with-png=yes no
RAQM --with-raqm=yes no
RAW --with-raw=yes no
RSVG --with-rsvg=no no
TIFF --with-tiff=yes no
WEBP --with-webp=yes no
WMF --with-wmf=no no
X11 --with-x= no
XML --with-xml=yes no
ZIP --with-zip=yes no
ZLIB --with-zlib=yes no
ZSTD --with-zstd=yes no
Delegate program configuration:
GhostPCL None pcl6 (unknown)
GhostXPS None gxps (unknown)
Ghostscript None gs (unknown)
Font configuration:
Apple fonts --with-apple-font-dir=default
Dejavu fonts --with-dejavu-font-dir=default none
Ghostscript fonts --with-gs-font-dir=default none
URW-base35 fonts --with-urw-base35-font-dir=default none
Windows fonts --with-windows-font-dir=default none
X11 configuration:
X_CFLAGS =
X_PRE_LIBS =
X_LIBS =
X_EXTRA_LIBS =
Options used to compile and link:
PREFIX = /usr/local
EXEC-PREFIX = /usr/local
VERSION = 7.1.0-37
CC = gcc
CFLAGS = -fopenmp -Wall -g -O2 -mtune=ivybridge -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
CPPFLAGS = -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
PCFLAGS =
DEFS = -DHAVE_CONFIG_H
LDFLAGS =
LIBS = -lm -lpthread
CXX = g
CXXFLAGS = -pthread
FEATURES = DPC HDRI Cipher OpenMP
DELEGATES =
==============================================================================
All delegates seem to be not active.
EDIT: I checked the output again. It seems like it doesn't find libpng
-------------------------------------------------------------
checking for libpng >= 1.0.0... no
-------------------------------------------------------------
I checked the installed version and it is 1.6.37-3
When I use ImageMagick outside of the Docker container it works without problems. I'm not sure what the problem is and why it doesn't configure the delegates. Sadly I can't install ImageMagick 7 with apt
.
CodePudding user response:
Try adding pkg-config
, and possibly also autoconf
, to your prerequisite package list. ImageMagick is considerably better at finding and configuring stuff with those helpers, especially the PNG delegate:
RUN apt-get update && apt-get install -y wget && \
apt-get install -y autoconf pkg-config ...
Actually, the Alpine docker image is brilliant for ImageMagick. It is very current, very small, and includes loads of delegates:
docker run --rm -it -v "$(pwd)":/work -w /work alpine:latest
/work # apk add --no-cache imagemagick
...
... output, output, output
... and then around 4 seconds later
...
/work # magick identify -version
Version: ImageMagick 7.1.0-50 beta Q16-HDRI x86_64 20489 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jng jpeg jxl lcms ltdl lzma png ps rsvg tiff webp x xml zlib
Compiler: gcc (11.2)