0

I need to rotate an image from my Ruby/Rails application and I've been using ImageMagick through the RMagick gem. I've tried both the command line tool (i.e. convert) and the API (e.g. Magick::Image#rotate) and in both cases the performance is more than 50 times worse than the corresponding Java operation in java.awt.geom.AffineTransform, per https://code.google.com/p/zxing/issues/detail?id=1745#c21 and the corresponding response (i.e. more than a second vs. 10s of milliseconds).

I've tried to step through the code in the RMagick gem using pry, but I can't "penetrate" the Image#rotate function from the debugger.

Although I've only tried rotate through the API, I've tried the convert command tool with and without -affine ... -transform and the results have not been significantly different.

Any help would be appreciated.

Peter Alfvin
  • 28,599
  • 8
  • 68
  • 106
  • The RMagick stuff is a very thin layer over the C library so there shouldn't be much difference between RMagick and `convert` (or any of the other wrappers) for this sort of thing. I'd suspect that the Java stuff is using native hardware support for the heavy lifting but ImageMagick is doing it all by hand. – mu is too short Jan 27 '14 at 02:39
  • Thanks, @muistooshort, that makes sense. I was thinking of switching to JRuby for other reasons, which would give me access to the Java 2D library, but I can't help but wonder if someone hasn't already addressed the problem of connecting ImageMagick to hardware acceleration as well (e.g. through OpenGL). – Peter Alfvin Jan 27 '14 at 03:28
  • You could try [GraphicsMagick](http://www.graphicsmagick.org), same bizarre and twisted API as ImageMagick but better code underneath. I think Flickr uses GM under the covers and I've had some success with GM in the past. – mu is too short Jan 27 '14 at 03:49
  • Hmmm. According to https://github.com/rmagick/rmagick, RMagick already provides an interface to GraphicsMagick, but https://github.com/rmagick/rmagick seems to suggest that it doesn't take advantage of hardware acceleration. You think I'm misreading things? – Peter Alfvin Jan 27 '14 at 04:03
  • RMagick can sit on top of either one. I don't think GM does hardware acceleration either but it should be faster than IM. – mu is too short Jan 27 '14 at 04:09

0 Answers0