Jump to content

Can't read exif data


StanLytle

Recommended Posts

When images are uploaded, they are given a random file name, such as /tmp/php7cFxpG.  How do I get this file name to work with exif_read_data?

 

Here's what I have that doesn't work:

 

$exif = exif_read_data('$File', 'IFD0');

if ($exif == true)

{

$exif = exif_read_data('$File', 0, true);

foreach ($exif as $key => $section)

{

$model = $exif['IFD0']['Model'];

$iso = $exif['EXIF']['ISOSpeedRatings'];

$exposure = $exif['EXIF']['ExposureTime'].' sec';

$fstop = $exif['COMPUTED']['ApertureFNumber'];

$focallength = intval($exif['EXIF']['FocalLength']).' mm';

$focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm';

}

echo "Model: $model<br/>";

echo "ISO: $iso<br/>";

echo "Shutter Speed: $exposure<br/>";

echo "f Stop: $fstop<br/>";

echo "Focal Length: $focallength<br/>";

echo "Focal Length 35mm: $focallength35mm<br/>";

$PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength;

}

else

{

$PhotoExif = "";

}

 

Thanks

 

Link to comment
Share on other sites

I'm not sure if I did what you suggested correctly, but it didn't work either.  Here's what I tried:

 

$exif = exif_read_data('$_FILES[File][$File]', 'IFD0');

if ($exif == true)

{

$exif = exif_read_data('$_FILES[File][$File]', 0, true);

foreach ($exif as $key => $section)

{

$model = $exif['IFD0']['Model'];

$iso = $exif['EXIF']['ISOSpeedRatings'];

$exposure = $exif['EXIF']['ExposureTime'].' sec';

$fstop = $exif['COMPUTED']['ApertureFNumber'];

$focallength = intval($exif['EXIF']['FocalLength']).' mm';

$focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm';

}

echo "Model: $model<br/>";

echo "ISO: $iso<br/>";

echo "Shutter Speed: $exposure<br/>";

echo "f Stop: $fstop<br/>";

echo "Focal Length: $focallength<br/>";

echo "Focal Length 35mm: $focallength35mm<br/>";

$PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength;

}

else

{

$PhotoExif = "";

}

 

Thanks

 

Link to comment
Share on other sites

And I tried removing the single quotes.  Still doesn't work:

 

$exif = exif_read_data($File, 'IFD0');

if ($exif == true)

{

$exif = exif_read_data($File, 0, true);

foreach ($exif as $key => $section)

{

$model = $exif['IFD0']['Model'];

$iso = $exif['EXIF']['ISOSpeedRatings'];

$exposure = $exif['EXIF']['ExposureTime'].' sec';

$fstop = $exif['COMPUTED']['ApertureFNumber'];

$focallength = intval($exif['EXIF']['FocalLength']).' mm';

$focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm';

}

echo "Model: $model<br/>";

echo "ISO: $iso<br/>";

echo "Shutter Speed: $exposure<br/>";

echo "f Stop: $fstop<br/>";

echo "Focal Length: $focallength<br/>";

echo "Focal Length 35mm: $focallength35mm<br/>";

$PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength;

}

else

{

$PhotoExif = "";

}

 

 

Thanks

Link to comment
Share on other sites

Some success!  What was missing were foreach statements.  At least thats what made it work.  I can extract the data, even though the data isn't output in the format I want:

 

$exif = exif_read_data($File, 'IFD0');

if ($exif == true)

{

$exif = exif_read_data($File, 0, true);

foreach ($exif as $key => $section)

{

foreach ($section as $name => $val)

{

$model = $exif['IFD0']['Software'];

$iso = $exif['EXIF']['ISOSpeedRatings'];

$exposure = $exif['EXIF']['ExposureTime'].' sec';

$fstop = $exif['COMPUTED']['ApertureFNumber'];

$focallength = intval($exif['EXIF']['FocalLength']).' mm';

$focallength35mm = intval($exif['EXIF']['FocalLengthIn35mmFilm']).' mm';

}

}

if ($model == "K10D ")

{

$model = "Pentax K10D";

}

$PhotoExif = $model . ", ISO " . $iso . ", " . $exposure. ", " . $fstop. ", " . $focallength;

}

 

Now the problem is that I can't change the value of $model from "K10D space" to "Pentax K10D".

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.