Page 1 of 1

1GB 4-channel tif to jpg2000

Posted: 2010-06-21T07:00:51-07:00
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).

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-21T07:53:20-07:00
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.

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-21T08:22:44-07:00
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.

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-21T10:53:41-07:00
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).

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-21T11:14:30-07:00
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?

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-21T11:51:11-07:00
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.

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-21T12:22:11-07:00
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.

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-22T10:50:53-07:00
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.

Re: 1GB 4-channel tif to jpg2000

Posted: 2010-06-22T14:42:33-07:00
by snibgo
Yup, I didn't try tilewidth and height, so they were bound to help. Sigh.

Glad you solved it, Roman.