I want to use ImageMagick to convert some files from jp2 (JPEG-2000) to jpg. The command to do that is fine, but I don't know how to enable the jp2 delegate in ImageMagick.

I installed ImageMagick via package manager: sudo apt-get install ImageMagick.
I'm using ImageMagick 6.8.9-9, this is the most up to date version of ImageMagick available from apt-get.

Currently, a lot of the main file types are automatically included. The following libraries have built-in support and are listed as delegates:

bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

Edit: I should have mentioned, I did try file conversions before starting to wrangle with openjpeg-2. A command like convert input.jp2 output.jpg gives me the error message:

convert: no decode delegate for this image format `JP2' @ error/constitute.c/ReadImage/501.

So, I need to get jp2 working. The relevant library is openjpeg-2, and ImageMagick's delegates page gives the tarball, openjpeg-2.0.0.tar.gz.

Okay, so I downloaded it and followed the instructions to install given in the install file. Normal stuff: cmake ., sudo make install.

But now, how do I configure ImageMagick so that it 'picks up' open-jpeg-2.0.0? Do I have to rebuild ImageMagick from source to do so? Or is there a command I can enter to get ImageMagick to enable it? Or a file I should change, etc?

I have spent ages and ages looking into this, read many Q&As online, but I still did not crack it. It is an issue of my Linux knowledge rather than something to do with ImageMagick per se, so I would really appreciate it if someone can help me figure out what the missing step is here. Thank you.

  • I solved this problem by using graphicsmagick instead, e.g. gm convert in.jp2 out.jpg
    – Sam Wilson
    May 11, 2017 at 1:19
  • I know I'm late in responding, but there is an issue with ImageMagick and JPEG-2000 which has been open for 5 years ('wrong' library linked) and that only recently (May 2020) has been assigned to one developer for fixing. For now, the only alternative seems to be to compile IM from the sources as described on the answers below... May 27, 2020 at 19:15

5 Answers 5


Install libopenjp2-tools and use opj_decompress to convert jp2 to something else:

sudo apt install libopenjp2-tools
opj_decompress -i m_3712213_sw_10_h_20160625_20161004.jp2 -OutFor TIF -o my.tif

This package provides with command-line tools allowing for conversions between several formats and also provides tools for encoding and decoding motion-jpeg2000 video formats:

  • opj_decompress: decodes j2k, jp2, and jpt files to pgm, ppm, pnm, pgx, and bmp.
  • opj_compress: encodes pnm, pgm, pgx, bmp, and ppm files to j2k, and jp2.
  • opj_dump: dump information contains in j2k and jp2.
  • index_create: create jp2 with JPIP index file from a j2k file.
  • frames_to_mj2: convert YUV video streams to mj2 format.
  • mj2_to_frames: convert mj2 video streams to YUV format.
  • wrap_j2k_in_mj2: wrap j2k codestreams into mj2 format.
  • extract-j2k-from_mj2: extract j2k codestreams from the mj2 format.

@arokath Like you, I was unable to find jp2 support in the version of ImageMagick that I installed through apt-get (Ubuntu 16.04.1 LTS).

Before building from source (following the ImageMagick docs), I installed first libopenjp2-tools and then libopenjp2-7-dev.

Note: I'm not sure which one did the trick: the alphabetical summary at the end of configure listed jp2 support as OpenJP2, rather than JP2 which I didn't notice until I had installed libopenjp2-7-dev and re-configured; it's quite possible it worked with only the first lib.

Besides ./configure, make and make install, I found that I needed (as suggested in the docs) to "configure the dynamic linker": sudo ldconfig /usr/local/lib.

Now, output of /usr/local/bin/identify -list format contains:

  J2C* rw-   JPEG-2000 Code Stream Syntax (2.1.0)
  J2K* rw-   JPEG-2000 Code Stream Syntax (2.1.0)
  JNX* r--   Garmin tile format
  JP2* rw-   JPEG-2000 File Format Syntax (2.1.0)
  JPC* rw-   JPEG-2000 Code Stream Syntax (2.1.0)
  JPM* rw-   JPEG-2000 File Format Syntax (2.1.0)
  JPT* rw-   JPEG-2000 File Format Syntax (2.1.0)
 JSON  -w+   The image format and characteristics
  • 1
    Thanks for this. I'm still having problems, unfortunately! I installed libopenjp2-tools and libopenjp2-7-dev using apt-get, then built from source, then ran sudo ldconfig /usr/local/lib. (In other words, followed the docs). STILL no JP2. Argh! It's doing my head in. I'll run through the process again just in case.
    – aroaro
    Apr 3, 2017 at 21:48
  • Still no luck. I noticed that when running ./configure, it checks for JP2 and doesn't find it: "checking for LIBOPENJP2... no". As a bonus, now it's not working for JPEG conversions in general. When I tried convert in.png out.jpg it creates a file, but it's invalid - it's a PNG file just with the jpg extension. I don't know why JPEG should suddenly be broken when I've compiled from source!
    – aroaro
    Apr 3, 2017 at 22:20
  • Try running "apt-get build-dep imagemagick" so it installs the libraries needed by imagemagick (these will be the ones it was built with in the release, so you'll still need openjp2)
    – cbz
    May 23, 2019 at 10:55

I resolve my problem of enabling the openjp2 delegation in Imagemagick.

Be sure you have install :

Now when you launch ./configure you can see openjp2 delegation

DELEGATES = mpeg jbig jng jpeg lcms lzma openjp2 png tiff zlib


I followed all the build-instruction on this page, including apt-get build-dep imagemagick. Handling jp2-files now works, however there is no JP or J2 output of the identify -list format statement of user3294778, so those are probably not necessary with Version: ImageMagick 7.1.0-20

  • Not really clear if this is a comment or an answer itself. There doesnt seem to be a link to the page you refer to. A brief overview of the build instruction will make this a self contained answer just incase the linked page disappears.
    – fossfreedom
    Jan 7, 2022 at 10:26
  • I wasn't able to comment the answer of user3294778, there were some statements about needing some credibility first. For some reason I'm able to respond to your comment underneath my answer though. The page I referred to is THIS page: askubuntu.com/questions/899541/…, so it will probably remain as long as my remark is here as well.
    – rmast
    Jan 8, 2022 at 12:29
  • By the way I'm still not able to comment to the original answer. "You must have 50 reputation to comment"
    – rmast
    Jan 8, 2022 at 12:35

Here is a script I wrote to build from source on Ubuntu 22.


sudo apt-get install libopenjp2-tools libopenjp2-7-dev pkg-config

if ! [ -f $tar_file ]; then
    echo "$tar_file" not found, downloading...
    wget https://download.imagemagick.org/ImageMagick/download/releases/$tar_file
if ! [ -d $folder ]; then
    echo "$folder" not found, untar-ing...
    tar xvzf $tar_file

cd $folder || exit

./configure --with-openjp2 > configure.log
if grep -q "jp2" configure.log; then
  echo "JP2 enabled"
  echo "JP2 not enabled, see configure.log, exiting"
  exit 1

sudo make > make.log
sudo make install > make_install.log
sudo ldconfig /usr/local/lib
if convert -version | grep -q jp2; then
  echo "JP2 installed correctly!"
  echo "JP2 not enabled, see make.log and make_install.log, exiting"
  exit 1

cd ..
sudo rm -rf ImageMagick-${version}*

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .