Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#8 Error converting .bmp to .jp2

closed
None
5
2012-01-18
2011-06-30
bittam
No

Simply running the command line tool: > gm.exe convert img1.bmp img2.jp2
results in the following error:
"This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."

It should be noted that the file size of img1.bmp is 173 mb and this conversion works on files at least as large as 43 mb.
Any help towards resolving this issue would be greatly appreciated!

~Matt

Discussion

    • assigned_to: nobody --> bfriesen
     
  • What is the output of 'gm identify img1.bmp'? The issue may be that the image has dimensions (rows x columns) which is too big for the Jasper library to handle. Jasper is not memory efficient and it also seems to have some bugs with computations which overflow. Eventually GM may switch to OpenJPEG (another JPEG 2000 library) which has recently added the ability to deal with larger images.

     
  • bittam
    bittam
    2011-07-01

    Here's the output from running identify:
    C:\Users\Matt\Desktop\img1.bmp BMP 8984x6732+0+0 DirectClass 8-bit 173.0M 0.000u 0:01

    Thanks!

     
  • The image dimensions seem to be too large to deal with under Windows. The Jasper library is crashing while saving the image. While it works under Solaris, it fails under Windows. I was able to reproduce the problem with this command:

    $ gm convert -monitor -size 8984x6732 xc:red crap.jp2
    100% [red] Set color...
    100% [red] Analyze for bilevel...
    100% [red] Analyze for gray...
    100% [crap.jp2] Saving image: 8984x6732...

    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.

    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.

     
  • The failure occurs under FreeBSD as well. The process size is quite close to the 2GB limit so perhaps a memory allocation fails. This is the call stack that gdb shows:

    Program received signal SIGABRT, Aborted.
    [Switching to Thread 28c01140 (LWP 100154)]
    0x28a012fb in thr_kill () from /lib/libc.so.7
    (gdb) bt
    #0 0x28a012fb in thr_kill () from /lib/libc.so.7
    #1 0x289b0836 in pthread_kill () from /lib/libthr.so.3
    #2 0x289ae353 in raise () from /lib/libthr.so.3
    #3 0x28aa291a in abort () from /lib/libc.so.7
    #4 0x28a88dd6 in __assert () from /lib/libc.so.7
    #5 0x28481ae7 in jpc_enc_enccblk () from /usr/local/lib/libjasper.so.4
    #6 0x28481d40 in jpc_enc_enccblks () from /usr/local/lib/libjasper.so.4
    #7 0x284708d7 in jpc_enc_encodemainbody () from /usr/local/lib/libjasper.so.4
    #8 0x28471910 in jpc_encode () from /usr/local/lib/libjasper.so.4
    #9 0x2846508f in jp2_encode () from /usr/local/lib/libjasper.so.4
    #10 0x28457153 in jas_image_encode () from /usr/local/lib/libjasper.so.4
    #11 0x08210b7e in WriteJP2Image (image_info=0x28c4b000, image=0x28c1b000)
    at /home/bfriesen/src/graphics/GraphicsMagick-head/coders/jp2.c:1151
    #12 0x080866d1 in WriteImage (image_info=0x28c18000, image=0x28c1b000)
    at /home/bfriesen/src/graphics/GraphicsMagick-head/magick/constitute.c:9049
    #13 0x08086e15 in WriteImages (image_info=0x28c0e000, image=0x28c1b000, filename=0x28c13050 "crap.jp2",
    exception=0xbfbfe888) at /home/bfriesen/src/graphics/GraphicsMagick-head/magick/constitute.c:9195
    #14 0x08074640 in ConvertImageCommand (image_info=0x28c0e000, argc=6, argv=0x28c11000, metadata=0x0, exception=0xbfbfe888)
    at /home/bfriesen/src/graphics/GraphicsMagick-head/magick/command.c:5595
    #15 0x08052493 in MagickCommand (image_info=0x28c0e000, argc=6, argv=0xbfbfe91c, metadata=0x0, exception=0xbfbfe888)
    at /home/bfriesen/src/graphics/GraphicsMagick-head/magick/command.c:8171
    #16 0x080525cb in GMCommand (argc=6, argv=0xbfbfe91c)
    at /home/bfriesen/src/graphics/GraphicsMagick-head/magick/command.c:16046
    #17 0x08051666 in main (argc=Error accessing memory address 0x3: Bad address.
    ) at /home/bfriesen/src/graphics/GraphicsMagick-head/utilities/gm.c:61
    (gdb)

     
  • From what I have seen, the Jasper library will prevent this issue from being fixed, even with a 64-bit build. Large file problems seem to be intrinsic to Jasper. Perhaps if we switch to the OpenJPEG library (a different JPEG2000 library) things will become better.

    I am closing this since the issue is not specifically in GraphicsMagick itself.

     
    • status: open --> closed