Error combining jp2 files with magick.net

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-06-15T04:04:12-07:00

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?

User avatar
dlemstra
Posts: 1475
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Error combining jp2 files with magick.net

Post by dlemstra » 2018-06-15T10:00:12-07:00

Can you share your images on something like dropbox?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Re: Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-06-17T23:30:47-07:00

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!

User avatar
fmw42
Posts: 23622
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error combining jp2 files with magick.net

Post by fmw42 » 2018-06-18T09:56:25-07:00

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.

User avatar
dlemstra
Posts: 1475
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Error combining jp2 files with magick.net

Post by dlemstra » 2018-06-18T13:03:19-07:00

Can you move your images to a more trusted spot like dropbox or onedrive? It's downloading an executable instead of your original file.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

User avatar
fmw42
Posts: 23622
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error combining jp2 files with magick.net

Post by fmw42 » 2018-06-18T13:10:20-07:00

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.

tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Re: Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-06-18T22:44:28-07:00

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!

tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Re: Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-06-20T22:55:08-07:00

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

tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Re: Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-06-25T22:04:33-07:00

So
can you reproduce this problem?

User avatar
dlemstra
Posts: 1475
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Error combining jp2 files with magick.net

Post by dlemstra » 2018-06-26T13:16:35-07:00

I downloaded the files but I haven't tried to reproduce the error yet. Hope I can make some time for it next week.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Re: Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-08-06T03:17:21-07:00

Hi
After a month of holiday, i just wanted to know if it was possible to reproduce my problem?

User avatar
dlemstra
Posts: 1475
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Error combining jp2 files with magick.net

Post by dlemstra » 2018-08-07T13:20:16-07:00

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);
}
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Re: Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-08-09T22:13:05-07:00

ok i'll test it again.

which version of magick.net did you used?

User avatar
dlemstra
Posts: 1475
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Error combining jp2 files with magick.net

Post by dlemstra » 2018-08-11T04:08:14-07:00

The latest Q16 any cpu version.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

tco95ttocs
Posts: 17
Joined: 2017-08-29T06:37:37-07:00
Authentication code: 1151

Re: Error combining jp2 files with magick.net

Post by tco95ttocs » 2018-08-14T01:19:29-07:00

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:

Post Reply