Missing jp2 delegate

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
pronaldzito
Posts: 12
Joined: 2013-12-03T15:56:51-07:00
Authentication code: 6789

Missing jp2 delegate

Post by pronaldzito »

I have recently upgraded from 6.8.8-1 to 6.8.8-5
The computer is running Ubuntu 13.04
I noticed that in this upgrade libjasper was replaced with libopenjp2 for JPEG-2000 support
I downloaded the delegate source, built and installed it.
When I configure magick, specifically including --with-openjp2, it shows:
-L/opt_test/lib (my installed library path)
-lopenjp2
DELEGATES = bzlib djvu mpeg fontconfig freetype jbig jng jpeg lcms lqr lzma openexr openjp2 pango png ps rsvg tiff webp x xml zlib
ldd reports the correct reference to libopenjp2.so.6 for each of the magick libraries and utility programs, however, given a JPEG-2000 file, identify reports no decode delegate and using convert to try to create a jp2 results in a file of the same format as the input.
What am I doing wrong when I build ImageMagick?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Missing jp2 delegate

Post by magick »

Post a URL to your JPEG-2000 image. We need to verify if we can read it. If not, its a coders bug. If so, it may be a problem on your end.
pronaldzito
Posts: 12
Joined: 2013-12-03T15:56:51-07:00
Authentication code: 6789

Re: Missing jp2 delegate

Post by pronaldzito »

I'm pretty sure this is a build issue.

I had previously built 6.8.6-10:
> /opt/bin/identify --version
Version: ImageMagick 6.8.6-10 2013-12-04 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenCL
Delegates: bzlib cairo djvu fontconfig freetype jbig jng jp2 jpeg lcms lqr lzma openexr pango pangocairo png png rsvg tiff webp x xml zlib

Running identify on files where the original TIFF was converted JPEG-2000 via convert v6.8.6-10:
> /opt/bin/identify -format "%[version] %f type=%[type] coder=%[magick]\n" k030542701.tif k030542701.jp2
identify: ASCII value for tag "Artist" does not end in null byte. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/838.
ImageMagick 6.8.6-10 2013-12-04 Q16 http://www.imagemagick.org k030542701.tif type=TrueColor coder=TIFF
ImageMagick 6.8.6-10 2013-12-04 Q16 http://www.imagemagick.org k030542701.jp2 type=TrueColor coder=JP2


Here is the info on 6.8.8-5:
> /opt_test/bin/identify --version
Version: ImageMagick 6.8.8-5 Q16 x86_64 2014-02-13 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenCL
Delegates: bzlib cairo djvu fontconfig freetype jbig jng jpeg lcms lqr lzma openexr pangocairo png rsvg tiff webp x xml zlib

Note that jp2 is not included in delegates list.
> /opt_test/bin/identify -format "%[version] %f type=%[type] coder=%[magick]\n" k030542701.tif k030542701.jp2
identify: ASCII value for tag "Artist" does not end in null byte. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/850.
identify: no decode delegate for this image format `k030542701.jp2' @ error/constitute.c/ReadImage/555.
ImageMagick 6.8.8-5 Q16 x86_64 2014-02-13 http://www.imagemagick.org k030542701.tif type=TrueColor coder=TIFF


I also converted that same TIFF file to JPEG-2000 using openjp2 obj_compress and get the same results from Magick; i.e. 6.8.6-10 recognizes is, 6.8.8-5 does not.

Here is the content of /opt_test/lib/ImageMagick-6.8.8/config-Q16/configure.xml which shows openjp2 in the DELEGATES:
<configuremap>
<configure name="CC" value="clang"/>
<configure name="CFLAGS" value="-pthread -I/usr/include/OpenEXR -I/usr/include/lqr-1 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/opt_test/include/openjpeg-2.0 -I/usr/include/freetype2 -pthread -g -O2 -Wall -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16"/>
<configure name="CODER_PATH" value="/opt_test/lib/ImageMagick-6.8.8/modules-Q16/coders"/>
<configure name="CONFIGURE_PATH" value="/opt_test/etc/ImageMagick-6/"/>
<configure name="CONFIGURE" value="./configure '--prefix=/opt_test' '--enable-shared' '--enable-openmp' '--enable-opencl' '--with-autotrace' '--with-rsvg' '--with-openjp2' 'CC=clang' 'CXX=clang++'"/>
<configure name="COPYRIGHT" value="Copyright (C) 1999-2014 ImageMagick Studio LLC"/>
<configure name="CPPFLAGS" value="-I/opt_test/include/ImageMagick-6"/>
<configure name="CXXFLAGS" value="-g -O2 -pthread"/>
<configure name="CXX" value="clang++"/>
<configure name="DEFS" value="-DHAVE_CONFIG_H"/>
<configure name="DELEGATES" value="bzlib djvu mpeg fontconfig freetype jbig jng jpeg lcms lqr lzma openexr openjp2 pango png ps rsvg tiff webp x xml zlib"/>
<configure name="DISTCHECK_CONFIG_FLAGS" value="'CC=clang' 'CXX=clang++' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-gslib=no --with-fontpath= --with-gvc=no --with-mupdf=no --with-wmf=no --with-perl=no"/>
<configure name="DOCUMENTATION_PATH" value="/opt_test/share/doc/ImageMagick-6"/>
<configure name="EXEC-PREFIX" value="/opt_test"/>
<configure name="EXECUTABLE_PATH" value="/opt_test/bin"/>
<configure name="FEATURES" value="DPC OpenCL"/>
<configure name="FILTER_PATH" value="/opt_test/lib/ImageMagick-6.8.8/modules-Q16/filters"/>
<configure name="HOST" value="x86_64-unknown-linux-gnu"/>
<configure name="INCLUDE_PATH" value="/opt_test/include/ImageMagick-6"/>
<configure name="LDFLAGS" value="-L/opt_test/lib "/>
<configure name="LIBRARY_PATH" value="/opt_test/lib/ImageMagick-6.8.8"/>
<configure name="LIBS" value="-ljbig -llcms2 -ltiff -lfreetype -ljpeg -llqr-1 -lglib-2.0 -lpng16 -ldjvulibre -lfontconfig -lwebp -lXext -lSM -lICE -lX11 -llzma -lbz2 -pthread -lIlmImf -lz -lImath -lHalf -lIex -lIlmThread -L/opt_test/lib -lopenjp2 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -lrsvg-2 -lm -lgio-2.0 -lgdk_pixbuf-2.0 -lcairo -lgobject-2.0 -lglib-2.0 -lxml2 -lz -lm -lgomp -lOpenCL -lm"/>
<configure name="LIB_VERSION_NUMBER" value="6,8,8,5"/>
<configure name="LIB_VERSION" value="0x688"/>
<configure name="NAME" value="ImageMagick"/>
<configure name="PCFLAGS" value="-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16"/>
<configure name="PREFIX" value="/opt_test"/>
<configure name="QuantumDepth" value="16"/>
<configure name="RELEASE_DATE" value="2014-02-13"/>
<configure name="SHAREARCH_PATH" value="/opt_test/lib/ImageMagick-6.8.8/config-Q16"/>
<configure name="SHARE_PATH" value="/opt_test/share/ImageMagick-6"/>
<configure name="SVN_REVISION" value="14837"/>
<configure name="TARGET_CPU" value="x86_64"/>
<configure name="TARGET_OS" value="linux-gnu"/>
<configure name="TARGET_VENDOR" value="unknown"/>
<configure name="VERSION" value="6.8.8"/>
<configure name="WEBSITE" value="http://www.imagemagick.org"/>
</configuremap>

So it would appear that the build includes openjp2.
Is there still a need for me to post a jp2 file?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Missing jp2 delegate

Post by magick »

> Is there still a need for me to post a jp2 file?

Sure. We need to determine if there is a problem interpretting your particular JP2 image file or if its a problem with your particular build of ImageMagick with OpenJP2 support. If we can read your image, it isolates the problem to your build.
pronaldzito
Posts: 12
Joined: 2013-12-03T15:56:51-07:00
Authentication code: 6789

Re: Missing jp2 delegate

Post by pronaldzito »

I've placed 2 images here
https://www.dropbox.com/sh/j4fkng56qk5x9zi/emrE9aYtsT
k030542701_convert.jp2 was created with convert v6.8.6-10
k030542701_ojb_compress.jp2 was created with obj_compress (OpenJPEG) v2.0.0
Last edited by pronaldzito on 2014-02-14T10:35:29-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Missing jp2 delegate

Post by snibgo »

.
Last edited by snibgo on 2014-02-14T11:14:22-07:00, edited 1 time in total.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Missing jp2 delegate

Post by magick »

Ok, these images work fine for us. This command returns:
  • -> identify -list format | grep -i jp2
    J2K* JP2 rw- JPEG-2000 Code Stream Syntax (2.0.0)
    JP2* JP2 rw- JPEG-2000 File Format Syntax (2.0.0)
    JPC* JP2 rw- JPEG-2000 Code Stream Syntax (2.0.0)
    JPT* JP2 rw- JPEG-2000 File Format Syntax (2.0.0)
This shows that JPEG-2000 images can be read and written by this instance of ImageMagick. Does the command return something similar? If not, check for /usr/local/lib/ImageMagick-6.8.8/modules-Q16/coders/jp2.so. Are the permission set properly on this file? What does the ldd command return for this file?
pronaldzito
Posts: 12
Joined: 2013-12-03T15:56:51-07:00
Authentication code: 6789

Re: Missing jp2 delegate

Post by pronaldzito »

identify -list format does not show JP2 nor JPEG-2000
I am installing in /opt_test rather than /usr/local as others are using this computer
It does not build a shared object for jp2
I did use nm to check the jp2.o file for unresolved references and all those that begin with "opj" are found in (resolved by) libopenjp2.so
I can run ldd on either identify or libMagickCore-6.Q16.so and both show the reference to libopenjp2:
> ldd /opt_test/lib/libMagickCore-6.Q16.so | grep jp2
libopenjp2.so.6 => /opt_test/lib/libopenjp2.so.6 (0x00007f80bb66c000)
> ldd /opt_test/bin/identify | grep jp2
libopenjp2.so.6 => /opt_test/lib/libopenjp2.so.6 (0x00007f52394f9000)
I am confused by this found in the configure output:
JPEG v1 --with-jpeg=yes yes
JPEG-2000 --with-jp2=
...
OpenJP2 --with-openjp2=yes yes

But I also see this, which leads me to believe that it's finding the openjp2 library:
LIBS = -ljbig -llcms2 -ltiff -lfreetype -ljpeg -llqr-1 -lglib-2.0 -lpng16 -ldjvulibre -lfontconfig -lwebp -lXext -lXt -lSM -lICE -lX11 -llzma -lbz2 -pthread -lIlmImf -lz -lImath -lHalf -lIex -lIlmThread -L/opt_test/lib -lopenjp2 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -lrsvg-2 -lm -lgio-2.0 -lgdk_pixbuf-2.0 -lcairo -lgobject-2.0 -lglib-2.0 -lxml2 -lz -lm -lgomp -lOpenCL -lm
...
DELEGATES = bzlib djvu mpeg fontconfig freetype jbig jng jpeg lcms lqr lzma openexr openjp2 pango png ps rsvg tiff webp x xml zlib

I ran make clean follow by make with debug option and found these interesting tidbits:
Considering target file `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo'.
...
Looking for a rule with intermediate file `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo.c'.
...
Looking for a rule with intermediate file `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo.w'.
...
No implicit rule found for `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo'.
Finished prerequisites of target file `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo'.
No need to remake target `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo'.
...
Considering target file `coders/.deps/coders_jp2_la-jp2.Plo'.
Looking for an implicit rule for `coders/.deps/coders_jp2_la-jp2.Plo'.
...
Looking for a rule with intermediate file `coders/.deps/coders_jp2_la-jp2.Plo.c'.
...
No implicit rule found for `coders/.deps/coders_jp2_la-jp2.Plo'.
Finished prerequisites of target file `coders/.deps/coders_jp2_la-jp2.Plo'.
No need to remake target `coders/.deps/coders_jp2_la-jp2.Plo'.
...
No need to remake target `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo'.
No need to remake target `coders/.deps/coders_jp2_la-jp2.Plo'.
No need to remake target `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo'.
No need to remake target `coders/.deps/magick_libMagickCore_6_Q16_la-jp2.Plo'.
Considering target file `coders/magick_libMagickCore_6_Q16_la-jp2.lo'.
File `coders/magick_libMagickCore_6_Q16_la-jp2.lo' does not exist.
Considering target file `coders/jp2.c'.
No need to remake target `coders/jp2.c'.
...
Pruning file `coders/jp2.c'.
...
Must remake target `coders/magick_libMagickCore_6_Q16_la-jp2.lo'.
Putting child 0x013a5170 (coders/magick_libMagickCore_6_Q16_la-jp2.lo) PID 13316 on the chain.
Live child 0x013a5170 (coders/magick_libMagickCore_6_Q16_la-jp2.lo) PID 13316
CC coders/magick_libMagickCore_6_Q16_la-jp2.lo
Reaping winning child 0x013a5170 PID 13316
Live child 0x013a5170 (coders/magick_libMagickCore_6_Q16_la-jp2.lo) PID 13332
Reaping winning child 0x013a5170 PID 13332
Removing child 0x013a5170 PID 13332 from chain.
Successfully remade target file `coders/magick_libMagickCore_6_Q16_la-jp2.lo'.

Does the "pruning coders/jp2.c mean that jp2 is being excluded from the build?
pronaldzito
Posts: 12
Joined: 2013-12-03T15:56:51-07:00
Authentication code: 6789

Re: Missing jp2 delegate

Post by pronaldzito »

I was able to get JPEG-2000 working with libopenjp2.so by modifying the source code in magick/static.c
Specifically, I changed lines 236-238 from this:
#if defined(MAGICKCORE_JP2_DELEGATE)
(void) RegisterJP2Image();
#endif

to this:
#if defined(MAGICKCORE_JP2_DELEGATE)
(void) RegisterJP2Image();
#elif defined(MAGICKCORE_LIBOPENJP2_DELEGATE)
(void) RegisterJP2Image();
#endif
Post Reply