Not optimal processing MPC

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
yarkm
Posts: 1
Joined: 2017-09-09T21:24:40-07:00
Authentication code: 1151

Not optimal processing MPC

Post by yarkm »

I have 95 MPC files each representing one line of big image. I need to compose single image. My files is 59,2MiB each.

Code: Select all

montage -limit memory 1000MiB -frame 0 -geometry +0+0 -tile 1x *.mpc ./all_map.png
During this command run
— there are created temp files size of 59,2MiB i believe it's just copy of all my source files
— created one more temp file with total size 59,2MiB * 95 ≈ 5,6GiB
— temp files deleted one by one
— target all_map.png created

Documentation say that MPC is raw memory cache format so why not write MPC files directly into target big (5,6 Gib in my case) temp file? Wy it need to copy all files before processing?

I believe it's possible to avoid that step and speed up processing.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Not optimal processing MPC

Post by magick »

There is a more optimal way to handle montages-- apply one image at a time and dispose of it before the next is applied. We choose instead to collect all images first because that is what ImageMagick other utilities were designed to do. We suspect handling one image at a time would benefit your use case. However, its unlikely that this optimization will ever be effected because it would likely take months to complete and there are still thousands of pending "things to do" to improve ImageMagick.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Not optimal processing MPC

Post by snibgo »

The "one at a time" method can be implemented in a script like this:

Code: Select all

convert
  line0.mpc
  line1.mpc -append
  line2.mpc -append
  line3.mpc -append
  line4.mpc -append
:
:
  out.png
And that script (or a magick "-script") can be created by another script.
snibgo's IM pages: im.snibgo.com
Post Reply