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,30 +159,42 @@ 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+ $ caption = false ;
169+ if (isset ($ source ['Caption ' ])) {
170+ $ caption = $ source ['Caption ' ];
171+ } elseif (isset ($ source ['Caption-Abstract ' ])) {
172+ $ caption = $ source ['Caption-Abstract ' ];
173+ }
148174
149175 return array (
150176 Exif::APERTURE => (!isset ($ source ['Aperture ' ])) ? false : sprintf ('f/%01.1f ' , $ source ['Aperture ' ]),
151- Exif::AUTHOR => false ,
177+ Exif::AUTHOR => (! isset ( $ source [ ' Artist ' ])) ? false : $ source [ ' Artist ' ] ,
152178 Exif::CAMERA => (!isset ($ source ['Model ' ])) ? false : $ source ['Model ' ],
153- Exif::CAPTION => false ,
179+ Exif::CAPTION => $ caption ,
154180 Exif::COLORSPACE => (!isset ($ source [Exif::COLORSPACE ]) ? false : $ source [Exif::COLORSPACE ]),
155- Exif::COPYRIGHT => false ,
181+ Exif::COPYRIGHT => (! isset ( $ source [ ' Copyright ' ])) ? false : $ source [ ' Copyright ' ] ,
156182 Exif::CREATION_DATE => (!isset ($ source ['CreateDate ' ])) ? false : DateTime::createFromFormat ('Y:m:d H:i:s ' , $ source ['CreateDate ' ]),
157- Exif::CREDIT => false ,
158- Exif::EXPOSURE => (! isset ( $ source [ ' ShutterSpeed ' ])) ? false : $ source [ ' ShutterSpeed ' ] ,
159- Exif::FILESIZE => false ,
183+ Exif::CREDIT => (! isset ( $ source [ ' Credit ' ])) ? false : $ source [ ' Credit ' ] ,
184+ Exif::EXPOSURE => $ exposureTime ,
185+ Exif::FILESIZE => (! isset ( $ source [Exif:: FILESIZE ]) ? false : $ source [Exif:: FILESIZE ]) ,
160186 Exif::FOCAL_LENGTH => $ focalLength ,
161187 Exif::FOCAL_DISTANCE => (!isset ($ source ['ApproximateFocusDistance ' ])) ? false : sprintf ('%1$sm ' , $ source ['ApproximateFocusDistance ' ]),
162- Exif::HEADLINE => false ,
188+ Exif::HEADLINE => (! isset ( $ source [ ' Headline ' ])) ? false : $ source [ ' Headline ' ] ,
163189 Exif::HEIGHT => (!isset ($ source ['ImageHeight ' ])) ? false : $ source ['ImageHeight ' ],
164190 Exif::HORIZONTAL_RESOLUTION => (!isset ($ source ['XResolution ' ])) ? false : $ source ['XResolution ' ],
165191 Exif::ISO => (!isset ($ source ['ISO ' ])) ? false : $ source ['ISO ' ],
166- Exif::JOB_TITLE => false ,
192+ Exif::JOB_TITLE => (! isset ( $ source [ ' JobTitle ' ])) ? false : $ source [ ' JobTitle ' ] ,
167193 Exif::KEYWORDS => (!isset ($ source ['Keywords ' ])) ? false : $ source ['Keywords ' ],
168- Exif::MIMETYPE => false ,
194+ Exif::MIMETYPE => (! isset ( $ source [ ' MIMEType ' ])) ? false : $ source [ ' MIMEType ' ] ,
169195 Exif::ORIENTATION => (!isset ($ source ['Orientation ' ])) ? false : $ source ['Orientation ' ],
170196 Exif::SOFTWARE => (!isset ($ source ['Software ' ])) ? false : $ source ['Software ' ],
171- Exif::SOURCE => false ,
197+ Exif::SOURCE => (! isset ( $ source [ ' Source ' ])) ? false : $ source [ ' Source ' ] ,
172198 Exif::TITLE => (!isset ($ source ['Title ' ])) ? false : $ source ['Title ' ],
173199 Exif::VERTICAL_RESOLUTION => (!isset ($ source ['YResolution ' ])) ? false : $ source ['YResolution ' ],
174200 Exif::WIDTH => (!isset ($ source ['ImageWidth ' ])) ? false : $ source ['ImageWidth ' ],
0 commit comments