As far as I can tell ImageMagick uses JasPer library for JPEG2000 conversion. The problem with using JasPer directly is that none of its support input formats themselves support transparency, even though the JasPer documentation implies that transparency is supported (it doesn't say it is or isn't, but it does talk a bit about how transparency is encoded.)
I found this post from a few months ago on this forum with someone asking a very similar question to mine:
In that post the user got it working somehow, but there is no actual solution posted there. So at least this shows that what I want to do is possible!
I was previously using whatever version of IM came with Ubuntu 14.04, but have now upgraded to the latest to try to get this to work:
Code: Select all
Version: ImageMagick 6.9.0-0 Q16 x86_64 2014-12-08 http://www.imagemagick.org Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC Features: DPC OpenMP Delegates (built-in): fontconfig freetype jbig jng jp2 jpeg lcms lzma openexr pangocairo png tiff webp x xml zlib
On both the previous version and this version the resulting JPEG2000 have black background instead of transparent.
Things I have tried, on both versions are:
convert test.png test.jp2
convert test.png -define jp2:rate=0.3 -define compression=JPEG2000 test.jp2
convert test.png -alpha Set -background transparent test2.jp2
convert test.png -background none test3.jp2
None of these work. All of them turn the previously transparent background black.
I also tried converting test.png to PNG8 and then converting that to JP2, thinking that since PNG8 supports only full transparency (instead of partial transparency) it might help it decide to be transparent. But no, the background is still black on the JP2.
Here is a test image:
I just don't understand...