Trying to Install ImageMagic in HAOS 14.2

Due to a problem with the SMTP Integration and images generated with the camera.snapshot action, I need to use ImageMagick to fixup the JPEG images. In a nutshell, the SMTP Integration claims to not recognize the JPEG format of the images generated by camera.snapshot. If I use magick image.jpg image.jpg to re-encode the JPEG image created by camera.snapshot, then the SMTP Integration has no problems with them.

I’m running HAOS 14.2 on an Intel NUC. The problem I’m having is that I need to install ImageMagick in the docker that HA is running in. If I use the command line in Advanced SSH & Web Terminal I can load ImageMagick and the JPEG delegate and manually re-encode the image so it works.

➜  ~ apk --update add imagemagick && apk --no-cache add msttcorefonts-installer fontconfig && update-ms-fonts && fc-cache -f
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz
OK: 262 MiB in 249 packages
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz
OK: 262 MiB in 249 packages
.
.
.
➜  ~ apk add imagemagick-jpeg
(1/2) Installing libjpeg-turbo (3.0.4-r0)
(2/2) Installing imagemagick-jpeg (7.1.1.41-r0)
OK: 263 MiB in 251 packages
➜  ~ magick "/config/www/snapshots/AI Pro Driveway_snapshot2.jpg" "/config/www/snapshots/AI Pro Driveway_snapshot2.jpg"
➜  ~ 

So, I know it can work. In order to get it to run from an automation, in need to load the packages inside the HA container. However, inside the container, APK cannot find the imagemagick-jpeg package. If I run the two commands using the the add-on File Editor “Execute Shell Command” dialog, it installs the ImageMAgick package without problems, but fails to load the ImageMagick-jpeg package.

Execute shell command
Command executed: apk --update add imagemagick && apk --no-cache add msttcorefonts-installer fontconfig && update-ms-fonts && fc-cache -f: 0
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
(1/20) Installing libpng (1.6.44-r0)
(2/20) Installing freetype (2.13.2-r0)
(3/20) Installing fontconfig (2.14.2-r4)
(4/20) Installing libxau (1.0.11-r3)
(5/20) Installing libmd (1.1.0-r0)
(6/20) Installing libbsd (0.11.7-r3)
(7/20) Installing libxdmcp (1.1.4-r3)
(8/20) Installing libxcb (1.16-r0)
(9/20) Installing libx11 (1.8.7-r0)
(10/20) Installing libxext (1.3.5-r3)
(11/20) Installing fftw-double-libs (3.3.10-r5)
(12/20) Installing libgomp (13.2.1_git20231014-r0)
(13/20) Installing lcms2 (2.15-r4)
(14/20) Installing libltdl (2.4.7-r3)
(15/20) Installing imagemagick-libs (7.1.1.32-r0)
(16/20) Installing imagemagick (7.1.1.32-r0)
(17/20) Installing libmspack (0.11_alpha-r1)
(18/20) Installing cabextract (1.11-r1)
(19/20) Installing wget (1.21.4-r0)
(20/20) Installing msttcorefonts-installer (3.8.1-r0)
Executing msttcorefonts-installer-3.8.1-r0.post-install
Executing busybox-1.36.1-r15.trigger
Executing fontconfig-2.14.2-r4.trigger
OK: 122 MiB in 91 packages
*
* With root permissions run "update-ms-fonts" and once completed
* run "fc-cache -f" in order to update the font cache
*

Execute shell command
Command executed: apk add imagemagick-jpeg: 5
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
ERROR: unable to select packages:
  && (no such package):
    required by: world[&&]
  add (no such package):
    required by: world[add]
  apk (no such package):
    required by: world[apk]
  fc-cache (no such package):
    required by: world[fc-cache]
  update-ms-fonts (no such package):
    required by: world[update-ms-fonts]

Without the jpeg delegate, magick fails:

Execute shell command
Command executed: magick "./www/snapshots/AI Pro Driveway_snapshot2.jpg" "./www/snapshots/AI Pro Driveway_snapshot2.jpg": 1
magick: no decode delegate for this image format `JPEG' @ error/constitute.c/ReadImage/746.

Any ideas on how I can fix this?

Hi miataTom,
You cannot add Docker containers to HAOS like that. They need to be in the form of Add-ons. I suggest find an add-on or build one that has your tools, or switch your HAOS for Container mode HA where you can use your own Docker.

I am not trying to add any Docker containers. I’m just trying to install software packages into the HA container that already exists.

If you ever decide to update the revision of HAOS, anything you manage to add will be removed. You need to put that whatever in an add-on or Custom Integration, and not mess with the HAOS container.

Great. I’ve never created a custom integration. How would I go about creating one to install imagemagick? The solution I’m trying was presented by others (SMTP - unknown MIME type - #8 by ElPotton). It works, except the newer packages of ImageMagick have broken out the delegates into additional packages, and I cannot get those additions to install.

Here is what I do:

That is correct @wmaker, and exactly what I am doing. However, with the latest Imagemagick packages, the jpeg support has been moved to imagemagick-jpeg which I cannot get apk to load.

Just to clarify, I have imagemagick loading, it persists after HA updates, I can call it with shell_command from my automations/scripts. It just no longer contains the JPEG delegates and I can’t figure out how to install them.

Sorry, didn’t look at your details …

My application is pretty much the same as yours (take a doorbell camera snapshot and having issues sending that image w. SMTP).
Sooo far I only have to apk add imagemagick (in HA Core container)

and for the jpeg to jpeg conversion I use the command convert filename filename from imagemagick package.

Let me know what you find out

[EDIT] Also for comparison …

$convert -version
WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert"

Version: ImageMagick 7.1.1-41 Q16-HDRI x86_64 22504 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
Compiler: gcc (14.2)