 |
Forums |
Admin Start New Thread
| Message: 64371 |
 |
BY: Tim Hunter (rmagick) DATE: 2009-02-01 21:26 SUBJECT: Why are RGB values in the range 0-65535? From time-to-time I get a report that RMagick is returning the "wrong" RGB values for a pixel. The complaint is that the values are too big, that is, greater than 255. This is not an error. It is a result of how ImageMagick has been configured.
ImageMagick has a configurable "quantum depth". Quantum is the data type used to contain the RGB values of a pixel, and quantum depth is the number of bits in a quantum. ImageMagick can be configured to use 8, 16, 32, or 64 bit quanta. The quantum depth is chosen when ImageMagick is configured and cannot be changed without recompiling and reinstalling ImageMagick.
When ImageMagick is configured to use an 8-bit quantum, the RGB values will be in the range 0-255. For a 16-bit quantum, the RGB values will be in the range 0-65535.
By default, ImageMagick is configured to use a 16-bit quantum. Usually pre-compiled packages for Linux distributions, such as the libmagick deb for Ubuntu and Debian, or the ImageMagick rpm on Fedora, are compiled using this default. On these systems in order to configure ImageMagick to use an 8-bit quantum you will have to build ImageMagick from source yourself.
On OS X the MacPorts system offers a variant of the ImageMagick port, +q8, which is configured with an 8-bit quantum. On Win32, the version of ImageMagick bundled with the RMagick gem is the 8-bit quantum version.
You can determine what quantum depth your particular installation of ImageMagick is using by issuing this command:
convert -version
Look for the string "Q16" or "Q8" in the output.
In a script that uses RMagick, the number of bits in a quantum is in the constant Magick::QuantumDepth, and the maximum value of a quantum is in the constant Magick::QuantumRange.
The quantum depth has a strong influence on the amount of memory used by ImageMagick as well as how much CPU is required to process images. In general, more bits = more memory and more CPU. See this page for more information about ImageMagick's quantum depth option: http://imagemagick.org/script/advanced-unix-installation.php. | |
Thread View
Post a followup to this message
|
 |