1GB 4-channel tif to jpg2000

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
RomanK

1GB 4-channel tif to jpg2000

Post by RomanK »

I need to convert TIFFs that are 1GB large and have 4 channels to JPG2000. I am using ImageMagick-6.6.2-4-Q16-windows-x64-static on a Windows 7 64-bit machine with 8GB RAM. The conversion runs through without any error message, however the resulting JP2 file is 0kB large and there are 4 scratch files in the root directory each 250MB. I have tried this with the same results on about 30 different and similar files. I can supply a sample file via FTP.

Any sugegstions are much aprpeciated (I have to convert ~200 of these aerial images).
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: 1GB 4-channel tif to jpg2000

Post by magick »

Post a URL to your image and the exact command you are using. We need to reproduce the problem before we can comment.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: 1GB 4-channel tif to jpg2000

Post by snibgo »

Is the problem the file size or JP2? Can you create JP2 files from smaller images? Can you convert these large images to other formats?

1 GB is too large for my broadband, so I won't be able to test this. Someone else might.
snibgo's IM pages: im.snibgo.com
RomanK

Re: 1GB 4-channel tif to jpg2000

Post by RomanK »

The command I use:

convert in-file.tif -define jp2:rate=1 out-file.jp2 (... need lossless)

This works with most(!) smaller files like ~200MB (not all though and I have not figured out why).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: 1GB 4-channel tif to jpg2000

Post by snibgo »

After some correspondence with Roman, here is a reproducible test case. (Creating a small JP2 works fine.)

Create a large input:

convert -size 16053x16053 xc:red bigred.png

convert bigred.png bigred.jpg
(This works.)

convert bigred.png bigred.jp2
convert: unable to create image `bigred.jp2' @ error/jp2.c/WriteJP2Image/878.

I have Windows 7, IM 6.5.2-4, on a 4 GB laptop. With the Windows Resource Monitor, I observe the memory filling up. When it is full, convert fails.

The convert also fails with variations of
-limit memory 1024mb
-limit map 1024mb
-limit area 1024mb

I suspect the conversion to JP2 might work with more memory. Am I missing something to make it work on a "small" computer?
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: 1GB 4-channel tif to jpg2000

Post by magick »

Although ImageMagick can process one image scan line in memory at a time (if you force the pixel cache to disk with -limit area 1mb), the JP2 delegate library appears to want to allocate the entire image in memory. There are a number of JP2 options you can use, one which may reduce memory requirements. If you cannot find an option that works, contact the Jasper development team. Only they can resolve the memory issue.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: 1GB 4-channel tif to jpg2000

Post by snibgo »

Thanks, magick.

I can't find a jp2 option that helps: nomct, rate, lazy etc.

I'll leave it to Roman to find a bigger computer or contact the Jasper team. Let us know how it goes, Roman.
snibgo's IM pages: im.snibgo.com
RomanK

Re: 1GB 4-channel tif to jpg2000

Post by RomanK »

We found a solution. The command

convert source.tif -define jp2:rate=1 -define jp2:tilewidth=256 -define jp2:tileheight=256 destination.jp2

works perfectly, even with my 2GB RAM laptop.Whew! Thank you all for your help and especially your quick response.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: 1GB 4-channel tif to jpg2000

Post by snibgo »

Yup, I didn't try tilewidth and height, so they were bound to help. Sigh.

Glad you solved it, Roman.
snibgo's IM pages: im.snibgo.com
Post Reply