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 '17 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 '20 at 19:15

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.

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


@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.
    – arokath
    Apr 3 '17 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!
    – arokath
    Apr 3 '17 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 '19 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.