10

I had similar problems to the original poster of How to install delegate libraries for Image Magick 7.0.7

  • No Delegates after building 7.0.8-37.

I installed all the 240 MB odd libraries and the second lot that included libheif-dev.

When I tried to use the single (big) command it failed with a '404' error so I used the instructions from the IM website.

The 'make' failed with

.....
CC       coders/MagickCore_libMagickCore_7_Q16HDRI_la-heic.lo
coders/heic.c: In function ‘WriteProfile’:
coders/heic.c:546:18: warning: implicit declaration of function ‘heif_context_add_exif_metadata’; did you mean ‘heif_image_handle_get_metadata’? [-Wimplicit-function-declaration]
.... etc
 *** [coders/MagickCore_libMagickCore_7_Q16HDRI_la-heic.lo] Error 1
make[1]: Leaving directory '/home/xxxx/imagemagick_build/ImageMagick-7.0.8-39'
Makefile:5761: recipe for target 'all' failed
make: *** [all] Error 

Not having an iPhone I decided I didn't need HEIC and removed libheif-dev and tried again.

The result was a new ImageMagick :

Version: ImageMagick 7.0.8-39 Q16 x86_64 2019-04-08 https://imagemagick.org

I can start playing with it now - at least it now displays jpegs.

Greenonline
  • 2,081
Iain1940
  • 101

6 Answers6

6

Hopefully me struggling for way too long getting mogrify up and running will help someone else.

Compiling imagemagick with HEIC support from clean install of Ubuntu:

$ sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
$ sudo apt-get update
$ sudo apt-get install build-essential autoconf git-core
$ sudo apt-get build-dep imagemagick libde265 libheif
$ cd /usr/src/ 
$ sudo git clone https://github.com/strukturag/libde265.git  
$ sudo git clone https://github.com/strukturag/libheif.git 
$ cd libde265/ 
$ sudo ./autogen.sh 
$ sudo ./configure 
$ sudo make –j4  
$ sudo make install 
$ cd /usr/src/libheif/ 
$ sudo ./autogen.sh 
$ sudo ./configure 
$ sudo make –j4  
$ sudo make install 
$ cd /usr/src/ 
$ sudo wget https://www.imagemagick.org/download/ImageMagick.tar.gz 
$ sudo tar xf ImageMagick.tar.gz 
$ cd ImageMagick-7* 
$ sudo ./configure --with-heic=yes 
$ sudo make –j4  
$ sudo make install  
$ sudo ldconfig  
$ mogrify --version 
# heic should appear in the Delegates line 

Additional References:

https://linuxconfig.org/how-to-install-imagemagick-7-on-ubuntu-18-04-linux

https://github.com/ImageMagick/ImageMagick/issues/1470

https://github.com/strukturag/libheif/blob/master/README.md

https://github.com/strukturag/libde265/blob/master/README.md

DonP
  • 394
5

I ended up using IMEI - ImageMagick Easy Install, which worked great on Ubuntu 20.04. It can be installed as follows (quoting from the project's GitHub page):

One-Step Automated Install

t=$(mktemp) && \
wget 'https://dist.1-2.dev/imei.sh' -qO "$t" && \
bash "$t" && \
rm "$t"

Alternative Install Method

git clone https://github.com/SoftCreatR/imei && \
cd imei && \
chmod +x imei.sh && \
./imei.sh
user162988
  • 71
  • 1
  • 3
  • IMEI is great but is slow - if using docker then cache the IMEI install within a parent docker image and create a child Dockerfile which extends the parent - example here https://hub.docker.com/repository/docker/danday74/ubuntu18-ffmpeg4-imagemagick7 - this should speed up your build whilst utilising the professional approach adopted by IMEI – danday74 May 05 '22 at 10:30
  • 1
    It was indeed slow (took maybe 5 minutes) but this was very simple to do and worked very well. – gr5 Sep 08 '22 at 16:00
3

I had the same problem under Ubuntu 18.04 when trying to compile the latest version of ImageMagick 7.0.8. The solution was to manually compile and install the latest version of libheif from here. After this, the compilation succeeded. Remember to uninstall the default package of libheif supplied by Ubuntu first, both libheif and libheif-dev.

zero0cool
  • 131
  • 1
    This is tricky... you also need to make sure libheif actually compiled with libde265 support or it still won't decode HEIC images. See https://github.com/strukturag/libheif/issues/90 – Adam Monsen Sep 30 '19 at 05:51
1

For 18.04 and 20.04 LTS, you can try to follow these steps, which are an extension of Chris Smith's answer:

Step 1

sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install build-essential autoconf libtool git-core
sudo apt-get build-dep imagemagick libmagickcore-dev libde265 libheif
cd /usr/src/ 
sudo git clone https://github.com/strukturag/libde265.git  
sudo git clone https://github.com/strukturag/libheif.git 
cd libde265/ 
sudo ./autogen.sh 
sudo ./configure 
sudo make  
sudo make install 
cd /usr/src/libheif/ 
sudo ./autogen.sh 
sudo ./configure 
sudo make  
sudo make install 
cd /usr/src/ 
sudo wget https://www.imagemagick.org/download/ImageMagick.tar.gz 
sudo tar xf ImageMagick.tar.gz 
cd ImageMagick-7*
sudo ./configure --with-heic=yes 
sudo make  
sudo make install  
sudo ldconfig

Step 2

sudo apt install php-imagick
cd /usr/src/ 
wget http://pecl.php.net/get/imagick-3.4.4.tgz
tar -xvzf imagick-3.4.4.tgz
cd imagick-3.4.4/
### If you are using 20.04 LTS, use php7.4-dev below.
apt install php7.4-dev 
### If you are using 18.04 LTS, use php7.2-dev below.
apt install php7.2-dev
phpize
./configure
make
make install
sudo phpenmod imagick

Step 3

sudo systemctl restart apache2
php -r 'phpinfo();' | grep HEIC
You should see:
ImageMagick supported formats => 3FR, 3G2, 3GP, A, AAI, AI, ART, ARW, AVI, AVS, B, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, C, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CRW, CUBE, CUR, CUT, DATA, DCM, DCR, DCRAW, DCX, DDS, DFONT, DJVU, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FLV, FRACTAL, FTP, FTS, G, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, HALD, HDR, HEIC,...

Sample code

<?php

$im = new Imagick(); $im->setSize(1280, 1280); $im->setFormat('heic'); $im->readImage( DIR . '/tmp/test.jpg' ); $im->cropThumbnailImage( 1280, 1280 ); $im->setImageCompressionQuality(80); $im->writeImage( DIR . '/tmp/test_1280.heic' ); $im->destroy(); $im = new Imagick(); $im->setSize(1280, 1280); $im->setFormat('jpg'); $im->readImage( DIR . '/tmp/test.jpg' ); $im->cropThumbnailImage( 1280, 1280 ); $im->setImageCompressionQuality(80); $im->writeImage( DIR . '/tmp/test_1280.jpg' ); $im->destroy(); ?>

Source: 5 minutes to Install Imagemagick with HEIC support on Ubuntu 20.04 (and 18.04) DigitalOcean

Greenonline
  • 2,081
0

Ended up with this solution (includes all features I could install) : https://gist.github.com/hurricup/e14ae5bc47705fca6b1680e7a1fb6580

0

An alternative to compiling is to use docker with a ready made image. There's one that worked fine for me, but you can search for others.

Converting from HEIC to PNG was as easy as:

docker run -v /path/to/picsdir/:/pics --rm dpokidov/imagemagick /pics/img.heic /pics/img.png

Saves some time.

Nagev
  • 674