View Single Post
Old 11th July 2011
PaulE PaulE is offline
Full member
Join Date: May 2008
Location: Mid Wales
Posts: 330
Thanks: 0
Thanked 3 Times in 3 Posts
Likes: 0
Liked 0 Times in 0 Posts
Re: Any php specialists out there?

Originally Posted by Kees View Post
Or maybe other routines don't use the name tags, but fixed offsets to access the right position for the data. Then the fields can have a different name, but the correct data would still be in the same relative position and you'd still get the right answer. I don't know enough of how this was set up to be of any practical use in this regard though.
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:

then your script becomes:
// extract and display the exif data

	$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.
Reply With Quote