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,182
Iain1940
  • 101

6 Answers6

8

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
  • 492
Chris Smith
  • 181
  • 2
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
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

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,182
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
  • 704
0

I lost 2 hours because of this issue while trying to convert pictures taken from a new phone from the brand with a fruit in the name.

I did the following and it finally allowed me to use the magick <file.heic> <file.jpg> command to convert heic to usable jpeg.

This was done as of today on ubuntu 24.04.2 LTS with all latest packages installed. I was getting errors like:

convert-im6.q16: Invalid input: Unspecified: Too many auxiliary image references (2.0) ...

And then:

magick: no decode delegate for this image format `HEIC'

When I only upgraded by compiling ImageMagick...

Here are the steps I did to make it work:

First, update libheif by compiling from source:

  1. Download source from github: https://github.com/strukturag/libheif
  2. From inside the source directory, to compile libheif:

commands to do:

sudo apt install cmake
mkdir build
cd build
cmake --preset=release ..
make
sudo make install

Then, you have to do the same for ImageMagick:

  1. Download source : https://github.com/ImageMagick/ImageMagick
  2. From inside the directory, compile and install (credit to https://gist.github.com/hurricup/e14ae5bc47705fca6b1680e7a1fb6580):

commands to do:

# remove bundled ImageMagick
sudo apt remove imagemagick -y

install base dependencies

sudo apt-get install -y
build-essential
git
libde265-dev
libdjvulibre-dev
libfftw3-dev
libghc-bzlib-dev
libgoogle-perftools-dev
libgraphviz-dev
libgs-dev
libheif-dev
libjbig-dev
libjemalloc-dev
libjpeg-dev
liblcms2-dev
liblqr-1-0-dev
liblzma-dev
libopenexr-dev
libopenjp2-7-dev
libpango1.0-dev
libraqm-dev
libraw-dev
librsvg2-dev
libtiff-dev
libwebp-dev
libwmf-dev
libxml2-dev
libzip-dev
libzstd-dev

./configure
--with-bzlib=yes
--with-djvu=yes
--with-dps=yes
--with-fftw=yes
--with-flif=yes
--with-fontconfig=yes
--with-fpx=yes
--with-freetype=yes
--with-gslib=yes
--with-gvc=yes
--with-heic=yes
--with-jbig=yes
--with-jemalloc=yes
--with-jpeg=yes
--with-jxl=yes
--with-lcms=yes
--with-lqr=yes
--with-lzma=yes
--with-magick-plus-plus=yes
--with-openexr=yes
--with-openjp2=yes
--with-pango=yes
--with-perl=yes
--with-png=yes
--with-raqm=yes
--with-raw=yes
--with-rsvg=yes
--with-tcmalloc=yes
--with-tiff=yes
--with-webp=yes
--with-wmf=yes
--with-x=yes
--with-xml=yes
--with-zip=yes
--with-zlib=yes
--with-zstd=yes
--with-gcc-arch=native

make -j 16 sudo make install sudo ldconfig /usr/local/lib

  1. Now should be able to convert, you can check if it worked by getting the version using magick -version
Puck
  • 101