Page 1 of 1

how do I open a jpg for analysis

Posted: Thu Jun 10, 2004 5:12 pm
by tony_c
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;

Posted: Thu Jun 10, 2004 8:51 pm
by feyd
The all mighty Google provided: http://www.w3.org/Graphics/JPEG/

Thank you

Posted: Fri Jun 11, 2004 6:53 am
by tony_c
Thank you! That's Great! I must have been using the wrong keywords :wink:

Posted: Fri Jun 11, 2004 7:15 am
by Grim...
If this 'motion detector' isn't for a client or anything, I'd be interested in seeing the finished product.

Posted: Fri Jun 11, 2004 11:13 am
by feyd
for future reference, the Google search term was: [google]JFIF[/google]