Page 1 of 1

Convert JP2 to JPG Issue

Posted: 2012-10-18T13:17:55-07:00
by LLW
I'm having trouble converting a large JP2 image (~ 1000MB) to a JPG. I've been looking into why this is a problem and it may be overloading my cache. However, I'm uncertain about a work around. I'm using the convert utility and I've tried the resize flag and scale flag separately without any results. My libraries show jp2 jpg are indeed installed. My errors are always the following...
"error:cannot decode code stream
convert.exe: unable to decode image file 'BALTIMORE201210180200_11.JP2' @error/jp2.c/ReadJP2Image/403."

The image(s) I want converted are here: http://www.hazecam.net/image_archive/Oc ... BALTIMORE/

I can easilly convert these because they're smaller: http://www.hazecam.net/image_archive/Oc ... FROSTBURG/

I'm running ImageMagick 6.8.0 (Q8, as recommended by another forum post for large files) on a Windows XP SP3 32bit machine 2.53 GHz, 1.98 GB RAM.

Any help on this would be appreciated!

Re: Convert JP2 to JPG Issue

Posted: 2012-10-18T13:43:37-07:00
by Bonzo
What happens if you use -define

Code: Select all

convert jpeg:size=500x500 input.jpg -resize 500x500 output.jpg

Re: Convert JP2 to JPG Issue

Posted: 2012-10-18T14:20:33-07:00
by fmw42
Bonzo wrote:What happens if you use -define

Code: Select all

convert jpeg:size=500x500 input.jpg -resize 500x500 output.jpg

I am not sure that -define works for jp2 input images. But if it did, I believe user Bonzo accidentally left out the -define

convert -define jpeg:size=500x500 input.jp2 -resize 500x500 output.jpg

see
http://www.imagemagick.org/Usage/formats/#jpg_read

If your convert works for small jp2 images, then perhaps it is the size of the image and your memory allocation. Perhaps see
http://www.imagemagick.org/Usage/files/#massive. If it does not work for small images then you probably have not installed the Jasper delegate library to support the reading of JP2 files.

It should be listed in the line starting with DELEGATES when you do

convert -list configure

If it is there, then it is either a corrupted file or too large an image to handle without using -limit.

Re: Convert JP2 to JPG Issue

Posted: 2012-10-18T14:21:17-07:00
by Bonzo
Woops - well spoted fmw42.

Re: Convert JP2 to JPG Issue

Posted: 2012-10-18T14:31:08-07:00
by fmw42
I tested one of your images and it works fine on my Mac OSX Snow Leopard with IM 6.8.0.1 Q16

convert BALTIMORE201210010200_21.JP2 BALTIMORE201210010200_21.jpg

The file size was 896KB before converting and 615KB after converting.


convert -list configure
...
DELEGATES bzlib fftw fontconfig freetype gs jpeg jng jp2 lcms2 lqr openexr png tiff x11 xml zlib


see also
http://www.imagemagick.org/script/jp2.php

Re: Convert JP2 to JPG Issue

Posted: 2012-10-19T05:36:45-07:00
by LLW
Thanks for your quick responses. I tried Bonzo's -define suggestion and unfortunately received the same error message.

Also, I checked delegates and I have: bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
Looks like I have a few less than you, fmw42 (I'm missing fftw, fontconfig, js and jng). Do they relate to jp2's at all?

"identify -list resources" shows the following...
FILE AREA MEMORY MAP DISK THREAD TIME
1536 17.077GB 7.9523GiB 15.905GiB unlimited 2 unlimited

What kind of -limit options would you recommend? I've tried -limit area 500mb (no success) then -limit area 0mb to force the image to use disk instead of cache, but I receive the same error again. The file doesn't apear to be corrupt because I can open it in QuickTime.

Re: Convert JP2 to JPG Issue

Posted: 2012-10-19T10:19:54-07:00
by fmw42
Also, I checked delegates and I have: bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
Looks like I have a few less than you, fmw42 (I'm missing fftw, fontconfig, js and jng). Do they relate to jp2's at all?
Nothing there that I expect would affect jp2 and jpg.

Perhaps it is the version of the Jasper delegate library or the jpeg delegate library.

If I can convert it on my system without -limit, then you should not have any trouble either.


I do not know if this might be an issue, but some people have jpg (62) and (80) on the same system and that can cause problems. Make sure you only have one. My system is using (80).

Re: Convert JP2 to JPG Issue

Posted: 2012-10-19T11:31:41-07:00
by LLW
fmw42 wrote: Perhaps it is the version of the Jasper delegate library or the jpeg delegate library.

If I can convert it on my system without -limit, then you should not have any trouble either.

I do not know if this might be an issue, but some people have jpg (62) and (80) on the same system and that can cause problems. Make sure you only have one. My system is using (80).
Is there a command I can use to check my jpg versions? I haven't played with jpeg or any other ImageMagick libraries before. I simply installed ImageMagick as a Windows binary that's offered on the main website. Because I can successfully convert the smaller *.jp2 in the FROSTBURG directory which are ~ 200 KB, wouldn't that point to my jpeg and jpeg2000 libraries are working ok? I tried it on another Windows XP computer and received the same error. Maybe there's a bug in the IM Windows installation files since the Mac version works fine for fmw42? Especially because the limit options don't resolve my problem.

Re: Convert JP2 to JPG Issue

Posted: 2012-10-19T12:11:44-07:00
by fmw42
Perhaps some other kind Windows user would test one of your larger images. If it fails, then I suggest you report on the Bugs forum.

Re: Convert JP2 to JPG Issue

Posted: 2012-10-20T08:25:53-07:00
by indiego
Fails here too (Win7-64bit, 8GB RAM)

Version: ImageMagick 6.8.0-1 2012-10-15 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

f:\Downloads>convert BALTIMORE201210010200_21.JP2 baltimore.jpg
error: cannot decode code stream
convert.exe: unable to decode image file `BALTIMORE201210010200_21.JP2' @ error/jp2.c/ReadJP2Image/403.
convert.exe: no images defined `baltimore.jpg' @ error/convert.c/ConvertImageCommand/3044.

Re: Convert JP2 to JPG Issue

Posted: 2012-10-20T13:25:06-07:00
by magick
The exception is thrown by the Jasper delegate library. It is isolated to Windows only. Try posting a bug report to the Jasper development team.

Re: Convert JP2 to JPG Issue

Posted: 2012-10-20T19:51:48-07:00
by snibgo
If it's helpful: a large file fails for me on my (fairly current) Q16, but succeeds on a (fairly old) Q8.

D:\web\im>"%IMG%convert" BALTIMORE201210010200_21.JP2 x.jpg
error: cannot decode code stream
convert.exe: unable to decode image file `BALTIMORE201210010200_21.JP2' @ error/jp2.c/ReadJP2Image/403.
convert.exe: no images defined `x.jpg' @ error/convert.c/ConvertImageCommand/3044.

D:\web\im>"%IMG%convert" FROSTBURG201210010400_11.JP2 x.jpg

D:\web\im>"%IMG%convert" -version
Version: ImageMagick 6.7.9-6 2012-09-13 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP


D:\web\im>"%IMG8%convert" BALTIMORE201210010200_21.JP2 x.jpg

D:\web\im>"%IMG8%convert" -version
Version: ImageMagick 6.6.1-1 2010-04-04 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

Re: Convert JP2 to JPG Issue

Posted: 2012-10-22T06:06:46-07:00
by LLW
magick, fmw42 -Thanks, I posted on the Bug forum as suggested.

snibgo - I tried the 6.6.1-5 Q8 Windows version and that looks to have the same bug. I didn't try any others, but depending on how long a bug fix will be implemented then I'll dry the 6.7.9-6 as you suggested. Thank you!