I would like to resize a large number (about 5200) of image files (PPM format, each 5 MB in size) and save them in PNG format using convert .
Short version:
convert explodes 24 GB of memory, although I use a syntax that tells convert process image files sequentially.
Long version:
For more than 25 GB of image data, I suggest that I should not process all the files at once. I was looking for ImageMagick documentation on how to process image files sequentially and I found :
It is faster and less resource intensive to resize each image. in the following way:
$ convert '*.jpg[120x120]' thumbnail%03d.png
In addition, the manual states :
For example, instead of ...
montage '*.tiff' -geometry 100x100+5+5 -frame 4 index.jpg
which first reads all the tiff files and then resizes them. You can instead ...
montage '*.tiff[100x100]' -geometry 100x100+5+5 -frame 4 index.jpg
This will read each image and resize it before proceeding to the next image. As a result, there is significantly less memory usage and, possibly, prevent disk replacement (interception) when the memory limits are reached.
Therefore, this is what I am doing:
$ convert '*.ppm[1280x1280]' pngs/%05d.png
In accordance with the documents, he must process each image file one after another: read, resize, write. I do this on a machine with 12 real cores and 24 GB of RAM. However, in the first two minutes, memory usage in the convert process increases to about 96%. He stays there. CPU utilization is maximized. A little longer, and the process dies, simply saying:
Killed
No output files were created at this point. I'm on Ubuntu 10.04 and convert --version says:
Version: ImageMagick 6.5.7-8 2012-08-17 Q16 http:
It looks like convert trying to read all the data before starting the conversion. Therefore, either there is an error in convert , a problem with the documentation, or I did not read the documentation properly.
What's wrong? How can I achieve low memory usage when resizing this large number of image files?
BTW: A quick solution would be to simply iterate over the files using the shell and invoke convert for each file independently. But I would like to understand how to achieve this using pure ImageMagick.
Thanks!