Compiling ImageMagick with JPEG 2000 on Ubuntu

In the previous post I published two scripts to combine satellite spectral bands with ImageMagick but one of the script needs JPEG 2000 support to open *.jp2 images and that support has been missing on Ubuntu since 2015.

You can check if you have it by running convert -version | grep jp2.

The support is provided by a package called openjpeg2 which is not included in main. This issue should be resolved in future versions of Ubuntu but at the moment we have to recompile ImageMagick.

# development tools
sudo apt-get install build-essential

# required dependencies
sudo apt-get build-dep imagemagick

# openjpeg2
sudo apt-get install libopenjp2-7-dev

# imagemagick
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd ImageMagick-*
./configure --disable-shared
make
sudo make install

Tags: imagemagick, linux