Saving many images to files gets slow

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
ohach

Saving many images to files gets slow

Post by ohach »

Hey guys,

I am pretty new to IM ... I use Core functions to save buffered images to files, depending on the number of images the saving gets really slow (means < 1 MB/s). I tried two different approches:

a) creating Images and saving them via WriteFile() - gets slow at ~750 images

b) creating an Image list and saving it via WriteFiles() - the list creation almost stops at ~1200 images

All images are ~640x480 pixels, 8 bit grayscale, I guess its a memory issue, although I shouldn't touch the bounds currently. Is there a better way to save many images? Can I somehow influence the amount of allocated memory of the image list?

Any help is appreciated.
Regards, Oliver
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Saving many images to files gets slow

Post by anthony »

Do you need to have so many images in memory at the same time.

Prehaps reading processing writing then deleting them from memory would work better.


If you use too much memory the comuter will run out and start using disk space for memory management, when is VERY VERY slow by comparision. This is known as thrashing!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ohach

Re: Saving many images to files gets slow

Post by ohach »

Hi Anthony, thanks for the reply.
anthony wrote:Do you need to have so many images in memory at the same time.
Yes, since they are grabbed from a camera at 200 fps.
anthony wrote:Prehaps reading processing writing then deleting them from memory would work better.
I already tried that, freeing the buffer memory as soon as an image is written to a file. Doesn't make a difference, there is still physical memory available in any case.
anthony wrote:If you use too much memory the comuter will run out and start using disk space for memory management, when is VERY VERY slow by comparision. This is known as thrashing!
I now write the images directly using Windows file operations and the GDI+ definitions. It works quite well, even with >5000 images. I still would be interested if there would be a way to do it with Magick Core functions.

Oliver
Post Reply