how do I open a jpg for analysis
Posted: Thu Jun 10, 2004 5:12 pm
I want to make a motion detector with PHP. The script will simply open jpg images and look for major changes from one image to the next. I know how to write the motion detection functions, but I can't figure out how to open a jpg and convert it to a format that I can work with. I can do bin2hex using the code below, but then I just get a long string. How can I then seperate the individual pixels? Thanks in advance.
Code: Select all
$filename = "my.jpg";
$handle = fopen($filename, "rb");
$binaryImage = fread($handle, filesize($filename));
fclose($handle);
$hexImage = bin2hex($binaryImage);
echo $hexImage;