@@ -150,13 +150,18 @@ public function mapRawData(array $data)
150150 }
151151 break ;
152152 case self ::EXPOSURETIME :
153- // normalize ExposureTime
154- // on one test image, it reported "10/300" instead of "1/30"
155- list ($ counter , $ denominator ) = explode ('/ ' , $ value );
156- if (intval ($ counter ) !== 1 ) {
157- $ denominator /= $ counter ;
153+ if (!is_float ($ value )) {
154+ $ value = $ this ->normalizeComponent ($ value );
155+ }
156+
157+ // Based on the source code of Exiftool (PrintExposureTime subroutine):
158+ // http://cpansearch.perl.org/src/EXIFTOOL/Image-ExifTool-9.90/lib/Image/ExifTool/Exif.pm
159+ if ($ value < 0.25001 && $ value > 0 ) {
160+ $ value = sprintf ('1/%d ' , intval (0.5 + 1 / $ value ));
161+ } else {
162+ $ value = sprintf ('%.1f ' , $ value );
163+ $ value = preg_replace ('/.0$/ ' , '' , $ value );
158164 }
159- $ value = '1/ ' . round ($ denominator );
160165 break ;
161166 case self ::FOCALLENGTH :
162167 $ parts = explode ('/ ' , $ value );
@@ -217,7 +222,7 @@ protected function isSection($field)
217222 */
218223 protected function extractGPSCoordinate (array $ components )
219224 {
220- $ components = array_map (array ($ this , 'normalizeGPSComponent ' ), $ components );
225+ $ components = array_map (array ($ this , 'normalizeComponent ' ), $ components );
221226
222227 if (count ($ components ) > 2 ) {
223228 return intval ($ components [0 ]) + (intval ($ components [1 ]) / 60 ) + (floatval ($ components [2 ]) / 3600 );
@@ -227,12 +232,12 @@ protected function extractGPSCoordinate(array $components)
227232 }
228233
229234 /**
230- * Normalize GPS coordinates components
235+ * Normalize component
231236 *
232237 * @param mixed $component
233238 * @return int|float
234239 */
235- protected function normalizeGPSComponent ($ component )
240+ protected function normalizeComponent ($ component )
236241 {
237242 $ parts = explode ('/ ' , $ component );
238243
0 commit comments