Page 1 of 1
Performance issue when rotating images
Posted: 2009-05-24T09:11:03-07:00
by iben
Hi there,
I'm currently working with ImageMagick 6.5.2-5 2009-05-24 Q16 and imagick 2.2.2 on an Suse/Apache environment at my ISP. When I try to rotate an image it takes minutes, compared to version 6.4.9-10 2009-03-08 (that I have previously used on a Windows machine, my little netbook) much, much slower.
Any ideas what I could do about it? What has happend since v 6.4.9-10? Where can I get a pre 6.5 version (maybe that would help already ...)? Thanks in advance!
Ben.
Re: Performance issue when rotating images
Posted: 2009-05-24T10:43:25-07:00
by magick
See
http://www.imagemagick.org/script/architecture.php. Most likely your image pixels are being cached to disk rather than memory which can be an order of magnitude slower. To verify, add -debug cache to your command line and see if the pixels are allocated from memory or disk.
Re: Performance issue when rotating images
Posted: 2009-05-24T11:28:19-07:00
by iben
magick wrote:See
http://www.imagemagick.org/script/architecture.php. Most likely your image pixels are being cached to disk rather than memory which can be an order of magnitude slower. To verify, add -debug cache to your command line and see if the pixels are allocated from memory or disk.
Hi,
I have tried usr/local/bin/convert -debug cache logo: logo.gif and get the folloing output:
2009-05-24T20:23:10+02:00 0:01 0.010u 6.5.2 Cache convert[22428]: cache.c/DestroyPixelCacheInfo/1513/Cache
destroy
2009-05-24T20:23:10+02:00 0:01 0.010u 6.5.2 Cache convert[22428]: cache.c/OpenPixelCache/3832/Cache
open LOGO[0] (heap memory, 640x480 2.93mb)
2009-05-24T20:23:10+02:00 0:01 0.080u 6.5.2 Cache convert[22428]: cache.c/DestroyPixelCacheInfo/1513/Cache
destroy LOGO[0]
What does that mean to me? And if I cache to disk instead of memory: How can I change it?
Ben.
Re: Performance issue when rotating images
Posted: 2009-05-24T12:40:24-07:00
by magick
Your image pixels are cached to memory but you are using the logo: image, which is quite small. What size is your original image and how many degrees of rotation are you using. If you save the results to the GIF format, the process may be slower because the color reduction algorithm take into account transparent pixels whereas previously it did not. Post a URL to your image and the command you are using to rotate it. We'll need to reproduce the problem before we can offer further advice.
Re: Performance issue when rotating images
Posted: 2009-05-24T13:06:49-07:00
by iben
magick wrote:Your image pixels are cached to memory but you are using the logo: image, which is quite small. What size is your original image and how many degrees of rotation are you using. If you save the results to the GIF format, the process may be slower because the color reduction algorithm take into account transparent pixels whereas previously it did not. Post a URL to your image and the command you are using to rotate it. We'll need to reproduce the problem before we can offer further advice.
The image is a PNG and about 3055x3120 px (254px/inch) big. I try to rotate it by 45 degrees. I do it by using imagick and PHP (rotateimage). I do not have a URL to the image, but I could forward you a copy if you send my your mail address.
BTW: identify -list resource shows:
File Area Memory Map Disk
------------------------------------------------
768 4gb 3gb 8gb 16eb
I really appreciate your help!
Ben.
Re: Performance issue when rotating images
Posted: 2009-05-24T14:26:11-07:00
by magick
We created an image at 3055x3120 pixels and it rotated at 45 degrees in less than 10 seconds (3.0 Ghz box). If its taking longer for you, add -debug cache to your command line and see if its caching to disk (the debugging output will mention a filename in /tmp).
Re: Performance issue when rotating images
Posted: 2009-05-26T02:08:30-07:00
by iben
magick wrote:We created an image at 3055x3120 pixels and it rotated at 45 degrees in less than 10 seconds (3.0 Ghz box). If its taking longer for you, add -debug cache to your command line and see if its caching to disk (the debugging output will mention a filename in /tmp).
Hi, I use the following PHP code for imagick:
$first = new Imagick($userimage);
$first ->resampleImage(254, 254, 1, 0);
$res = $first->getImageResolution();
$x=$res['x']*30.55/2.54;
$y=$res['y']*31.20/2.54;
$first -> scaleImage ($x,$y);
$first -> rotateImage(new ImagickPixel(),-45);
$first -> writeImage(...);
I have no experience with ImageMagick on command line level, I would have to figure out how to do the stuff above outside PHP before I can try to add the debug option or can you post a few lines that I could use to do the above operations on command line level?
I have no clue about the performance of the virtual server at my ISP, buty they are based on quad core machines and I have guranteed 1 GB of memory. Could that cause problems? If the script above is running the web server does not respond at all (e.g. I can't open additional pages in a second browser window.
Again, thanks in advance!
Ben.
Re: Performance issue when rotating images
Posted: 2009-05-26T06:00:39-07:00
by magick
We have found one system where enabling OpenMP actually slowed down ImageMagick algorithms rather than speed it up. You could try rebuilding ImageMagick and add --disable-openmp to your configure script command line. When complete, type
It will not mention OpenMP. However, its still likely that with only 1GB of memory and such a large image, ImageMagick is caching your image pixels to disk which is slow. Set the MAGICK_DEBUG environment variable to 'cache' and run your PHP script to confirm. You are also running on a shared system so performance is variable depending on the load of the system.
We are not sure why your Apache web server is hanging. Perhaps your ISP has configuration parameters to single thread your server. Not sure.