2828class Exiftool extends AdapterAbstract
2929{
3030 const TOOL_NAME = 'exiftool ' ;
31-
31+
3232 /**
3333 * Path to the exiftool binary
3434 *
3535 * @var string
3636 */
3737 protected $ toolPath ;
3838
39+ /**
40+ * @var boolean
41+ */
42+ protected $ numeric = true ;
43+
3944 /**
4045 * Setter for the exiftool binary path
4146 *
@@ -58,6 +63,14 @@ public function setToolPath($path)
5863
5964 return $ this ;
6065 }
66+
67+ /**
68+ * @param boolean $numeric
69+ */
70+ public function setNumeric ($ numeric )
71+ {
72+ $ this ->numeric = $ numeric ;
73+ }
6174
6275 /**
6376 * Getter for the exiftool binary path
@@ -86,9 +99,10 @@ public function getExifFromFile($file)
8699 {
87100 $ result = $ this ->getCliOutput (
88101 sprintf (
89- '%1$s -j %2$s ' ,
102+ '%1$s%3$s -j %2$s ' ,
90103 $ this ->getToolPath (),
91- $ file
104+ $ file ,
105+ $ this ->numeric ? ' -n ' : ''
92106 )
93107 );
94108
@@ -145,6 +159,13 @@ public function mapData(array $source)
145159 $ focalLengthParts = explode (' ' , $ source ['FocalLength ' ]);
146160 $ focalLength = (int ) reset ($ focalLengthParts );
147161 }
162+
163+ $ exposureTime = false ;
164+ if (isset ($ source ['ExposureTime ' ])) {
165+ $ exposureTime = '1/ ' . round (1 / $ source ['ExposureTime ' ]);
166+ }
167+
168+ //var_dump($source);
148169
149170 return array (
150171 Exif::APERTURE => (!isset ($ source ['Aperture ' ])) ? false : sprintf ('f/%01.1f ' , $ source ['Aperture ' ]),
@@ -155,7 +176,7 @@ public function mapData(array $source)
155176 Exif::COPYRIGHT => false ,
156177 Exif::CREATION_DATE => (!isset ($ source ['CreateDate ' ])) ? false : DateTime::createFromFormat ('Y:m:d H:i:s ' , $ source ['CreateDate ' ]),
157178 Exif::CREDIT => false ,
158- Exif::EXPOSURE => (! isset ( $ source [ ' ShutterSpeed ' ])) ? false : $ source [ ' ShutterSpeed ' ] ,
179+ Exif::EXPOSURE => $ exposureTime ,
159180 Exif::FILESIZE => false ,
160181 Exif::FOCAL_LENGTH => $ focalLength ,
161182 Exif::FOCAL_DISTANCE => (!isset ($ source ['ApproximateFocusDistance ' ])) ? false : sprintf ('%1$sm ' , $ source ['ApproximateFocusDistance ' ]),
@@ -165,7 +186,7 @@ public function mapData(array $source)
165186 Exif::ISO => (!isset ($ source ['ISO ' ])) ? false : $ source ['ISO ' ],
166187 Exif::JOB_TITLE => false ,
167188 Exif::KEYWORDS => (!isset ($ source ['Keywords ' ])) ? false : $ source ['Keywords ' ],
168- Exif::MIMETYPE => false ,
189+ Exif::MIMETYPE => (! isset ( $ source [ ' MIMEType ' ])) ? false : $ source [ ' MIMEType ' ] ,
169190 Exif::ORIENTATION => (!isset ($ source ['Orientation ' ])) ? false : $ source ['Orientation ' ],
170191 Exif::SOFTWARE => (!isset ($ source ['Software ' ])) ? false : $ source ['Software ' ],
171192 Exif::SOURCE => false ,
0 commit comments