RMagick scripts running too slow? If you're running the Q16 version of ImageMagick, you can make your RMagick scripts run 2x as fast simply by installing the Q8 version of ImageMagick.
What's the difference between the Q8 and Q16 versions?
The Q16 version uses 16 bits to represent each of the red, green, blue, and alpha (opacity) channels in a pixel. This means that ImageMagick uses 8 bytes to store the color information for each pixel in an image. Each channel can have a value between 0 and 65535. The Q8 version uses 8 bits per channel, therefore each pixel is stored in 4 bytes. The channel values range from 0 to 255.
Not only will switching from Q16 to Q8 make your RMagick scripts run faster, your app will need dramatically less memory since Q8 pixels are represented in half as much memory.
How do I know which version I've got?
Here are two ways. From the command line, enter
convert -version
The output will look something like this:
Version: ImageMagick 6.3.1 12/11/06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC
The Q16 in the first line indicates that this is the Q16 version of ImageMagick.
You can also ask Ruby. From the command line, enter
ruby -r RMagick -e"puts Magick::Magick_version"
The output will be similar to this:
ImageMagick 6.3.1 12/11/06 Q16 http://www.imagemagick.org
How do I know if I need to use the Q16 version?
If you don't already know that you need the Q16 version, you probably don't need it. Generally you need to use Q16 when you're doing commercial printing. For web graphics and printing on common inkjet printers, Q8 is sufficient.
Okay, I'm convinced. How do I get the Q8 version?
Build ImageMagick from source. When you run the configure script, specify the "--with-quantum-depth=8" option:
./configure <other-options> --with-quantum-depth=8
See http://rmagick.rubyforge.org/install-faq.html for more information.
I'm using Ruby on Windows. What do I do to get the Q8 version?
You don't need to do anything. The version of ImageMagick that is bundled with RMagick is the Q8 version.
I installed ImageMagick from a package. What can I do to get the Q8 version?
Either ask the package maintainer for a Q8 version, or build ImageMagick from source and configure it yourself.
What about GraphicsMagick?
GraphicsMagick's default is Q8. Unless you specifically configured it using the --with-quantum-depth=16 option, you don't need to do anything.
|