Jump to content

Problem reading Exif data


foucquet

Recommended Posts

OK, so I am trying to read exif data from images and have come up against a snag that I cannot see the answer to. I know that what I have at present is pretty basic, but I want to be sure that I know how to access the bits I want before tidying it up into something more sophisticated. The coide I have is this:-

 

$exif = exif_read_data('brass jaw.jpg', 'EXIF');

$name = $exif['FileName'];
$height = $exif['ExifImageWidth'];
$width = $exif['ExifImageLength'];
$model = $exif['Model'];
$exposuretime = $exif['ExposureTime'];
$fnumber = $exif['FNumber'];
$iso = $exif['ISOSpeedRatings'];
$date = $exif['DateTime'];

echo "File Name: $name<br />";
echo "Height: $height<br />";
echo "Width: $width<br />";
echo "Camera: $model<br />";
echo "Shutter Speed: $exposuretime<br />";
echo "F number: $fnumber<br />";
echo "ISO: $iso<br />";
echo "Date & Time: $date<br />";

var_dump($exif);

 

This code produces the following:-

 

File Name: brass jaw.jpg

Height: 640

Width: 360

Camera: Canon EOS 550D

Shutter Speed: 244/1000000

F number: 8000000/1000000

ISO: Array

Date & Time: 2011:09:17 13:52:30

 

Which serves quite well apart from the ISO, which comes back as "Array". Now when I do a var_dump I see that ISOSpeedRatings returns as this:-

 

'ISOSpeedRatings' =>

array

0 => int 800

1 => int 800

 

What I can't work out is how to access the information from this - I know that the solution will probably be very simple, and that I will end up kicking myself, but I could use a little help.

Link to comment
Share on other sites

It's a simple multidimensional array.

 

echo $iso['ISOSpeedRatings'][0];
echo $iso['ISOSpeedRatings'][1];

 

That produces "Notice: Undefined index: ISOSpeedRatings" - I had thought of this but got the same result and couldn't work out why, which is why I resorted to the forum...

Link to comment
Share on other sites

It's a simple multidimensional array.

 

echo $iso['ISOSpeedRatings'][0];
echo $iso['ISOSpeedRatings'][1];

 

That produces "Notice: Undefined index: ISOSpeedRatings" - I had thought of this but got the same result and couldn't work out why, which is why I resorted to the forum...

 

OK, problem solved replacing $iso with $exif did the trick - logical really, I just knew the solution would be simple...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.