I am struggling in compiling imagick on my custom image of php based on php:7.4-fpm-alpine.
Imagemagick is also compiled from source.
I have created this repository https://github.com/mickaelperrin/imagick-build-error with a minimal Dockerfile showing the problem.
My compilation process is basically:
# Compile imagemagick from source
RUN mkdir -p /usr/src/imagemagick
&& curl -fsSL https://imagemagick.org/download/releases/ImageMagick-${IMAGE_MAGICK_VERSION}.tar.gz | tar xvz -C "/usr/src/imagemagick" --strip 1
&& cd /usr/src/imagemagick
&& ./configure
--with-magick-plus-plus=no
--without-perl
--disable-docs
--with-fontconfig=yes
--with-fftw
--with-heic=yes
--with-jpeg=yes
--with-png=yes
--with-tiff=yes
--with-webp=yes
&& ldconfig /usr/local/lib
&& make -j$(nproc)
&& make install
&& identify -version
&& identify -list format
# Imagick
ENV MAGICK_HOME=/usr/src/imagemagick
ARG IMAGICK_VERSION=3.6.0RC1
RUN mkdir -p /usr/src/php/ext/imagick
&& curl -fsSL https://github.com/Imagick/imagick/archive/refs/tags/${IMAGICK_VERSION}.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1
RUN cd /usr/src/php/ext/imagick
&& apk add --no-cache autoconf pkgconfig
&& phpize
&& ./configure
&& make -j$(nproc)
&& make install
&& docker-php-ext
The build fails with the following errors:
#8 3.852 /usr/src/php/ext/imagick/php_imagick_defs.h:25:12: fatal error: MagickWand/MagickWand.h: No such file or directory
#8 3.852 25 | # include <MagickWand/MagickWand.h>
#8 3.852 |
^~~~~~~~~~~~~~~~~~~~~~~~~
I guess this could be related to the following lines in the log:
#8 2.581 checking ImageMagick MagickWand API configuration program... checking Testing /usr/local/bin/MagickWand-config... It exists
#8 2.581 found in /usr/local/bin/MagickWand-config
#8 2.584 checking if ImageMagick version is at least 6.2.4... found version 7.1.0-17 Q16 HDRI
#8 2.584 checking for MagickWand.h or magick-wand.h header... user location /usr/local/include/ImageMagick-7/MagickWand/MagickWand.h
#8 2.587 /usr/local/bin/MagickWand-config: line 53: --libs: not found
#8 2.588 /usr/local/bin/MagickWand-config: line 41: --cflags: not found
Any idea of what I am doing wrong ?
2
Answers
Solution provided by @emcconville
Simply add the packages
autoconf
andpkgconfig
before the compilation of ImagamagickI created a bash script to compile ImageMagick 7 from source code that I get off of their official GitHub "releases" page.
Since you need libpng12 to build IM from source code, and it is no longer available with the latest Debian distros such as Ubuntu I had to get the libpng source code from sourceforge.net and compile and install it before building IM itself. The script should work well. Let me know if you have any issues.
Just run the bottom command in a terminal and feel free to check out my GitHub page to view the script itself!