#!/bin/bash

# NOTE: Before running command, make sure following sources are at /etc/apt/sources.txt
#  deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
#  deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted 

sudo apt-get update
sudo apt-get build-dep imagemagick -y

sudo add-apt-repository ppa:strukturag/libheif -y
sudo add-apt-repository ppa:strukturag/libde265 -y
sudo apt-get update
sudo apt-get install libheif-dev -y
sudo apt-get install libde265-dev -y

cd /opt
sudo wget https://www.imagemagick.org/download/ImageMagick-7.0.11-0.tar.gz
sudo tar xvzf ImageMagick-7.0.11-0.tar.gz
cd ImageMagick-7.0.11-0
sudo ./configure --with-heic=yes
sudo make
sudo make install   # $ `sudo checkinstall` may work here if you have that.
sudo ldconfig /usr/local/lib # this creates the necessary links and cache to the most recent shared libraries in /usr/local/lib
