problem with convert -resize : doesn't work beyond 3 images

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
xzibit

problem with convert -resize : doesn't work beyond 3 images

Post by xzibit »

Hi everyBody !

I'm web developper and I'm working on a project for my company using imagemagick (version 6.3.5).
We need to make several resize at the same time, with high image dimension.
So I made some test with an image of 5500*12000 pixels, and I resized it in 600x600 using this command :
convert img.jpg -resize 600x600 imgResized.jpg

I get the following result :
- 1 image : take 9 seconds
- 2 images at the same time : 11s
- 3 images : 17s
- 4 images : doesn't work (no error message, I can wait several minutes nothing happened)

When I tried with 4 images at the same time, I can see with the top command that the CPU and the memory used increase but maybe during 5seconds, after it makes like the tasks was finished, memory and CPU become normally.

So I tried using limit option like this :
convert img.jpg -limit memory 64000000 -limit map -128000000 -resize 600x600 imgResized.jpg
but I got a similar result. It just take more time with 1,2 or 3 images and with 4 images it doesn't work.

Could anyone tell me how to resolve this problem ?
Why it doesn't work beyond 3 images ?

Concerning the server config, we have 2Gb for memory, processor intel core 2 duo E4500 @2.20Ghz.


Thanks for your help
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: problem with convert -resize : doesn't work beyond 3 images

Post by magick »

There is no limit in the number of images you can process with ImageMagick other than resource limits (.e.g. you run out of temporary disk). Add -debug cache to your command line to identify where the slow down is originating from.
xzibit

Re: problem with convert -resize : doesn't work beyond 3 images

Post by xzibit »

I added -debug trace and I post here the end of the message I got for each console :

console 1 :

Code: Select all

 4.300u 6.3.5 Cache convert[2911]: cache.c/unknown/3969/Cache
  groove.jpg[0][108x11762+896+0]
g 4.590u 6.3.5 Cache convert[2911]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+64+0]
g[0][1x11762+64+0] 6.420u 6.3.5 Cache convert[2911]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+128+0]
QG6.930u 6.3.5 Cache convert[2911]: cache.c/unknown/3969/Cache
  groove.jpg[0][109x11762+2560+0]
console 2 :

Code: Select all

4.450u 6.3.5 Cache convert[2912]: cache.c/unknown/3969/Cache
  groove.jpg[0][108x11762+896+0]
g 4.760u 6.3.5 Cache convert[2912]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+64+0]
g[0][1x11762+64+0] 6.500u 6.3.5 Cache convert[2912]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+128+0]
QG6.960u 6.3.5 Cache convert[2912]: cache.c/unknown/3969/Cache
  groove.jpg[0][109x11762+2560+0]

console 3 :

Code: Select all

 4.950u 6.3.5 Cache convert[2913]: cache.c/unknown/3969/Cache
  groove.jpg[0][108x11762+896+0]
g 5.260u 6.3.5 Cache convert[2913]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+64+0]
g[0][1x11762+64+0] 6.820u 6.3.5 Cache convert[2913]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+128+0]
QG7.200u 6.3.5 Cache convert[2913]: cache.c/unknown/3969/Cache
  groove.jpg[0][109x11762+2560+0]
console 4

Code: Select all

[0][109x11762+2560+0] 10.000u 6.3.5 Cache convert[2914]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+256+0]
 11.050u 6.3.5 Cache convert[2914]: cache.c/unknown/4885/Cache
  groove.jpg[0][1x11762+302+0]
 7:31 11.340u 6.3.5 Cache convert[2914]: cache.c/unknown/2161/Cache
  destroy groove.jpg[0]
å> 7:32 11.420u 6.3.5 Cache convert[2914]: cache.c/unknown/2161/Cache
  destroy groove.jpg[0]
Ðä> 7:33 11.450u 6.3.5 Cache convert[2914]: cache.c/unknown/2161/Cache
  destroy groove.jpg[0]


I can't understand this log, could you tell me if there is a problem ?

Finally, after several minute, the resize made on the console 4 take end, console 3 after, console 2 and 1.

So the function convert work with 4 images, but why does it take so much time ?

If I resume, when I make 1, 2 or 3 resize at the same time it takes between 10 and 20 seconds, and for 4 images it takes more than 5 minutes.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: problem with convert -resize : doesn't work beyond 3 images

Post by magick »

We suspect your system is running out of memory and ImageMagick caches the pixels to temporary disk rather than memory. Processing from disk is much slower than memory. The solution is to add more memory to your system or limit the number of images you process simultaneously.
xzibit

Re: problem with convert -resize : doesn't work beyond 3 images

Post by xzibit »

Ok thank you.

I will add memory and I will post the result
Post Reply