Skip to content

Instantly share code, notes, and snippets.

@bitsgalore
Created February 26, 2020 14:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitsgalore/c57100ecba99e589ce83b6a0aa7c4b28 to your computer and use it in GitHub Desktop.
Save bitsgalore/c57100ecba99e589ce83b6a0aa7c4b28 to your computer and use it in GitHub Desktop.
Imagemagick + openjpeg build and install notes

ImageMagick / OpenJPEG build and install notes

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).

Cmake

First install Cmake, which we need for building both OpenJPEG and ImageMagick :

sudo apt install cmake

OpenJPEG

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

ImageMagick

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

  1. 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment