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
https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/
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
https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819348
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
https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819353
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
https://forums.phpfreaks.com/topic/155669-cant-read-exif-data/#findComment-819509
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.