-limit not honoured during +adjoin of MNG

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
Barthax

-limit not honoured during +adjoin of MNG

Post by Barthax »

Hi all,

I'm using the default Image Magick with Ubuntu 10.04 LTS: 6.5.7-8. I'm trying to split apart an MNG of some play from an old version of MAME (irrelvant fact, IMO, but included in case). The command-line I'm using is as follows (there's a script wrapper which creates the dir & copies the MNG to the location).

convert -define mng:need-cacheoff -limit area 12mb -limit memory 6mb -limit map 6mb +adjoin /tmp/mng2avitemp/test.mng /tmp/mng2avitemp/test%06d.png

With the above, small MNGs (~20MB) will get extracted OK on my 1.5GB RAM machine. I have, however, some larger MNGs (>200MB) and convert does not honour the limits place on it (as I understand it). The RAM used will gradually grow and I've let it run to more than 750MB real RAM used and more than 1GB VRAM used (I killed it by this point). Is there something wrong with my command line or is this normal behaviour of the pixel cache? Alternatively, is there anything I can add to the command-line such that the pixel cache is flushed after each frame?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -limit not honoured during +adjoin of MNG

Post by magick »

Add -debug cache -limit area 0 to your command line to track where ImageMagick is caching your images. This should cache all images to disk and prove it by displaying the cache type (hopefully disk). If that fails, post a URL to one of your ginormous MNG files so we can download and reproduce the problem.
Barthax

Re: -limit not honoured during +adjoin of MNG

Post by Barthax »

Hi magick,

Thanks for the instruction. The stderr output does indeed show disk as the output however the RAM usage continues to grow. I guess (hopefully you can confirm/deny) that this is due to having to note the disk usage somewhere (i.e., in RAM)... I've made available the relevant files. The screenshot shows top running (top-left), an occasional ls -l of the files concerned (top-right) and the output from a brief test & then the running command (bottom).

I hope you can give me the insight to just simply extract each frame as a PNG without this massive overhead.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -limit not honoured during +adjoin of MNG

Post by magick »

Only pixels are cached to disk. The image object itself and associated meta-data are stored in memory.
Barthax

Re: -limit not honoured during +adjoin of MNG

Post by Barthax »

magick wrote:Only pixels are cached to disk. The image object itself and associated meta-data are stored in memory.
By that succinct answer is the answer to my quandry of "simply extract each frame as a PNG without this massive overhead" is "not possible"?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -limit not honoured during +adjoin of MNG

Post by magick »

You can use the Q8 version of ImageMagick to reduce the memory requirements by half. You can extract a few frames at a time to reduce resource demand:
  • convert 'image.mng[0-9]' image-%06d.png
Finally, you can use another utility that only processes one frame at a time.
Barthax

Re: -limit not honoured during +adjoin of MNG

Post by Barthax »

magick wrote:
  • convert 'image.mng[0-9]' image-%06d.png
I actually tried this & the overheads do not seem to change up to the required frame. For example, if I extract frames 1100-1200, the overhead appears to be exactly the same as if I requested frame 1200 on its own or 0-1200. It wasn't a particularly scientific analysis but extrapolating that to the last frame means I may as well just do the lot in one go.

Thanks for your honest answers. I believe we've reached the conclusion that Image Magick's ideology on processing does not match the combination of my attempts+machine limits combined. It's a shame, as your's is the only free tool to have succeeded on every short MNG I have.

Thanks again.
Post Reply