Convert JP2 to JPG Issue

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
LLW
Posts: 6
Joined: 2012-10-18T12:35:03-07:00
Authentication code: 67789

Convert JP2 to JPG Issue

Post 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!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Convert JP2 to JPG Issue

Post by Bonzo »

What happens if you use -define

Code: Select all

convert jpeg:size=500x500 input.jpg -resize 500x500 output.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert JP2 to JPG Issue

Post 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.
Last edited by fmw42 on 2012-10-18T14:28:14-07:00, edited 2 times in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Convert JP2 to JPG Issue

Post by Bonzo »

Woops - well spoted fmw42.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert JP2 to JPG Issue

Post 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
LLW
Posts: 6
Joined: 2012-10-18T12:35:03-07:00
Authentication code: 67789

Re: Convert JP2 to JPG Issue

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert JP2 to JPG Issue

Post 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).
LLW
Posts: 6
Joined: 2012-10-18T12:35:03-07:00
Authentication code: 67789

Re: Convert JP2 to JPG Issue

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert JP2 to JPG Issue

Post 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.
indiego
Posts: 75
Joined: 2010-10-16T06:35:10-07:00
Authentication code: 8675308

Re: Convert JP2 to JPG Issue

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Convert JP2 to JPG Issue

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert JP2 to JPG Issue

Post 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
snibgo's IM pages: im.snibgo.com
LLW
Posts: 6
Joined: 2012-10-18T12:35:03-07:00
Authentication code: 67789

Re: Convert JP2 to JPG Issue

Post 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!
Post Reply