I always end up getting this wrong; steps below worked for Linux Mint 19.3 (based on Ubuntu 18.04).
Build/installation order is important; JPEG 2000 support in ImageMagick only works if OpenJPEG is
found at build time, so we have to start with that. Note that for OpenJPEG an 'openjpeg-dev' Debian package exists.
As I'm not entirely sure this is the most up-to-date version, and JPEG 2000 support is important for me, I'm compiling
this library from the sources here. Otherwise everything under the 'OpenJPEG' could probably be subsituted by the
one-liner sudo at-get install openjpeg-dev
).
First install Cmake, which we need for building both OpenJPEG and ImageMagick :
sudo apt install cmake
Then install the libraries that OpenJPEG needs for formats and colour management:
sudo apt install libtiff-dev
sudo apt install libpng-dev
sudo apt install liblcms2-dev
Clone OpenJPEG source repo and make:
git clone https://github.com/uclouvain/openjpeg.git
cd openjpeg
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
Check output of last step for any missing libraries and fix if needed. If successful, install OpenJPEG:
sudo make install
sudo make clean
First install delegate libraries for the most common (and some less common) formats. I used the following (partially taken from here)1:
sudo apt-get install libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libwebp-dev librsvg2-dev libde265-dev
Then download the ImageMagick source, unpack it and then build it (based on these instructions):
wget https://imagemagick.org/download/ImageMagick.tar.gz
tar xvzf ImageMagick.tar.gz
cd ImageMagick-x.y.z-##
./configure
make
If make doesn't report any errors, install using:
sudo make install
sudo ldconfig /usr/local/lib
If everything works, it's safe to delete the OpenJPEG and ImageMagick source directories.
Footnotes
-
I had initially included libheif-dev as well here, but this library caused an error in the build process, so I removed it (and then re-ran everything from
./configure
onwards) ↩