Cannot decode JP2000 Images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
footnoter

Cannot decode JP2000 Images

Post by footnoter »

Certain JP2000 images fail to decode (I am using identify or convert). I've tried debug mode but it does not give a reason why the image cannot be decoded. The images open fine in Kakadu. Any idea why this image doesn't work?

An example image can be found at: http://chroniclingamerica.loc.gov/lccn/ ... /seq-1.jp2
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cannot decode JP2000 Images

Post by snibgo »

identify and convert work fine for me, Windows 7, IM 6.6.2-4. What version/platform are you on? If old, an upgrade might help.

The image is also large: 5284x7222. This might be a problem on your machine. Do you have problems with just the large images?
snibgo's IM pages: im.snibgo.com
footnoter

Re: Cannot decode JP2000 Images

Post by footnoter »

I am using 6.6.2-Q8 on Vista. I can open other JP2 images just fine. The error message is:

error: cannot decode code stream
2010-06-30T09:18:06-06:00 0:00.171 0.016u 6.6.2 Exception Magick[7868]: jp2.c/ReadJP2Image/400/Exception
unable to decode image file `C:\Temp\ImageTest\seq-1.jp2'
2010-06-30T09:18:06-06:00 0:00.187 0.016u 6.6.2 Cache Magick[7868]: cache.c/DestroyPixelCache/1601/Cache
destroy
Magick: unable to decode image file `C:\Temp\ImageTest\seq-1.jp2' @ error/jp2.c/ReadJP2Image/400.
footnoter

Re: Cannot decode JP2000 Images

Post by footnoter »

Please tell me more about your install. I installed using a binary install (ImageMagick-6.6.2-4-Q8-windows-static.exe I think).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cannot decode JP2000 Images

Post by snibgo »

Same here, the standard Windows static binary, except that mine is Q16 (which needs twice the memory of Q8).

The mention of DestroyPixelCache in the error report suggests a memory issue. My laptop has 4 GB memory. How much do you have? Does closing all other software (browser etc) help? Does the resource monitor (or whatever Vista offers) show a problem?

You might also post the result of:

convert -debug all seq-1.jp2 x.jpg >x.txt
snibgo's IM pages: im.snibgo.com
footnoter

Re: Cannot decode JP2000 Images

Post by footnoter »

I really appreciate your help. 2 reasons that I don't think it is a memory issue are: 1) I can do an Identify or convert on a TIFF that has the same dimensions and much greater file size and it only makes a small blip in Task Manager memory usage. 2) I can do an identify on a different JP2 that is a little smaller and it works fine.

Instead, I have been suspicious that one of the following things is to blame.
1. The image has 25 layers while other JP2 images have 1 or 2 layers.
2. The image has additional headers with comments and metadata.

Are you using the built-in JP2 coder (Jasper)? Could you send me the output of your "identify -verbose" on the image? This might help me to figure out what is different.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cannot decode JP2000 Images

Post by snibgo »

I'm just guessing about the memory. "identify -vebose" shows an interesting ICC profile, but it shouldn't create a problem. Yes, I'm just using the built-in Jasper; nothing weird.

Try "-debug all"; it might show something useful. (But maybe not; it might just confirm that Jasper is falling over.)

Code: Select all

Image: seq-1.jp2
  Format: JP2 (JPEG-2000 File Format Syntax)
  Class: DirectClass
  Geometry: 5284x7222+0+0
  Resolution: 72x72
  Print size: 73.3889x100.306
  Units: Undefined
  Type: Grayscale
  Base type: Grayscale
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    gray: 8-bit
  Channel statistics:
    Gray:
      min: 0 (0)
      max: 255 (1)
      mean: 197.811 (0.775728)
      standard deviation: 73.123 (0.286757)
      kurtosis: 1.29607
      skewness: -1.60173
  Histogram:
    861354: (  0,  0,  0) #000000 black
    423034: (  1,  1,  1) #010101 rgb(1,1,1)
    214873: (  2,  2,  2) #020202 rgb(2,2,2)
    125408: (  3,  3,  3) #030303 grey1
     88122: (  4,  4,  4) #040404 rgb(4,4,4)
     70373: (  5,  5,  5) #050505 grey2
     56947: (  6,  6,  6) #060606 rgb(6,6,6)
     49455: (  7,  7,  7) #070707 rgb(7,7,7)
     45802: (  8,  8,  8) #080808 grey3
     43484: (  9,  9,  9) #090909 rgb(9,9,9)
     41902: ( 10, 10, 10) #0A0A0A grey4
     40283: ( 11, 11, 11) #0B0B0B rgb(11,11,11)
     38823: ( 12, 12, 12) #0C0C0C rgb(12,12,12)
     38019: ( 13, 13, 13) #0D0D0D grey5
     37153: ( 14, 14, 14) #0E0E0E rgb(14,14,14)
     36582: ( 15, 15, 15) #0F0F0F grey6
     36198: ( 16, 16, 16) #101010 rgb(16,16,16)
     35240: ( 17, 17, 17) #111111 rgb(17,17,17)
     34856: ( 18, 18, 18) #121212 grey7
     34285: ( 19, 19, 19) #131313 rgb(19,19,19)
     34076: ( 20, 20, 20) #141414 grey8
     33806: ( 21, 21, 21) #151515 rgb(21,21,21)
     33754: ( 22, 22, 22) #161616 rgb(22,22,22)
     33407: ( 23, 23, 23) #171717 grey9
     33463: ( 24, 24, 24) #181818 rgb(24,24,24)
     32860: ( 25, 25, 25) #191919 rgb(25,25,25)
     33251: ( 26, 26, 26) #1A1A1A grey10
     32820: ( 27, 27, 27) #1B1B1B rgb(27,27,27)
     32691: ( 28, 28, 28) #1C1C1C grey11
     32592: ( 29, 29, 29) #1D1D1D rgb(29,29,29)
     32713: ( 30, 30, 30) #1E1E1E rgb(30,30,30)
     32853: ( 31, 31, 31) #1F1F1F grey12
     32637: ( 32, 32, 32) #202020 rgb(32,32,32)
     33130: ( 33, 33, 33) #212121 grey13
     32848: ( 34, 34, 34) #222222 rgb(34,34,34)
     32541: ( 35, 35, 35) #232323 rgb(35,35,35)
     32633: ( 36, 36, 36) #242424 grey14
     32577: ( 37, 37, 37) #252525 rgb(37,37,37)
     32677: ( 38, 38, 38) #262626 grey15
     33273: ( 39, 39, 39) #272727 rgb(39,39,39)
     32972: ( 40, 40, 40) #282828 rgb(40,40,40)
     32760: ( 41, 41, 41) #292929 grey16
     32654: ( 42, 42, 42) #2A2A2A rgb(42,42,42)
     32406: ( 43, 43, 43) #2B2B2B grey17
     32729: ( 44, 44, 44) #2C2C2C rgb(44,44,44)
     33146: ( 45, 45, 45) #2D2D2D rgb(45,45,45)
     33002: ( 46, 46, 46) #2E2E2E grey18
     32913: ( 47, 47, 47) #2F2F2F rgb(47,47,47)
     32946: ( 48, 48, 48) #303030 grey19
     33313: ( 49, 49, 49) #313131 rgb(49,49,49)
     33190: ( 50, 50, 50) #323232 rgb(50,50,50)
     33206: ( 51, 51, 51) #333333 grey20
     33198: ( 52, 52, 52) #343434 rgb(52,52,52)
     33397: ( 53, 53, 53) #353535 rgb(53,53,53)
     33609: ( 54, 54, 54) #363636 grey21
     33556: ( 55, 55, 55) #373737 rgb(55,55,55)
     33491: ( 56, 56, 56) #383838 grey22
     33707: ( 57, 57, 57) #393939 rgb(57,57,57)
     34130: ( 58, 58, 58) #3A3A3A rgb(58,58,58)
     33817: ( 59, 59, 59) #3B3B3B grey23
     34053: ( 60, 60, 60) #3C3C3C rgb(60,60,60)
     33659: ( 61, 61, 61) #3D3D3D grey24
     34156: ( 62, 62, 62) #3E3E3E rgb(62,62,62)
     33827: ( 63, 63, 63) #3F3F3F rgb(63,63,63)
     34107: ( 64, 64, 64) #404040 grey25
     34245: ( 65, 65, 65) #414141 rgb(65,65,65)
     34063: ( 66, 66, 66) #424242 grey26
     34604: ( 67, 67, 67) #434343 rgb(67,67,67)
     34338: ( 68, 68, 68) #444444 rgb(68,68,68)
     34833: ( 69, 69, 69) #454545 grey27
     34679: ( 70, 70, 70) #464646 rgb(70,70,70)
     34591: ( 71, 71, 71) #474747 grey28
     34725: ( 72, 72, 72) #484848 rgb(72,72,72)
     34707: ( 73, 73, 73) #494949 rgb(73,73,73)
     34715: ( 74, 74, 74) #4A4A4A grey29
     34931: ( 75, 75, 75) #4B4B4B rgb(75,75,75)
     35596: ( 76, 76, 76) #4C4C4C rgb(76,76,76)
     34974: ( 77, 77, 77) #4D4D4D grey30
     35598: ( 78, 78, 78) #4E4E4E rgb(78,78,78)
     35233: ( 79, 79, 79) #4F4F4F grey31
     35827: ( 80, 80, 80) #505050 rgb(80,80,80)
     36006: ( 81, 81, 81) #515151 rgb(81,81,81)
     35924: ( 82, 82, 82) #525252 grey32
     36546: ( 83, 83, 83) #535353 rgb(83,83,83)
     36745: ( 84, 84, 84) #545454 grey33
     36724: ( 85, 85, 85) #555555 rgb(85,85,85)
     36559: ( 86, 86, 86) #565656 rgb(86,86,86)
     36230: ( 87, 87, 87) #575757 grey34
     36928: ( 88, 88, 88) #585858 rgb(88,88,88)
     37242: ( 89, 89, 89) #595959 grey35
     37198: ( 90, 90, 90) #5A5A5A rgb(90,90,90)
     37594: ( 91, 91, 91) #5B5B5B rgb(91,91,91)
     37652: ( 92, 92, 92) #5C5C5C grey36
     37787: ( 93, 93, 93) #5D5D5D rgb(93,93,93)
     38063: ( 94, 94, 94) #5E5E5E grey37
     38345: ( 95, 95, 95) #5F5F5F rgb(95,95,95)
     38762: ( 96, 96, 96) #606060 rgb(96,96,96)
     38887: ( 97, 97, 97) #616161 grey38
     39491: ( 98, 98, 98) #626262 rgb(98,98,98)
     39683: ( 99, 99, 99) #636363 grey39
     39928: (100,100,100) #646464 rgb(100,100,100)
     40266: (101,101,101) #656565 rgb(101,101,101)
     40691: (102,102,102) #666666 grey40
     41083: (103,103,103) #676767 rgb(103,103,103)
     41222: (104,104,104) #686868 rgb(104,104,104)
     41523: (105,105,105) #696969 DimGray
     41881: (106,106,106) #6A6A6A rgb(106,106,106)
     42243: (107,107,107) #6B6B6B grey42
     42033: (108,108,108) #6C6C6C rgb(108,108,108)
     42751: (109,109,109) #6D6D6D rgb(109,109,109)
     43131: (110,110,110) #6E6E6E grey43
     42823: (111,111,111) #6F6F6F rgb(111,111,111)
     43386: (112,112,112) #707070 grey44
     43534: (113,113,113) #717171 rgb(113,113,113)
     43906: (114,114,114) #727272 rgb(114,114,114)
     44332: (115,115,115) #737373 grey45
     44505: (116,116,116) #747474 rgb(116,116,116)
     44564: (117,117,117) #757575 grey46
     44601: (118,118,118) #767676 rgb(118,118,118)
     45047: (119,119,119) #777777 rgb(119,119,119)
     45400: (120,120,120) #787878 grey47
     45576: (121,121,121) #797979 rgb(121,121,121)
     46001: (122,122,122) #7A7A7A grey48
     45725: (123,123,123) #7B7B7B rgb(123,123,123)
     46007: (124,124,124) #7C7C7C rgb(124,124,124)
     46364: (125,125,125) #7D7D7D grey49
     46934: (126,126,126) #7E7E7E gray
     46908: (127,127,127) #7F7F7F grey50
     46780: (128,128,128) #808080 fractal
     47320: (129,129,129) #818181 rgb(129,129,129)
     47510: (130,130,130) #828282 grey51
     47704: (131,131,131) #838383 rgb(131,131,131)
     48125: (132,132,132) #848484 rgb(132,132,132)
     48433: (133,133,133) #858585 grey52
     48948: (134,134,134) #868686 rgb(134,134,134)
     48624: (135,135,135) #878787 grey53
     49059: (136,136,136) #888888 rgb(136,136,136)
     49493: (137,137,137) #898989 rgb(137,137,137)
     49420: (138,138,138) #8A8A8A grey54
     50075: (139,139,139) #8B8B8B rgb(139,139,139)
     50225: (140,140,140) #8C8C8C grey55
     50238: (141,141,141) #8D8D8D rgb(141,141,141)
     50365: (142,142,142) #8E8E8E rgb(142,142,142)
     50980: (143,143,143) #8F8F8F grey56
     51347: (144,144,144) #909090 rgb(144,144,144)
     51462: (145,145,145) #919191 grey57
     51976: (146,146,146) #929292 rgb(146,146,146)
     52045: (147,147,147) #939393 rgb(147,147,147)
     52557: (148,148,148) #949494 grey58
     53302: (149,149,149) #959595 rgb(149,149,149)
     53764: (150,150,150) #969696 grey59
     54098: (151,151,151) #979797 rgb(151,151,151)
     54034: (152,152,152) #989898 rgb(152,152,152)
     54531: (153,153,153) #999999 grey60
     54930: (154,154,154) #9A9A9A rgb(154,154,154)
     55319: (155,155,155) #9B9B9B rgb(155,155,155)
     55869: (156,156,156) #9C9C9C grey61
     56525: (157,157,157) #9D9D9D rgb(157,157,157)
     56272: (158,158,158) #9E9E9E grey62
     57037: (159,159,159) #9F9F9F rgb(159,159,159)
     57578: (160,160,160) #A0A0A0 rgb(160,160,160)
     58087: (161,161,161) #A1A1A1 grey63
     58437: (162,162,162) #A2A2A2 rgb(162,162,162)
     59095: (163,163,163) #A3A3A3 grey64
     59317: (164,164,164) #A4A4A4 rgb(164,164,164)
     59802: (165,165,165) #A5A5A5 rgb(165,165,165)
     60739: (166,166,166) #A6A6A6 grey65
     61054: (167,167,167) #A7A7A7 rgb(167,167,167)
     61656: (168,168,168) #A8A8A8 grey66
     62004: (169,169,169) #A9A9A9 DarkGray
     62641: (170,170,170) #AAAAAA rgb(170,170,170)
     63208: (171,171,171) #ABABAB grey67
     64071: (172,172,172) #ACACAC rgb(172,172,172)
     64885: (173,173,173) #ADADAD grey68
     65360: (174,174,174) #AEAEAE rgb(174,174,174)
     66532: (175,175,175) #AFAFAF rgb(175,175,175)
     66916: (176,176,176) #B0B0B0 grey69
     68110: (177,177,177) #B1B1B1 rgb(177,177,177)
     69067: (178,178,178) #B2B2B2 rgb(178,178,178)
     70780: (179,179,179) #B3B3B3 grey70
     71694: (180,180,180) #B4B4B4 rgb(180,180,180)
     72671: (181,181,181) #B5B5B5 grey71
     73740: (182,182,182) #B6B6B6 rgb(182,182,182)
     75562: (183,183,183) #B7B7B7 rgb(183,183,183)
     77107: (184,184,184) #B8B8B8 grey72
     78298: (185,185,185) #B9B9B9 rgb(185,185,185)
     79884: (186,186,186) #BABABA grey73
     81720: (187,187,187) #BBBBBB rgb(187,187,187)
     83772: (188,188,188) #BCBCBC rgb(188,188,188)
     85665: (189,189,189) #BDBDBD grey74
     87387: (190,190,190) #BEBEBE grey
     89966: (191,191,191) #BFBFBF grey75
     91850: (192,192,192) #C0C0C0 silver
     95262: (193,193,193) #C1C1C1 rgb(193,193,193)
     97812: (194,194,194) #C2C2C2 grey76
    100558: (195,195,195) #C3C3C3 rgb(195,195,195)
    103699: (196,196,196) #C4C4C4 grey77
    106423: (197,197,197) #C5C5C5 rgb(197,197,197)
    109925: (198,198,198) #C6C6C6 rgb(198,198,198)
    112930: (199,199,199) #C7C7C7 grey78
    115894: (200,200,200) #C8C8C8 rgb(200,200,200)
    119126: (201,201,201) #C9C9C9 grey79
    122307: (202,202,202) #CACACA rgb(202,202,202)
    125343: (203,203,203) #CBCBCB rgb(203,203,203)
    130205: (204,204,204) #CCCCCC grey80
    134010: (205,205,205) #CDCDCD rgb(205,205,205)
    139285: (206,206,206) #CECECE rgb(206,206,206)
    143658: (207,207,207) #CFCFCF grey81
    149811: (208,208,208) #D0D0D0 rgb(208,208,208)
    154151: (209,209,209) #D1D1D1 grey82
    161645: (210,210,210) #D2D2D2 rgb(210,210,210)
    166443: (211,211,211) #D3D3D3 LightGray
    173230: (212,212,212) #D4D4D4 grey83
    179617: (213,213,213) #D5D5D5 rgb(213,213,213)
    186261: (214,214,214) #D6D6D6 grey84
    192668: (215,215,215) #D7D7D7 rgb(215,215,215)
    199446: (216,216,216) #D8D8D8 rgb(216,216,216)
    205761: (217,217,217) #D9D9D9 grey85
    212809: (218,218,218) #DADADA rgb(218,218,218)
    220719: (219,219,219) #DBDBDB grey86
    226920: (220,220,220) #DCDCDC gainsboro
    235531: (221,221,221) #DDDDDD rgb(221,221,221)
    246091: (222,222,222) #DEDEDE grey87
    257369: (223,223,223) #DFDFDF rgb(223,223,223)
    271655: (224,224,224) #E0E0E0 grey88
    286668: (225,225,225) #E1E1E1 rgb(225,225,225)
    307113: (226,226,226) #E2E2E2 rgb(226,226,226)
    327605: (227,227,227) #E3E3E3 grey89
    349965: (228,228,228) #E4E4E4 rgb(228,228,228)
    371921: (229,229,229) #E5E5E5 grey90
    392919: (230,230,230) #E6E6E6 rgb(230,230,230)
    415458: (231,231,231) #E7E7E7 rgb(231,231,231)
    444372: (232,232,232) #E8E8E8 grey91
    476665: (233,233,233) #E9E9E9 rgb(233,233,233)
    510052: (234,234,234) #EAEAEA rgb(234,234,234)
    554707: (235,235,235) #EBEBEB grey92
    604429: (236,236,236) #ECECEC rgb(236,236,236)
    666765: (237,237,237) #EDEDED grey93
    743972: (238,238,238) #EEEEEE rgb(238,238,238)
    837844: (239,239,239) #EFEFEF rgb(239,239,239)
    953358: (240,240,240) #F0F0F0 grey94
   1072528: (241,241,241) #F1F1F1 rgb(241,241,241)
   1181158: (242,242,242) #F2F2F2 grey95
   1260925: (243,243,243) #F3F3F3 rgb(243,243,243)
   1315991: (244,244,244) #F4F4F4 rgb(244,244,244)
   1339670: (245,245,245) #F5F5F5 grey96
   1333402: (246,246,246) #F6F6F6 rgb(246,246,246)
   1293746: (247,247,247) #F7F7F7 grey97
   1198048: (248,248,248) #F8F8F8 rgb(248,248,248)
   1049745: (249,249,249) #F9F9F9 rgb(249,249,249)
    867840: (250,250,250) #FAFAFA grey98
    669300: (251,251,251) #FBFBFB rgb(251,251,251)
    460289: (252,252,252) #FCFCFC grey99
    339229: (253,253,253) #FDFDFD rgb(253,253,253)
    884878: (254,254,254) #FEFEFE rgb(254,254,254)
    157771: (255,255,255) #FFFFFF white
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Compose: Over
  Page geometry: 5284x7222+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG2000
  Orientation: Undefined
  Properties:
    date:create: 2010-06-30T16:27:18+01:00
    date:modify: 2010-06-30T16:27:29+01:00
    signature: d3f545934e21e9325b31ef32a060bd0feaf3ee2e7913c36aba982b59287d6450
  Profiles:
    Profile-icc: 394 bytes
      Description: Restricted ICC profile describing sRGB-grey
      Manufacturer: Restricted ICC profile describing sRGB-grey
      Model: Restricted ICC profile describing sRGB-grey
      Copyright: Copyright 2003 sRGB-grey Reference
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 4.771MB
  Number pixels: 38.16M
  Pixels per second: 5.075M
  User time: 7.519u
  Elapsed time: 0:08.520
  Version: ImageMagick 6.6.2-4 2010-06-07 Q16 http://www.imagemagick.org
snibgo's IM pages: im.snibgo.com
footnoter

Re: Cannot decode JP2000 Images

Post by footnoter »

Thanks for all of your help. I installed the 16 bit version but still can't do anything with these images. I'm going to setup a linux envronment to see if I get a better result. I don't know what else I can try.
footnoter

Re: Cannot decode JP2000 Images

Post by footnoter »

Well, I setup a Linux environment and I am able to decode the sample image on that server. So there is something about my Windows environment that is to blame. Prehaps it is the Vista security model or there is a configuration step that I need to do. What is strange is that I can decode other jp2 images. I'll post more if I ever figure this out.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Cannot decode JP2000 Images

Post by snibgo »

Ideally, you might try installing ImageMagic on Windows 7, and a fresh Vista installation. Vista uses more resources than Win7, apparently.

You might also try more memory in your computer.

I can't think of any other tests to try. Sorry.
snibgo's IM pages: im.snibgo.com
johan
Posts: 7
Joined: 2010-10-12T09:08:23-07:00
Authentication code: 8675308

Re: Cannot decode JP2000 Images

Post by johan »

Hi, actually I'm pretty sure *is* a memory issue after all, as I've seen many examples of this behaviour before.

If I use IM's 'identify' command when I'm logged in on Windows as a normal user, I'm getting a 'cannot decode code stream' error as well. When I do exactly the same thing from my administrator account it works fine. I've seen numerous other examples of this behaviour with completely different JP2 files, and I guess that it has something to do with having more memory available as an admin (but I'm not 100% sure). Even as an admin, you may easily run into problems with larger files (ditto with other OSs such as Ubuntu).

Earlier you commented that IM handles much larger TIFF files fine, and that this would rule out a memory problem. However, it's not IM itself that's causing the problem, but the underlying JasPer library that IM uses for de- and encoding JPEG2000 data. JasPer appears to have some pretty serious memory management issues. Other applications that are using it (e.g. XnView) all have similar problems. This basically means that -unless you're dealing with very small images- ImageMagick may simply not be a viable option for dealing with JPEG2000 at the moment.

Unfortunately when it coms to JPEG2000, the choice of available open-source options is still extremely limited ...

Hope this helps,

Johan
Post Reply