Page 1 of 1

Composite memory issues

Posted: 2007-02-21T23:30:01-07:00
by Utah Craghopper
I have an issue with 'composite' taking a ridiculous amount of time. The images are not overly huge. They have widths and heights in the range of 7,000-10,000 pixels. From searching the archives of this site I see that ImageMagick has been used for images much larger than this, so I expect the software to work fine for my application. All other operations on images of the same size work well; these are operations like annotate, compositing much smaller images, lines, etc. It is only a composite of one large image on top of another that takes up to six hours to run.

I am hoping someon can give me a tuning suggestion.

I am using the Q16 version. Doing some calculations, using 4 channels per pixel at 16 bits per channel, both images should take around one gig of memory which is less than my physical RAM. It really does not seem to me that this should be all that complicated. It just amounts to reading both images into memory and transferring pixels from one image to another. It should take almost no time to run other than the reading and writing of images.

Running 'identify -list resource' gives the following:

File Area Memory Map Disk
------------------------------------------------
768 1.95gb 1.95gb 1.95gb 4.000eb

I read the architecture page, but it does not really give suggestions for how the different settings should be set relative to one another. Should 'memory' be set to physical RAM minus an amount for the OS, or should physical RAM + swap be used? What should 'area' be set to relative to 'memory'?

When I run 'top' I can see the 'composite' initially starts out using a lot of CPU but then drops down to a few percent and seems to not do much. The process' memory is sometimes up to 2G. Memory goes up to around 1G. Both images should fit inside of of the 1G. I just fail to see how a simple composite can take so long when the everything should fit in RAM.

Any help or suggestions would be much appreciated.

Re: Composite memory issues

Posted: 2007-02-22T09:29:59-07:00
by magick
Add -debug cache to your command line and most likely you'll see your image is being cached to disk which is 1000 times slower than memory. Try adding -limit area 8192 -limit memory 8192 to your command line to ensure your image is processed in memory. Its still possible your system may reject large memory requests and force the pixel cache to disk. In that case add more memory or use some other program.

Re: Composite memory issues

Posted: 2007-02-22T19:48:30-07:00
by anthony
These notes (and others) have been added to IM Examples, Really Massive Image Handling...
http://www.imagemagick.org/Usage/files/#massive

Re: Composite memory issues

Posted: 2007-02-22T23:32:44-07:00
by Utah Craghopper
Thanks to both of you.

I compiled a Q8 version of ImageMagick to use just for the one step that was taking so much time. That now takes about thirty seconds instead of six hours, which is not too far off a 1000 times slowdown.

Using 'stream' to dice images into smaller parts, as mentioned in the link that anthony gave, also may have worked and maintained 16 bits through the whole transformation process.