Skip to content

Commit 36c5dcf

Browse files
author
Peter Frivalszky
committed
exiftool encoding
1 parent b7dbf93 commit 36c5dcf

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

lib/PHPExif/Adapter/Exiftool.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class Exiftool extends AdapterAbstract
3939
*/
4040
protected $numeric = true;
4141

42+
/**
43+
* @var array
44+
*/
45+
protected $encoding = [];
46+
4247
/**
4348
* @var string
4449
*/
@@ -75,6 +80,15 @@ public function setNumeric($numeric)
7580
$this->numeric = $numeric;
7681
}
7782

83+
/**
84+
* @see http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html#Q10
85+
* @param string $type the TYPE from -charset TYPE=CHARSET
86+
* @param string $encoding the CHARSET from -charset TYPE=CHARSET
87+
*/
88+
public function setEncoding($type, $encoding) {
89+
$this->encoding[$type] = $encoding;
90+
}
91+
7892
/**
7993
* Getter for the exiftool binary path
8094
* Lazy loads the "default" path
@@ -100,13 +114,21 @@ public function getToolPath()
100114
*/
101115
public function getExifFromFile($file)
102116
{
117+
$encoding = '';
118+
if(!empty($this->encoding)) {
119+
$encoding = '-charset ';
120+
foreach ($this->encoding as $key => $value) {
121+
$encoding .= escapeshellarg($key).'='.escapeshellarg($value);
122+
}
123+
}
103124
$result = $this->getCliOutput(
104125
sprintf(
105-
'%1$s%3$s -j -a -G1 -c %4$s %2$s',
126+
'%1$s%3$s -j -a -G1 %5$s -c %4$s %2$s',
106127
$this->getToolPath(),
107128
escapeshellarg($file),
108129
$this->numeric ? ' -n' : '',
109-
escapeshellarg('%d deg %d\' %.4f"')
130+
escapeshellarg('%d deg %d\' %.4f"'),
131+
$encoding
110132
)
111133
);
112134

0 commit comments

Comments
 (0)