note 108556 added to imagick.getimagechanneldepth
| From: | holdoffhunger at gmail dot com | Date: | Sun, 06 May 2012 23:48:11 +0000 |
| Subject: | note 108556 added to imagick.getimagechanneldepth | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187494@lists.php.net to get a copy of this message | ||
For undocumented functions, this is a particular oddity. For me, this function has so far returned
only two values for any particular image: 1 and 8. And, after experimenting with it about forty or
fifty times, I think I understand how it works, based simply on my experience.
The value returned is the number of bits used for the particular color channel within an image.
That means how variable a particular color is within an image. While I received 1 and 8, it could
theoretically be as much as 16 or 32, depending on how the technology evolves over, say, the next
decade or so.
To best understand this function, you should probably also understand the ImageMagick function
getColorValue. In terms of the ImageMagick class, a color can be measured between 0 and 1, in terms
in of a particular pixel. Red, Green, Blue, or, any particular color of any color scheme, can be
something like 0.501960784314. But, since each pixel is a combination of the three colors, you can
have 0.845 for red, 0.254 for green, and 0.11 for blue.
How does this all tie in with the getChannelDepth function? Easy. If all of the pixels in an image
are either values 1 or values 0 for the particular Red/Green/Blue values, then this function will
return a 1 for 1 bits per pixel for that color channel. If, however, any single pixel in the image
for the inputted channel parameter isn't exactly 1 or 0 for the particular color channel, then
this function will return an 8 for 8-bit colors per pixel for that color channel.
If you receive back a 1 for every single color channel put in the parameter, that means you're
dealing with an image that's 16-bit -- you know, like those computer games published in 1982,
or the Atari console games. You won't ever forget a 16-bit color green, trust me. If you get
back an 8 for every single color channel put in the parameter, that means you're dealing with
any standard, modern image.
You can input any color channel, based on the channel constants available within the ImageMagick
class. See them here: http://www.php.net/manual/en/imagick.constants.php#imagick.constants.channel
. That means a format like imagick::CHANNEL_UNDEFINED, but with the "_UNDEFINED" value
being anything here: undefined, red, gray, cyan, green, magenta, blue, yellow, alpha, opacity,
matte, black, index, all, and default.
For any image with one pixel color of RGB value 1 / 0.501960784314 / 0.501960784314 (#FF8080), you
get this result:
Channel - 'Undefined' : 1
Channel - 'Red' : 1
Channel - 'Gray' : 1
Channel - 'Cyan' : 1
Channel - 'Green' : 8
Channel - 'Magenta' : 8
Channel - 'Blue' : 8
Channel - 'Yellow' : 8
Channel - 'Alpha' : 1
Channel - 'Opacity' : 1
Channel - 'Matte' : 1
Channel - 'Black' : 1
Channel - 'Index' : 1
Channel - 'All' : 8
Channel - 'Default' : 8
If all colors are between 0 and 1 with getColorValue function, each of these results with be 1. If
you're dealing with an image that has full color spectrum depth (almost any given photograph),
you'll get 8 for red, gray, cyan, green, magenta, blue, yellow, all, and default, with a 1 for
the other remaining channels. Perhaps some use for automated image editing, like use with posterize
or oilpaint functions.
----
Server IP: 69.147.83.197
Probable Submitter: 68.9.137.178
----
Manual Page -- http://www.php.net/manual/en/imagick.getimagechanneldepth.php
Edit -- https://master.php.net/note/edit/108556
Del: integrated -- https://master.php.net/note/delete/108556/integrated
Del: useless -- https://master.php.net/note/delete/108556/useless
Del: bad code -- https://master.php.net/note/delete/108556/bad+code
Del: spam -- https://master.php.net/note/delete/108556/spam
Del: non-english -- https://master.php.net/note/delete/108556/non-english
Del: in docs -- https://master.php.net/note/delete/108556/in+docs
Del: other reasons-- https://master.php.net/note/delete/108556
Reject -- https://master.php.net/note/reject/108556
Search -- https://master.php.net/manage/user-notes.php