Skip to content

Commit eb5a528

Browse files
author
Marek Szymczuk
committed
Added check for case when exposure time is already a decimal value.
1 parent 9cd8186 commit eb5a528

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/PHPExif/Exif.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ public function getExposureMilliseconds()
346346
return false;
347347
}
348348

349+
if (is_float($this->data[self::EXPOSURE])) {
350+
return $this->data[self::EXPOSURE];
351+
}
352+
349353
$exposureParts = explode('/', $this->data[self::EXPOSURE]);
350354

351355
return (int) reset($exposureParts) / (int) end($exposureParts);

tests/PHPExif/ExifTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,19 @@ public function testGetExposure()
219219
*/
220220
public function testGetExposureMilliseconds()
221221
{
222-
$expected = 1/320;
223-
$data[\PHPExif\Exif::EXPOSURE] = '1/320';
224-
$this->exif->setData($data);
225-
$this->assertEquals($expected, $this->exif->getExposureMilliseconds());
222+
$rawData = array(
223+
array(1/300, '1/300'),
224+
array(0.0025, 0.0025),
225+
);
226+
227+
foreach ($rawData as $data) {
228+
$expected = reset($data);
229+
$value = end($data);
230+
231+
$data[\PHPExif\Exif::EXPOSURE] = $value;
232+
$this->exif->setData($data);
233+
$this->assertEquals($expected, $this->exif->getExposureMilliseconds());
234+
}
226235
}
227236

228237
/**

0 commit comments

Comments
 (0)