View Full Version : Retrieve pixels from image

05-07-2006, 12:16 PM

Imagine I have a photo/image and I want to know what color is attributed to a certain pixel.
Is it possible to do that with PHP?

I found this in the PHP manual:

$im = ImageCreateFromPng("rockym.png");
$rgb = ImageColorAt($im, 100, 100);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;

but apparently, it gives me three different colors. Plus, would it still work if $im points to an image file?


05-07-2006, 12:46 PM
...it gives you the RGB color in $rgb and the r,g,b separated into $r, $g, $b variables
$im does point to an image file...'rockym.png'

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum