StanLytle Posted June 4, 2009 Share Posted June 4, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.