Dave
Dave

Reputation: 516

read_exif_data & ApertureFNumber

I've recently come across the php function exif_read_data - which is pretty awesome. I'm using it on my photography site, and while it works pretty well, I'm struggling to work out why ApertureFNumber isn't working. The code I'm using is:

$exif_data = exif_read_data($image[0]);

echo $exif_data['Model'];
echo $exif_data['ExposureTime'];
echo $exif_data['FNumber'];
echo $exif_data['ApertureFNumber'];
echo $exif_data['ISOSpeedRatings'];
echo $exif_data['DateTime'];

(styling removed)

I used FNumber as well as ApertureFNumber for testing because FNumber works, while ApertureFNumberjust returns blank. All the other fields work fine.

I did a var_dump of $exif_data - and this is what I get (the abridged version):

["ApertureFNumber"]=> string(5) "f/3.5"
["FNumber"]=> string(5) "35/10"

What have I missed that FNumber works, but ApertureFNumber doesn't?

--

EDIT - Complete var_dump added as requested

array(52) { ["FileName"]=> string(18) "MYD-67-900x602.jpg" ["FileDateTime"]=> int(0) ["FileSize"]=> int(123278) ["FileType"]=> int(2) ["MimeType"]=> string(10) "image/jpeg" ["SectionsFound"]=> string(30) "ANY_TAG, IFD0, THUMBNAIL, EXIF" ["COMPUTED"]=> array(9) { ["html"]=> string(24) "width="900" height="602"" ["Height"]=> int(602) ["Width"]=> int(900) ["IsColor"]=> int(1) ["ByteOrderMotorola"]=> int(0) ["ApertureFNumber"]=> string(5) "f/3.5" ["FocusDistance"]=> string(14) "4294967296.00m" ["Thumbnail.FileType"]=> int(2) ["Thumbnail.MimeType"]=> string(10) "image/jpeg" } ["Make"]=> string(17) "NIKON CORPORATION" ["Model"]=> string(9) "NIKON D60" ["XResolution"]=> string(5) "200/1" ["YResolution"]=> string(5) "200/1" ["ResolutionUnit"]=> int(2) ["Software"]=> string(41) "Adobe Photoshop Lightroom 4.4 (Macintosh)" ["DateTime"]=> string(19) "2013:07:06 10:07:40" ["Exif_IFD_Pointer"]=> int(216) ["THUMBNAIL"]=> array(6) { ["Compression"]=> int(6) ["XResolution"]=> string(5) "200/1" ["YResolution"]=> string(5) "200/1" ["ResolutionUnit"]=> int(2) ["JPEGInterchangeFormat"]=> int(932) ["JPEGInterchangeFormatLength"]=> int(8995) } ["ExposureTime"]=> string(5) "1/800" ["FNumber"]=> string(5) "35/10" ["ExposureProgram"]=> int(1) ["ISOSpeedRatings"]=> int(100) ["ExifVersion"]=> string(4) "0230" ["DateTimeOriginal"]=> string(19) "2008:10:30 16:04:34" ["DateTimeDigitized"]=> string(19) "2008:10:30 16:04:34" ["ShutterSpeedValue"]=> string(15) "9643856/1000000" ["ApertureValue"]=> string(13) "361471/100000" ["ExposureBiasValue"]=> string(3) "0/6" ["MaxApertureValue"]=> string(5) "36/10" ["SubjectDistance"]=> string(4) "-1/1" ["MeteringMode"]=> int(5) ["LightSource"]=> int(0) ["Flash"]=> int(0) ["FocalLength"]=> string(4) "18/1" ["SubSecTimeOriginal"]=> string(2) "50" ["SubSecTimeDigitized"]=> string(2) "50" ["SensingMethod"]=> int(2) ["FileSource"]=> string(1) "" ["SceneType"]=> string(1) "" ["CFAPattern"]=> string(8) "" ["CustomRendered"]=> int(0) ["ExposureMode"]=> int(1) ["WhiteBalance"]=> int(0) ["DigitalZoomRatio"]=> string(3) "1/1" ["FocalLengthIn35mmFilm"]=> int(27) ["SceneCaptureType"]=> int(0) ["GainControl"]=> int(0) ["Contrast"]=> int(0) ["Saturation"]=> int(0) ["Sharpness"]=> int(0) ["SubjectDistanceRange"]=> int(0) ["UndefinedTag:0xA431"]=> string(7) "6265825" ["UndefinedTag:0xA432"]=> array(4) { [0]=> string(4) "18/1" [1]=> string(4) "55/1" [2]=> string(5) "35/10" [3]=> string(5) "56/10" } ["UndefinedTag:0xA434"]=> string(22) "18.0-55.0 mm f/3.5-5.6" }

Upvotes: 0

Views: 431

Answers (2)

Dave
Dave

Reputation: 516

So, I got this figured out now - and thought you might like to see the answer.

The var_dump was giving the data ["ApertureFNumber"]=> string(5) "f/3.5", but wasn't really getting me anywhere, so instead I used print_r($exif_data). That printed out a whole load of useful data including the following:

[COMPUTED] => Array
        (
            [html] => width="1000" height="667"
            [Height] => 667
            [Width] => 1000
            [IsColor] => 1
            [ByteOrderMotorola] => 0
            [ApertureFNumber] => f/3.5
            [Thumbnail.FileType] => 2
            [Thumbnail.MimeType] => image/jpeg
            [Thumbnail.Height] => 171
            [Thumbnail.Width] => 256
        )

So, to echo out the needed ApertureFNumber I simply used
echo $exif['COMPUTED']['ApertureFNumber']; It also works for any of the information in the printed array.

Hopefully this helps someone else in the future.

Upvotes: 0

Moeed Farooqui
Moeed Farooqui

Reputation: 3622

Try This:

$exif = exif_read_data($image[0]);
foreach($exif as $exif_data){
echo $exif_data['Model']."<br/>";
echo $exif_data['ExposureTime']."<br/>";
echo $exif_data['FNumber']."<br/>";
echo "ApertureFNumber is:" .$exif_data['ApertureFNumber']."<br/>";
echo $exif_data['ISOSpeedRatings']."<br/>";
echo $exif_data['DateTime']."<br/>";
}

Upvotes: 2

Related Questions