View Single Post
  #22  
Old 12th July 2011
Kees's Avatar
Kees Kees is offline
Full member
 
Join Date: Jul 2010
Location: Netherlands
Posts: 202
Thanks: 39
Thanked 18 Times in 15 Posts
Likes: 0
Liked 0 Times in 0 Posts
Re: Any php specialists out there?

Quote:
Originally Posted by PaulE View Post
***EDIT
I think you are right in that the other scripts are using fixed offsets to get the values directly from the file - php exif_read_data is definitely looking at the right place within the file but why it doesn't return a sensible value I don't know. I done a bit of reading and came across a script that bypasses phps inbuilt exif_read_data function and reads byte by byte and hey presto pulling the value from the same offset that exif_read_data presumably uses for FocalLength (0x920a) returns a correct value of 14mm (after some correcting for byte order, data type etc) - it's very strange and far too complicated for me to get my head around but is at least there is a simple fix. Using the script below (under GNU General Public License) would save alot of hassle and seems to work perfectly:
http://www.jakeo.com/software/exif/index.php

then your script becomes:
Code:
// extract and display the exif data
	include('exif.php');

	$result = read_exif_data_raw($myfile,0);	

	$exposuretime = $result['SubIFD']['ExposureTime']; 
	$aperture = $result['SubIFD']['FNumber']; 
	$ISO = $result['SubIFD']['ISOSpeedRatings'];
	$focallength = $result['SubIFD']['FocalLength'];  

	echo "Shutter Speed: ".$exposuretime."<br/>\n";
	echo "Aperture: ".$aperture."<br/>\n";
	echo "ISO: ".$ISO."<br/>\n";
	echo "Focal Length: ".$focallength."<br/>\n";
It should be a simple 2min fix with no more worrying about strange formats, byte order and datatypes etc.
HTH
Paul.
I agree that this is the sensible solution.
There was an updat of the EXIF format in 2010, so it is also necessary to check if the software is up to date.
If anyone (David?) wants to go to the bottom of it, this is a very useful link.
Reply With Quote