how do I open a jpg for analysis

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tony_c
Forum Newbie
Posts: 4
Joined: Wed Feb 11, 2004 9:11 am

how do I open a jpg for analysis

Post 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;
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The all mighty Google provided: http://www.w3.org/Graphics/JPEG/
tony_c
Forum Newbie
Posts: 4
Joined: Wed Feb 11, 2004 9:11 am

Thank you

Post by tony_c »

Thank you! That's Great! I must have been using the wrong keywords :wink:
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

If this 'motion detector' isn't for a client or anything, I'd be interested in seeing the finished product.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

for future reference, the Google search term was: [google]JFIF[/google]
Post Reply