Extremely slow image resize

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
danc81
Posts: 7
Joined: 2012-01-23T12:18:56-07:00
Authentication code: 8675308

Extremely slow image resize

Post by danc81 »

Hi,

I'm using ImageMagick to convert some large TIFs (14000x14000) to smaller sizes - 8000x8000, 4000x4000 and 2000x2000, in GIMP and Photoshop this takes seconds but ImageMagick takes hours. My command line is:

convert "<path>\<to>\<input>" -resize 2000x2000 "<path>\<to>\<output>"

Running on a quad core Windows 7 64 box with 4GB of RAM. CPU sits at anywhere between 1% and 25% for a couple of hours before producing output.

Any ideas how to speed this up?

Thanks
stefan9
Posts: 15
Joined: 2012-02-22T00:56:56-07:00
Authentication code: 8675308

Re: Extremely slow image resize

Post by stefan9 »

try the "sample" operator.
The "-sample" resize operator is the fastest resize operator, especially in large scale image reduction.
http://www.imagemagick.org/Usage/resize/#sample

also try "Resize During Image Read" with [2000x2000] direct after the filename
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extremely slow image resize

Post by fmw42 »

I am no expert on this, but I believe that is because those other tools put the whole image into memory. IM has a different memory management and process in smaller parts.

see
http://www.imagemagick.org/Usage/files/#massive
danc81
Posts: 7
Joined: 2012-01-23T12:18:56-07:00
Authentication code: 8675308

Re: Extremely slow image resize

Post by danc81 »

This is a strange one. I experienced the problem with the latest dynamic Q16 version but I replaced it with the Q16 static standalone version and they resize just as quickly the other tools. Seems there may be something different about the way the 2 handle large files?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extremely slow image resize

Post by fmw42 »

Do you have multiple processors? If so, you can try compiling without openmp. I am not sure if that is available on Window IM. But you can check from convert -version and it will say if OpenMP is there. Otherwise, I am at a loss and you will need to get a response from the IM developers.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Extremely slow image resize

Post by anthony »

Extremely slow is caused by ImageMagick reaching memory limits (which may be settable), and as a result offloading the image processing to disk. Using a Q8 version of IM will make it much faster as it will use half the memory as a Q16. Presumably you get some othe rreduction in memory from using the other version of IM (or perhaps memory limits are set different)

An alternative is to unlimit the memory limit and allow the machine to do 'swapping' itself as needed.
But a swapping machine can be just as slow!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply