Rotating an image seems 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
pitosalas

Rotating an image seems slow

Post by pitosalas »

I writing a specialized deskew algorithm for USA voting ballots. I've figured out the angle that I need to rotate based on various marks that are always present.

What's the fastest way to do a rotate?

The basic API call 'rotate' appears to be very slow.

It takes 13 seconds on a Mac G5 to rotate a TIFF 1696x2824 1696x2824+0+0 DirectClass 8-bit 585kb

Is that normal? Is there a better way?

Thanks!

Pito
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Rotating an image seems slow

Post by magick »

The speed of ImageMagick is relative to the hardware its running on. Add -debug cache to your command line to see if the pixels are cached to disk or memory. If its disk, it can be slow (disk is always slower than real memory). If you have a dual-core system, ImageMagick can split the work between cores if your ImageMagick release is modern. We just converted a 4096x4096 image 13 degrees in less than 5 seconds on our 16GB 4 processor system.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating an image seems slow

Post by anthony »

The alternative way to rotate is to use -filter point +distort SRT {angle} +repage

Using -distort instead of the 'plus' version will be slightly faster, but may clip some detail from the image corners, if this is a skewed scan however that loss is probably junk in any case.

If this is faster than normal -rotate for your large image then... let us know...
Then look at IM Examples, distorting Images to understand the operation and what else you can do with it.
http://www.imagemagick.org/Usage/distorts/

You may also like to look at the info in IM Examples, Simple Image Warping, Rotate
http://www.imagemagick.org/Usage/warping/#rotate
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply