How can i read the pixel colors from an image in PHP?

Nick

New member
I need to use PHP to read every pixel in a BMP image. I need to read the file in bytes and convert the bytes into the relevant color code using the fread command. at current the code i have is:
$file = $_POST['imglocation'];
$handle = fopen($file, "r");
$contents = fread($handle, filesize($file));
$pixels = explode("BM",$contents);
echo ord($pixels[1]);

at the moment this opens the file and removes the header. i am not sure if i am on the right lines or not.
Any help is much apreciated.
 
Back
Top