BTMash

Blob of contradictions

Installing ImageMagick with JP2 support on CentOS

Written

Its been a long time and while I would normally kick off such a long hiatus with something exciting, I'm going to sneak him a memo instead. I've been working on an Islandora project over the past few months and, since I started work at Cherry Hill, has involved me working getting a bit more familiar with RPM-based Linux (Amazon Linux, CentOS, Redhat). Search Engines are still very much my friend (see my last article on Installing Jenkins and Fabric on RedHat as I ran into trouble at that time as well). Anyways, back on point to Islandora. I wanted to install Imagemagick and had incorrectly assumed that JPEG-2000 support would come out of the box like it does with Debian/Ubuntu. It does not. Every article out there implied that the only way to get support for JP2 is the following:

  1. yum install jasper jasper-devel
  2. # Install Imagemagick from source

However, this doesn't always work. If you want to just stick with a rpm system (so either the really outdated version of Imagemagick that is in the official repos or via a source RPM), Imagemagick doesn't pick up JP2 support via JasPer. I'm not wholly sure why (and hopefully someone in the RHEL/CentOS community might be able to give insight into a better way) ... but I did finally figure out another way. That is to use the OpenJPEG libraries, which is an open source JPEG-2000 codec. A few things to note if you end up going down this route:

  • OpenJPEG is slower than JasPer
  • OpenJPEG produces better quality images than JasPer (encoding <-> decoding. See article)

Given that we were dealing with Preservation of images, having the better image quality was a higher priority than the one-time conversion speed of said images. With that said, Kakadu may still be a good option as it is the fastest codec for JPEG-2000 and the image quality is very close to what OpenJPEG offers.

With that out of the way, your commands end up being:

  1. yum install openjpeg-libs
  2. yum install Imagemagick

And you are done. Typing convert -list | grep JP should let you see that you finally have JP2 support! This method is nice since you can still install RPMs from source if you want (to be able to get the latest version of Imagemagick) but you have actual options instead of just one way.