|
| Index | Recent Threads | Unanswered Threads | Who's Online | User List | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 5
|
|
| Author |
|
|
Member USA Joined: Mar 11, 2008 Post Count: 95 Status: Offline |
I want to extract the Exif Data (date, time, f-stop, ISO, shudderspeed) from images using a PHP script. Here is the site, just choose any of the links on the left and you will see a picture(s) and their exif data to the right of the picture. http://birds.adamvalencic.com But the exif data is currently hardcoded, meaning yes, I entered it like 53 times, literally. I found some help on php.net and got this far: http://birds.adamvalencic.com/test.php that test page uses this code: <img src="images/wren.jpg" alt="wrens" />That is a good start, but I don't want all of that, I just want certain parts of it. I read on php.net that the data is all stored in an array, but I can't figure out what it's called. Plus, once I get the code to only display the exif data I want, I need to get rid of the Exif description and just get the value itself . For example, EXIF.FocalLength: 3000/10 get rid of EXIF.FocalLength: and just display 3000/10. I know, this is a tall order... ---------------------------------------- Running IE6, IE7, and FF2 |
||
|
|
Advanced Member Joined: Jun 14, 2003 Post Count: 2940 Status: Offline |
Hi, All you need to do is get the key names and then only display the ones you want. If you don't know the key names, then use the index position: echo $array[0]; echo $array[1]; ... and so on. In you case the array is contained in $exif. Stefan ---------------------------------------- Stefan Mischook Video Tutorial Store | Web Templates |
||
|
|
Member USA Joined: Mar 11, 2008 Post Count: 95 Status: Offline |
Thanks! But that only solves half of my problem. Take this code for example: <img src="images/wren.jpg" alt="wrens" />This outputs the Date and Time from the Exif in this format: 2007:05:11 09:03:06 I need to change that into something like this: 05/11/2007 09:03am I know it is fairly simple, but I just don't know all the syntax for php. And even more importantly, I get a bunch of outputs like this: 3000/10 which needs to be 300 and 56/10 which needs to be 5.6 is there a way to do the math in PHP? ---------------------------------------- Running IE6, IE7, and FF2 ---------------------------------------- [Edit 1 times, last edit by swurp at Jun 11, 2008 9:59:07 AM] |
||
|
|
Member USA Joined: Mar 11, 2008 Post Count: 95 Status: Offline |
I figured this one out. I opted not to use the date/time stuff because they weren't set correctly anyways. But here is how I got the rest of the data: <?php function ex($param){ $exif = exif_read_data($param, 0, true); foreach ($exif as $key => $section) { foreach ($section as $name => $val) { if($name == 'ExposureTime'){ echo "<h2>Exposure Time:</h2>"; echo "<h3> $val sec</h3>"; } if($name == 'FNumber'){ list($pt1, $pt2) = split('[/.-]', $val); $fstop=$pt1/$pt2; echo "<h2>F-Stop:</h2>"; echo "<h3>$fstop</h3>"; } if($name =='ISOSpeedRatings'){ echo "<h2>ISO:</h2>"; echo "<h3> $val</h3>"; } if($name =='FocalLength'){ list($pt1, $pt2) = split('[/.-]', $val); $focal=$pt1/$pt2; echo "<h2>Focal Length:</h2>"; echo "<h3> $focal</h3>"; } if($name =='Make'){ echo "<h1>Camera:</h1>"; echo "<p>$val</p>"; } } } } ?> ---------------------------------------- Running IE6, IE7, and FF2 |
||
|
|
Stranger Joined: Jun 13, 2008 Post Count: 1 Status: Offline |
Hi Swurp, I've just spent all day on this exact topic, and at the moment am searching on how to ADD EXIF data to my exisiting JPG's. Anyway, below is all the code I used to get the information that I wanted from my photos. Hope this is of use to you..... $pathfile is the path and filename of the photograph you want the information from.Cheers, Phil. |
||
|
|
|
|
|
Current timezone is GMT Sep 2, 2010 8:47:50 PM |