Skip to content

Commit afb0d0a

Browse files
committed
Bugfixes
1 parent abd5b8e commit afb0d0a

File tree

5 files changed

+32
-43
lines changed

5 files changed

+32
-43
lines changed

lib/PHPExif/Exif.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class Exif
5656
const LATITUDE = 'latitude';
5757
const IMGDIRECTION = 'imgDirection';
5858
const LENS = 'lens';
59-
const SUBJECT = 'subject';
6059
const CONTENTIDENTIFIER = 'contentIdentifier';
6160
const FRAMERATE = 'framerate';
6261
const DURATION = 'duration';
@@ -1072,33 +1071,6 @@ public function getLens()
10721071
return $this->data[self::LENS];
10731072
}
10741073

1075-
/**
1076-
* Sets the subject value
1077-
*
1078-
* @param string $value
1079-
* @return \PHPExif\Exif
1080-
*/
1081-
public function setSubject($value)
1082-
{
1083-
$this->data[self::SUBJECT] = $value;
1084-
1085-
return $this;
1086-
}
1087-
1088-
/**
1089-
* Returns subject, if it exists
1090-
*
1091-
* @return string|boolean
1092-
*/
1093-
public function getSubject()
1094-
{
1095-
if (!isset($this->data[self::SUBJECT])) {
1096-
return false;
1097-
}
1098-
1099-
return $this->data[self::SUBJECT];
1100-
}
1101-
11021074
/**
11031075
* Sets the content identifier value
11041076
*

lib/PHPExif/Mapper/Exiftool.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class Exiftool implements MapperInterface
118118
self::IMGDIRECTION => Exif::IMGDIRECTION,
119119
self::LENS => Exif::LENS,
120120
self::DESCRIPTION => Exif::DESCRIPTION,
121-
self::SUBJECT => Exif::SUBJECT,
121+
self::SUBJECT => Exif::KEYWORDS,
122122
self::CONTENTIDENTIFIER => Exif::CONTENTIDENTIFIER,
123123
self::DATETIMEORIGINAL_QUICKTIME => Exif::CREATION_DATE,
124124
self::MAKE_QUICKTIME => Exif::MAKE,
@@ -185,7 +185,12 @@ public function mapRawData(array $data)
185185
case self::DATETIMEORIGINAL:
186186
case self::DATETIMEORIGINAL_QUICKTIME:
187187
try {
188-
$value = new DateTime(date('Y-m-d H:i:s', strtotime($value)));
188+
if(!(strtotime($value)==false)) {
189+
$value = new DateTime(date('Y-m-d H:i:s', strtotime($value)));
190+
} else {
191+
continue 2;
192+
}
193+
189194
} catch (\Exception $exception) {
190195
continue 2;
191196
}

lib/PHPExif/Mapper/Native.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Native implements MapperInterface
131131
self::LENS_LR => Exif::LENS,
132132
self::LENS_TYPE => Exif::LENS,
133133
self::DESCRIPTION => Exif::DESCRIPTION,
134-
self::SUBJECT => Exif::SUBJECT,
134+
self::SUBJECT => Exif::KEYWORDS,
135135
self::FRAMERATE => Exif::FRAMERATE,
136136
self::DURATION => Exif::DURATION
137137

@@ -148,7 +148,7 @@ public function mapRawData(array $data)
148148
{
149149
$mappedData = array();
150150
$gpsData = array();
151-
$mappedData['description']="";
151+
152152
foreach ($data as $field => $value) {
153153
if ($this->isSection($field) && is_array($value)) {
154154
$subData = $this->mapRawData($value);
@@ -168,7 +168,11 @@ public function mapRawData(array $data)
168168
switch ($field) {
169169
case self::DATETIMEORIGINAL:
170170
try {
171-
$value = new DateTime($value);
171+
if(!(strtotime($value)==false)) {
172+
$value = new DateTime(date('Y-m-d H:i:s', strtotime($value)));
173+
} else {
174+
continue 2;
175+
}
172176
} catch (Exception $exception) {
173177
continue 2;
174178
}

tests/PHPExif/Mapper/ExiftoolMapperTest.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testMapRawDataCorrectlyFormatsCreationDate()
111111
$result = reset($mapped);
112112
$this->assertInstanceOf('\\DateTime', $result);
113113
$this->assertEquals(
114-
reset($rawData),
114+
reset($rawData),
115115
$result->format('Y:m:d H:i:s')
116116
);
117117
}
@@ -184,9 +184,13 @@ public function testMapRawDataCorrectlyFormatsGPSData()
184184
)
185185
);
186186

187-
$expected = '40.333452380556,-20.167314813889';
188-
$this->assertCount(1, $result);
189-
$this->assertEquals($expected, reset($result));
187+
$expected_gps = '40.333452380556,-20.167314813889';
188+
$expected_lat = '40.333452380556';
189+
$expected_lon = '40.333452380556';
190+
$this->assertCount(3, $result);
191+
$this->assertEquals($expected_gps, $result['gps']);
192+
$this->assertEquals($expected_lat, $result['latitude']);
193+
$this->assertEquals($expected_lon, $result['longitude']);
190194
}
191195

192196
/**
@@ -204,9 +208,13 @@ public function testMapRawDataCorrectlyFormatsNumericGPSData()
204208
)
205209
);
206210

207-
$expected = '40.333452381,-20.167314814';
208-
$this->assertCount(1, $result);
209-
$this->assertEquals($expected, reset($result));
211+
$expected_gps = '40.333452381,-20.167314814';
212+
$expected_lat = '40.333452381';
213+
$expected_lon = '-20.167314814';
214+
$this->assertCount(3, $result);
215+
$this->assertEquals($expected_gps, $result['gps']);
216+
$this->assertEquals($expected_lat, $result['latitude']);
217+
$this->assertEquals($expected_lon, $result['longitude']);
210218
}
211219

212220
/**
@@ -232,7 +240,7 @@ public function testMapRawDataCorrectlyIgnoresIncorrectGPSData()
232240
* @group mapper
233241
* @covers \PHPExif\Mapper\Exiftool::mapRawData
234242
*/
235-
public function testMapRawDataCorrectlyIgnoresIncompleteGPSData()
243+
public function testMapRawDataOnlyLatitude()
236244
{
237245
$result = $this->mapper->mapRawData(
238246
array(
@@ -241,7 +249,7 @@ public function testMapRawDataCorrectlyIgnoresIncompleteGPSData()
241249
)
242250
);
243251

244-
$this->assertCount(0, $result);
252+
$this->assertCount(1, $result);
245253
}
246254

247255
/**

tests/PHPExif/Mapper/NativeMapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public function testMapRawDataFlattensRawDataWithSections()
210210
* @group mapper
211211
* @covers \PHPExif\Mapper\Native::mapRawData
212212
*/
213-
public function testMapRawDataMacthesFieldsWithoutCaseSensibilityOnFirstLetter()
213+
public function testMapRawDataMatchesFieldsWithoutCaseSensibilityOnFirstLetter()
214214
{
215215
$rawData = array(
216216
\PHPExif\Mapper\Native::ORIENTATION => 'Portrait',

0 commit comments

Comments
 (0)