Skip to content

Commit 5279727

Browse files
author
Peter Frivalszky
committed
Checking Exiftool output against UTF-8 encoding more elegantly
1 parent 002d07f commit 5279727

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/PHPExif/Adapter/Exiftool.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,15 @@ public function getExifFromFile($file)
110110
)
111111
);
112112

113-
$data = json_decode(utf8_encode($result), true);
113+
if (!mb_check_encoding($result, "utf-8")) {
114+
$result = utf8_encode($result);
115+
}
116+
$data = json_decode($result, true);
117+
if (!is_array($data)) {
118+
throw new RuntimeException(
119+
'Could not decode exiftool output'
120+
);
121+
}
114122

115123
// map the data:
116124
$mapper = $this->getMapper();

0 commit comments

Comments
 (0)