Jump to content

Correcting $exif['EXIF']['ExposureTime'] values


StanLytle

Recommended Posts

Reading the $exif['EXIF']['ExposureTime'] values from digital images returns all sorts of numbers and improper fractions.  In trying to display proper fractions, I came up with the following.  Is there a better way.  ANd I see that this isn't going to work if the number isn't a fraction (contains the /):

 

/* set value to $exposure for testing*/

$exposure = "10/3200";

 

$pos = strpos($exposure, '/');

$num = substr($exposure, 0, $pos);

$pos = $pos + 1;

$denom = substr($exposure, $pos);

$dec = $num / $denom;

$newdenom = 1 / $dec;

$roundnewdenom = number_format($newdenom, 0);

$newexposure = "1/" . $roundnewdenom;

 

/* print $newexposure to check output */

echo "$newexposure<br/>";

 

Thanks,

Stan

 

 

Link to comment
https://forums.phpfreaks.com/topic/160866-correcting-exifexifexposuretime-values/
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.