Page 1 of 2

Error combining jp2 files with magick.net

Posted: 2018-06-15T04:04:12-07:00
by tco95ttocs
Hi guys,

i got an error when trying to combine some jp2 files.
These files are created by separating the chanels of a tiff-file using magick.net.
But now i wanted to go the way back and combine these separated chanels, but it doesn't work! I got the Errormessage :

"Failed to decode the codestream in the JP2 file

`OpenJP2' @ error/jp2.c/JP2ErrorHandler/193"

{"unable to decode image file `\\ROBM8470.jp2' @ error/jp2.c/ReadJP2Image/384"}

I used MagickImageCollection to do the combining!

Code: Select all

using (MagickImageCollection images = new MagickImageCollection())
                {
                    MagickImage redimage = new MagickImage(ROBM8470.jp2);
                    images.Add(redimage);
                    MagickImage greenimage = new MagickImage(GOBM8470.jp2);
                    images.Add(greenimage);
                    MagickImage blueimage = new MagickImage(BOBM8470.jp2);
                    images.Add(blueimage);
                    MagickImage irimage = new MagickImage(IOBM8470.jp2);
                    images.Add(irimage);
                    }
the Error is shown directly when reading the first image!

Versions i tested are magick.net 7.0.7 and 7.4.6

when i use ImageMagick 7.0.8 it works

Code: Select all

convert ROBM8470.jp2 GOBM8470.jp2 BOBM8470.jp2 IOBM8470.jp2 -combine NOBM8470.tif
So is something wrong with the magick.net or did i forgot something?

Re: Error combining jp2 files with magick.net

Posted: 2018-06-15T10:00:12-07:00
by dlemstra
Can you share your images on something like dropbox?

Re: Error combining jp2 files with magick.net

Posted: 2018-06-17T23:30:47-07:00
by tco95ttocs
Hi guys,

here you can found the original image i used to separate into the 4 chanels:
R
G
B and
infrared

afterwards i tried to combine them to one image. But then i got that error above!

Re: Error combining jp2 files with magick.net

Posted: 2018-06-18T09:56:25-07:00
by fmw42
ImageMagick does not support multi-channel (TIFF) images, yet, as far as I know, unless the 4th channel is an alpha channel or the channels are CMYK.

Re: Error combining jp2 files with magick.net

Posted: 2018-06-18T13:03:19-07:00
by dlemstra
Can you move your images to a more trusted spot like dropbox or onedrive? It's downloading an executable instead of your original file.

Re: Error combining jp2 files with magick.net

Posted: 2018-06-18T13:10:20-07:00
by fmw42
Dirk,

Magick and I started working on multi-channel tiffs a while back. But we did not finish it. So there may be some initial coding somewhere in IM.

Re: Error combining jp2 files with magick.net

Posted: 2018-06-18T22:44:28-07:00
by tco95ttocs
Hi,
i put the files to dropbox for better handling.

I know that normally the 4th channel ist the alpha channel, but in our case we use this channel as the infrared channel. and as i can say, separating these 4 channels works fine!

Re: Error combining jp2 files with magick.net

Posted: 2018-06-20T22:55:08-07:00
by tco95ttocs
Are the files ok for testing?
i also got some smaller files, and with them the combing works!

not working:
original tif : 770mb and 1GB
seperated jp2 (quality 45): between 70 and 100mb

working:
original tif: 400mb
seperated jp2 (quality 45): between 15 and 30 mb

Re: Error combining jp2 files with magick.net

Posted: 2018-06-25T22:04:33-07:00
by tco95ttocs
So
can you reproduce this problem?

Re: Error combining jp2 files with magick.net

Posted: 2018-06-26T13:16:35-07:00
by dlemstra
I downloaded the files but I haven't tried to reproduce the error yet. Hope I can make some time for it next week.

Re: Error combining jp2 files with magick.net

Posted: 2018-08-06T03:17:21-07:00
by tco95ttocs
Hi
After a month of holiday, i just wanted to know if it was possible to reproduce my problem?

Re: Error combining jp2 files with magick.net

Posted: 2018-08-07T13:20:16-07:00
by dlemstra
I completely forgot about this issue. I just tried to reproduce it with your sample images with the latest version and I cannot reproduce your issue:

Code: Select all

using (MagickImageCollection images = new MagickImageCollection())
{
    MagickImage redimage = new MagickImage(@"I:\issues\topic34150\ROBN2184.jp2");
    images.Add(redimage);
    MagickImage greenimage = new MagickImage(@"I:\issues\topic34150\GOBN2184.jp2");
    images.Add(greenimage);
    MagickImage blueimage = new MagickImage(@"I:\issues\topic34150\BOBN2184.jp2");
    images.Add(blueimage);
    MagickImage irimage = new MagickImage(@"I:\issues\topic34150\IOBN2184.jp2");
    images.Add(irimage);
}

Re: Error combining jp2 files with magick.net

Posted: 2018-08-09T22:13:05-07:00
by tco95ttocs
ok i'll test it again.

which version of magick.net did you used?

Re: Error combining jp2 files with magick.net

Posted: 2018-08-11T04:08:14-07:00
by dlemstra
The latest Q16 any cpu version.

Re: Error combining jp2 files with magick.net

Posted: 2018-08-14T01:19:29-07:00
by tco95ttocs
ok
i tried again, with magick.net 7.6.0 with this code:

Code: Select all

 using (MagickImageCollection images = new MagickImageCollection())
            {
                MagickImage redimage = new MagickImage(@"E:\luna\magick_test\NOBN\R\ROBN2184.jp2");
                images.Add(redimage);
                MagickImage greenimage = new MagickImage(@"E:\luna\magick_test\NOBN\G\GOBN2184.jp2");
                images.Add(greenimage);
                MagickImage blueimage = new MagickImage(@"E:\luna\magick_test\NOBN\B\BOBN2184.jp2");
                images.Add(blueimage);
                MagickImage irimage = new MagickImage(@"E:\luna\magick_test\NOBN\I\IOBN2184.jp2");
                images.Add(irimage);
                using (IMagickImage image = images.Combine(ColorSpace.sRGB))
                {
                    image.Format = MagickFormat.Tif;
                    image.Write(@"E:\luna\magick_test\NOBN2184.tif");
                }
            }
And the result is very strange!
In my testproject it works fine, but in my normal project i still got this decode error :shock: