In Alpine Linux 3.18 and earlier, it was sufficient to install the imagemagick package by itself to operate on any image format, including modern ones such as HEIC and WebP. In later versions of Alpine Linux, that’s no longer the case.

Starting in Alpine Linux 3.19, the support files for HEIC, WebP, and other image formats moved into sub-packages like imagemagick-heic and imagemagick-webp; see https://git.alpinelinux.org/aports/commit/?id=61dce5f6a84d9f96ab7aa6437f12d2845b572ed8.

The problem

After upgrading Alpine Linux, this packaging change could lead to errors due to missing image format support files. For example:

/ # cat /etc/alpine-release
3.19.3
/ # magick identify sample.webp
identify: delegate failed `'dwebp' -pam '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1911.
identify: unable to open file '/tmp/magick-orxembTdZw90FFid2wMyYRKUC4OjjKpE': No such file or directory @ error/constitute.c/ReadImage/785.

When upgrading a system manually, Alpine notifies about the change:

* imagemagick support for various modules was split into subpackages.
* they autoinstall with the requisite library already installed.
* if not already present, install the module you want to use manually:
* (prefixed with imagemagick- )
* -heic -jpeg -pdf -raw
* -svg -tiff -webp -jxl
* if you want to exclude the support regardless, use e.g. 'apk add !imagemagick-pdf'

But it’s far more common to run Alpine in a Docker image, and you won’t see that message when updating the base image version in a Dockerfile.

The solution

When updating a Dockerfile to Alpine Linux 3.19, ensure that you also add the imagemagick-* sub-package for every image format that you expect to operate on:

RUN apk add --update --no-cache \
  imagemagick \
  imagemagick-heic \
  imagemagick-jpeg \
  imagemagick-svg \
  imagemagick-tiff \
  imagemagick-webp

For example, after installing the imagemagick-webp package, the error above running identify is resolved:

/ # apk add imagemagick-webp
(1/5) Installing libsharpyuv (1.3.2-r0)
(2/5) Installing libwebp (1.3.2-r0)
(3/5) Installing libwebpdemux (1.3.2-r0)
(4/5) Installing libwebpmux (1.3.2-r0)
(5/5) Installing imagemagick-webp (7.1.1.32-r0)
OK: 38 MiB in 49 packages
/ # magick identify sample.webp
sample.webp WEBP 550x368 550x368+0+0 8-bit sRGB 30320B 0.000u 0:00.000

If you run Alpine-based Node.js Docker images, note that the node:18.18.2-alpine image is based on Alpine Linux 3.18 and the node:18.19.0-alpine image is based on Alpine Linux 3.19.

Verify

To verify the image formats that ImageMagick recognizes on your system, run magick identify -list format:

/ # magick identify -list format
   Format  Module    Mode  Description
-------------------------------------------------------------------------------
      3G2  VIDEO     r--   Media Container
      3GP  VIDEO     r--   Media Container
      AAI* AAI       rw+   AAI Dune image
     APNG  VIDEO     rw+   Animated Portable Network Graphics
    ...
     WEBP* WEBP      rw+   WebP Image Format (libwebp 1.3.2 [020F])
    ...

* native blob support
r read support
w write support
+ support for multiple images

Additionally, to see the delegates, or external programs, that ImageMagick uses to process certain image formats, run magick identify -list delegate:

/ # magick identify -list delegate

Path: /etc/ImageMagick-7/delegates.xml

Delegate                Command
-------------------------------------------------------------------------------
    blender =>          "blender' -b '%i' -F PNG -o '%o''\n'magick' convert -concatenate '%o*.png' '%o"
        bpg =>          "bpgdec' -b 16 -o '%o.png' '%i'; /bin/mv '%o.png' '%o"
 dng:decode =>          "/bin/mv '%i' '%i.%e'; 'darktable-cli' --import '%i.%e' '%u.tif' > '%u"
           ...
       webp =>          "dwebp' -pam '%i' -o '%o"
        xls =>          "libreoffice' --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"
       xlsx =>          "libreoffice' --convert-to pdf -outdir `dirname '%i'` '%i' 2> '%u'; /bin/mv '%i.pdf' '%o"