I recently migrated from Hassbian to Hassio because I coudn’t upgrade any more for some reason.
Now everything works accept a bash script that converts images. It uses Imagemagick.

Is there any way to install Imagemagick on HASSIO?

It runs on a Pi3.



apk add --update imagemagick

1 Like

Please explain how that would work on E.'s Hassio install.

Hello KKlitgaard,

First you have to install SSH server on Hass.IO ADD-ON STORE, and log on with to it with a SSH client like PuTTY. Then execute the command to install Imagemagick: apk add --update imagemagick

With imagemagick installed, then you call in the scripts, commands to create an animated gif with the images from your cameras…
For example:
Create a file on \config\www\camera\ with the content:

rm -rf image-cam.gif
convert -loop 0 -delay 100 /config/www/camera/image-cam-1.png /config/www/camera/image-cam-2.png /config/www/camera/image-cam-3.png /config/www/camera/image-cam.gif

Command to turn the file executable: chmod +x
Create in shell_commands: snapshot_cam_gif: '/config/www/camera/'
Create in scripts:

    - service: camera.snapshot
        entity_id: camera.yourcamera
        filename: '/config/www/camera/image-cam-1.png'
    - service: camera.snapshot
        entity_id: camera.yourcamera
        filename: '/config/www/camera/image-cam-2.png'
    - service: camera.snapshot
        entity_id: camera.yourcamera
        filename: '/config/www/camera/image-cam-3.png'
    - delay: '00:00:05'
    - service: shell_command.snapshot_cam_gif


Thank you for this info! I was able to SSH into my instance and install Imagemaick. I also created the .sh script and ran it from the SSH terminal without issue. A .gif was created and was able to be sent via e-mail (and Google Hangouts!) without issue.

I am struggling however, with the shell_commands part. I have several other shell_commands that are working fine. However when I try to run the ‘convert’ script it fails with a return code of 127. I enabled additional debugging:

I simplified the script to just run ‘convert --help’ and it still fails the same way:

With #!/bin/bash in the script:

2019-05-24 18:41:35 DEBUG (MainThread) [homeassistant.components.shell_command] Stderr of command: `/config/cache/`, return code: 127:
b'/bin/sh: /config/cache/ not found\n'

Without #!/bin/bash in the script:

2019-05-24 18:27:59 DEBUG (MainThread) [homeassistant.components.shell_command] Stderr of command: `/config/cache/`, return code: 127:
b'/config/cache/ line 1: convert: not found\n'

Looks like maybe a path or permissions issue?


Edit: Added more info

Try this, make a wrapper python program, to call the script.
Based on the previous example, create a python file: like this:

import subprocess
import sys
import os
print (os.getcwd())
cmd = "/config/scripts/"
x = subprocess.check_output(cmd, shell=True)

Then the shell_command:
snapshot_cam_gif: "python3 /config/scripts/"

Also, you can change the script to reinstall imagemagick, if it gets uninstalled by a home assistant update, as it happens on HassOS.

if [ -f "$file" ]
   echo "Imagemagik $FILE found."
   echo "Re-Installing Imagemagik:"
   apk add --update imagemagick
cd /config/www/camera
rm -rf image-cam.gif
/usr/bin/convert -loop 0 -delay 50 /config/www/camera/image-cam-1.png /config/www/camera/image-cam-2.png /config/www/camera/image-cam-3.png /config/www/camera/image-cam.gif

There is another issue if you are editing this file in windows, and I guess it is your case based on your error: You need to remove the char(13) “Enter key” because Linux only uses char(10) for a new line.
Try this command to clean the file:
sed -i 's/\r//'

I hope this has helped…