Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 503692 - =media-gfx/imagemagick-6.8.8.5: jpeg2k (media-libs/openjpeg:2) support broken
Summary: =media-gfx/imagemagick-6.8.8.5: jpeg2k (media-libs/openjpeg:2) support broken
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Gentoo Graphics Project
URL: http://www.imagemagick.org/discourse-...
Whiteboard:
Keywords:
Depends on:
Blocks: 500580 501706
  Show dependency tree
 
Reported: 2014-03-07 04:56 UTC by Alexander Miller
Modified: 2014-04-08 11:49 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
enable jpeg2000 compression in pdf files (imagemagick-6.8.8.5-jp2-in-pdf.patch,1.40 KB, patch)
2014-03-07 04:56 UTC, Alexander Miller
Details | Diff
don't use opj_stream_destroy_v3, fixes linking (imagemagick-6.8.8.5-openjpeg-api.patch,2.31 KB, patch)
2014-03-07 04:59 UTC, Alexander Miller
Details | Diff
imagemagick-6.8.8.10-enable-openjp2-delegate-in-pdf-encoder.patch (imagemagick-6.8.8.10-enable-openjp2-delegate-in-pdf-encoder.patch,711 bytes, patch)
2014-04-08 01:38 UTC, Alexander Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Miller 2014-03-07 04:56:16 UTC
Created attachment 371936 [details, diff]
enable jpeg2000 compression in pdf files

I've tried to convert an image to pdf with jpeg2k compression, like:
$ convert test.png -compress JPEG2000 test.pdf
Unfortunately I've lost the original error message, but it was something with "DelegateLibrarySupportNotBuiltIn" and referred me to coders/pdf.c, line 1252. However, imagemagick-6.8.8.5 was built with USE=jpeg2k, and I've done this successfully with imagemagick-6.8.6.8 before.

Now let's try a plain jpeg2k file:
$ convert test.png test.jp2
convert: symbol lookup error: /usr/lib64/ImageMagick-6.8.8/modules-Q16HDRI/coders/jp2.so: undefined symbol: opj_stream_destroy_v3

Nice, a runtime linker error! Let's check the build log:
coders/jp2.c:372:7: warning: implicit declaration of function 'opj_stream_destroy_v3' [-Wimplicit-function-declaration]

Well, that symbol is not present in any released version of openjpeg, but has been added to svn trunk a year ago. This is probably the cause for bug 501706 and bug 500580, too.

The attached patches fix both bugs, at least they work for me.
Comment 1 Alexander Miller 2014-03-07 04:59:41 UTC
Created attachment 371938 [details, diff]
don't use opj_stream_destroy_v3, fixes linking
Comment 2 Alexander Miller 2014-03-07 17:26:32 UTC
I think the last sentence in comment #0 was too ambiguous:
> The attached patches fix both bugs, at least they work for me.

I was talking about the two errors I described first, not the gentoo bugs (which may be fixed, too, but I didn't test). I should have written:
* The second patch fixes the "convert test.png test.jp2" case for me (and probably the two gentoo bugs, too).
* The first patch fixes the pdf case for me.
Comment 3 Samuli Suominen gentoo-dev 2014-03-19 16:48:31 UTC
Comment on attachment 371936 [details, diff]
enable jpeg2000 compression in pdf files

This patch is part of upstream release 6.8.8-8 which I'm adding to Portage now.
Comment 4 Samuli Suominen gentoo-dev 2014-03-19 16:58:55 UTC
fixed in 6.8.8.8, added your patch in, this needs to be reported upstream!
Comment 5 Samuli Suominen gentoo-dev 2014-04-06 12:12:45 UTC
reported here:

http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=25362
Comment 6 Samuli Suominen gentoo-dev 2014-04-07 19:24:48 UTC
(In reply to Samuli Suominen from comment #5)
> reported here:
> 
> http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=25362

and upstream committed a fix to the subversion :)
Comment 7 Alexander Miller 2014-04-08 01:38:49 UTC
Created attachment 374512 [details, diff]
imagemagick-6.8.8.10-enable-openjp2-delegate-in-pdf-encoder.patch

jpeg2000 compression in PDF files is still broken in imagemagick-6.8.8.10.

In comment #3 Samuli wrote that the patch from attachment 371936 [details, diff] is part of upstream release 6.8.8-8. This is not correct. Only one file was fixed in that release, the part of the patch which is important for this bug is *not* part of 6.8.8-8 (or 6.8.8-10). I've created a patch with the missing pieces.

Here is what hat I did to test imagemagick-6.8.8.10:
$ convert test.png -compress jpeg2000 -quality 35 test.pdf
convert: delegate library support not built-in `test.pdf' (JP2) @ error/pdf.c/WritePDFImage/1283.
$ pdfimages -list test.pdf
page   num  type   width height color comp bpc  enc interp  object ID
---------------------------------------------------------------------
   1     0 image    2481  3500  rgb     3   8  image  no         8  0
$ ls -ks1 test.{png,pdf}
4012 test.pdf
3136 test.png

As you can see, jpeg2000 compression is not used. Instead I get a large file with RLE compression.

The same commands after rebuilding with my patch:
$ convert test.png -compress jpeg2000 -quality 35 test.pdf
$ pdfimages -list test.pdf
page   num  type   width height color comp bpc  enc interp  object ID
---------------------------------------------------------------------
   1     0 image    2481  3500  rgb     3   8  jpx    no         8  0
$ ls -ks1 test.{png,pdf}
 584 test.pdf
3136 test.png

It works! The "enc" column shows "jpx" and the file is much smaller.

You may want to send this patch upstream, too.
Comment 8 Samuli Suominen gentoo-dev 2014-04-08 04:32:32 UTC
(In reply to Alexander Miller from comment #7)
> Created attachment 374512 [details, diff] [details, diff]
> imagemagick-6.8.8.10-enable-openjp2-delegate-in-pdf-encoder.patch
> 
> jpeg2000 compression in PDF files is still broken in imagemagick-6.8.8.10.

ouch. reported here, http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=25376

will bump in Portage after morning coffee :p
Comment 9 Samuli Suominen gentoo-dev 2014-04-08 11:49:19 UTC
(In reply to Samuli Suominen from comment #8)
> (In reply to Alexander Miller from comment #7)
> > Created attachment 374512 [details, diff] [details, diff] [details, diff]
> > imagemagick-6.8.8.10-enable-openjp2-delegate-in-pdf-encoder.patch
> > 
> > jpeg2000 compression in PDF files is still broken in imagemagick-6.8.8.10.
> 
> ouch. reported here,
> http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=25376

upstream says he applied your patch :)

http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=25376&sid=4087a8d28aa34175d395029d8e6ea340#p110065

> will bump in Portage after morning coffee :p

done. 6.8.8.10-r1