2222 */
2323class Exif
2424{
25- const SECTION_FILE = 'FILE ' ;
26- const SECTION_COMPUTED = 'COMPUTED ' ;
27- const SECTION_IFD0 = 'IFD0 ' ;
28- const SECTION_THUMBNAIL = 'THUMBNAIL ' ;
29- const SECTION_COMMENT = 'COMMENT ' ;
30- const SECTION_EXIF = 'EXIF ' ;
31- const SECTION_ALL = 'ANY_TAG ' ;
32- const SECTION_IPTC = 'IPTC ' ;
25+ const APERTURE = 'aperture ' ;
26+ const AUTHOR = 'author ' ;
27+ const CAMERA = 'camera ' ;
28+ const CAPTION = 'caption ' ;
29+ const COPYRIGHT = 'copyright ' ;
30+ const CREATION_DATE = 'creationdate ' ;
31+ const CREDIT = 'credit ' ;
32+ const EXPOSURE = 'exposure ' ;
33+ const FOCAL_LENGTH = 'focalLength ' ;
34+ const FOCAL_DISTANCE = 'focalDistance ' ;
35+ const HEADLINE = 'headline ' ;
36+ const HEIGHT = 'height ' ;
37+ const HORIZONTAL_RESOLUTION = 'horizontalResolution ' ;
38+ const ISO = 'iso ' ;
39+ const JOB_TITLE = 'jobTitle ' ;
40+ const KEYWORDS = 'keywords ' ;
41+ const SOFTWARE = 'software ' ;
42+ const SOURCE = 'source ' ;
43+ const TITLE = 'title ' ;
44+ const VERTICAL_RESOLUTION = 'verticalResolution ' ;
45+ const WIDTH = 'width ' ;
3346
3447 /**
3548 * The EXIF data
@@ -78,11 +91,11 @@ public function getRawData()
7891 */
7992 public function getAperture ()
8093 {
81- if (!isset ($ this ->data [self ::SECTION_COMPUTED ][ ' ApertureFNumber ' ])) {
94+ if (!isset ($ this ->data [self ::APERTURE ])) {
8295 return false ;
8396 }
8497
85- return $ this ->data [self ::SECTION_COMPUTED ][ ' ApertureFNumber ' ];
98+ return $ this ->data [self ::APERTURE ];
8699 }
87100
88101 /**
@@ -92,11 +105,11 @@ public function getAperture()
92105 */
93106 public function getAuthor ()
94107 {
95- if (!isset ($ this ->data [' Artist ' ])) {
108+ if (!isset ($ this ->data [self :: AUTHOR ])) {
96109 return false ;
97110 }
98111
99- return $ this ->data [' Artist ' ];
112+ return $ this ->data [self :: AUTHOR ];
100113 }
101114
102115 /**
@@ -106,11 +119,11 @@ public function getAuthor()
106119 */
107120 public function getHeadline ()
108121 {
109- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' headline ' ])) {
122+ if (!isset ($ this ->data [self ::HEADLINE ])) {
110123 return false ;
111124 }
112125
113- return $ this ->data [self ::SECTION_IPTC ][ ' headline ' ];
126+ return $ this ->data [self ::HEADLINE ];
114127 }
115128
116129 /**
@@ -120,11 +133,11 @@ public function getHeadline()
120133 */
121134 public function getCredit ()
122135 {
123- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' credit ' ])) {
136+ if (!isset ($ this ->data [self ::CREDIT ])) {
124137 return false ;
125138 }
126139
127- return $ this ->data [self ::SECTION_IPTC ][ ' credit ' ];
140+ return $ this ->data [self ::CREDIT ];
128141 }
129142
130143 /**
@@ -134,11 +147,11 @@ public function getCredit()
134147 */
135148 public function getSource ()
136149 {
137- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' source ' ])) {
150+ if (!isset ($ this ->data [self ::SOURCE ])) {
138151 return false ;
139152 }
140153
141- return $ this ->data [self ::SECTION_IPTC ][ ' source ' ];
154+ return $ this ->data [self ::SOURCE ];
142155 }
143156
144157 /**
@@ -148,11 +161,11 @@ public function getSource()
148161 */
149162 public function getJobtitle ()
150163 {
151- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' jobtitle ' ])) {
164+ if (!isset ($ this ->data [self ::JOB_TITLE ])) {
152165 return false ;
153166 }
154167
155- return $ this ->data [self ::SECTION_IPTC ][ ' jobtitle ' ];
168+ return $ this ->data [self ::JOB_TITLE ];
156169 }
157170
158171 /**
@@ -162,11 +175,11 @@ public function getJobtitle()
162175 */
163176 public function getIso ()
164177 {
165- if (!isset ($ this ->data [' ISOSpeedRatings ' ])) {
178+ if (!isset ($ this ->data [self :: ISO ])) {
166179 return false ;
167180 }
168181
169- return $ this ->data [' ISOSpeedRatings ' ];
182+ return $ this ->data [self :: ISO ];
170183 }
171184
172185 /**
@@ -176,11 +189,11 @@ public function getIso()
176189 */
177190 public function getExposure ()
178191 {
179- if (!isset ($ this ->data [' ExposureTime ' ])) {
192+ if (!isset ($ this ->data [self :: EXPOSURE ])) {
180193 return false ;
181194 }
182195
183- return $ this ->data [' ExposureTime ' ];
196+ return $ this ->data [self :: EXPOSURE ];
184197 }
185198
186199 /**
@@ -190,11 +203,11 @@ public function getExposure()
190203 */
191204 public function getExposureMilliseconds ()
192205 {
193- if (!isset ($ this ->data [' ExposureTime ' ])) {
206+ if (!isset ($ this ->data [self :: EXPOSURE ])) {
194207 return false ;
195208 }
196209
197- $ exposureParts = explode ('/ ' , $ this ->data [' ExposureTime ' ]);
210+ $ exposureParts = explode ('/ ' , $ this ->data [self :: EXPOSURE ]);
198211
199212 return (int )reset ($ exposureParts ) / (int )end ($ exposureParts );
200213 }
@@ -206,11 +219,11 @@ public function getExposureMilliseconds()
206219 */
207220 public function getFocusDistance ()
208221 {
209- if (!isset ($ this ->data [self ::SECTION_COMPUTED ][ ' FocusDistance ' ])) {
222+ if (!isset ($ this ->data [self ::FOCAL_DISTANCE ])) {
210223 return false ;
211224 }
212225
213- return $ this ->data [self ::SECTION_COMPUTED ][ ' FocusDistance ' ];
226+ return $ this ->data [self ::FOCAL_DISTANCE ];
214227 }
215228
216229 /**
@@ -220,11 +233,11 @@ public function getFocusDistance()
220233 */
221234 public function getWidth ()
222235 {
223- if (!isset ($ this ->data [self ::SECTION_COMPUTED ][ ' Width ' ])) {
236+ if (!isset ($ this ->data [self ::WIDTH ])) {
224237 return false ;
225238 }
226239
227- return $ this ->data [self ::SECTION_COMPUTED ][ ' Width ' ];
240+ return $ this ->data [self ::WIDTH ];
228241 }
229242
230243 /**
@@ -234,11 +247,11 @@ public function getWidth()
234247 */
235248 public function getHeight ()
236249 {
237- if (!isset ($ this ->data [self ::SECTION_COMPUTED ][ ' Height ' ])) {
250+ if (!isset ($ this ->data [self ::HEIGHT ])) {
238251 return false ;
239252 }
240253
241- return $ this ->data [self ::SECTION_COMPUTED ][ ' Height ' ];
254+ return $ this ->data [self ::HEIGHT ];
242255 }
243256
244257 /**
@@ -248,11 +261,11 @@ public function getHeight()
248261 */
249262 public function getTitle ()
250263 {
251- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' title ' ])) {
264+ if (!isset ($ this ->data [self ::TITLE ])) {
252265 return false ;
253266 }
254267
255- return $ this ->data [self ::SECTION_IPTC ][ ' title ' ];
268+ return $ this ->data [self ::TITLE ];
256269 }
257270
258271 /**
@@ -262,11 +275,11 @@ public function getTitle()
262275 */
263276 public function getCaption ()
264277 {
265- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' caption ' ])) {
278+ if (!isset ($ this ->data [self ::CAPTION ])) {
266279 return false ;
267280 }
268281
269- return $ this ->data [self ::SECTION_IPTC ][ ' caption ' ];
282+ return $ this ->data [self ::CAPTION ];
270283 }
271284
272285 /**
@@ -276,11 +289,11 @@ public function getCaption()
276289 */
277290 public function getCopyright ()
278291 {
279- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' copyright ' ])) {
292+ if (!isset ($ this ->data [self ::COPYRIGHT ])) {
280293 return false ;
281294 }
282295
283- return $ this ->data [self ::SECTION_IPTC ][ ' copyright ' ];
296+ return $ this ->data [self ::COPYRIGHT ];
284297 }
285298
286299 /**
@@ -290,11 +303,11 @@ public function getCopyright()
290303 */
291304 public function getKeywords ()
292305 {
293- if (!isset ($ this ->data [self ::SECTION_IPTC ][ ' keywords ' ])) {
306+ if (!isset ($ this ->data [self ::KEYWORDS ])) {
294307 return false ;
295308 }
296309
297- return $ this ->data [self ::SECTION_IPTC ][ ' keywords ' ];
310+ return $ this ->data [self ::KEYWORDS ];
298311 }
299312
300313 /**
@@ -304,11 +317,11 @@ public function getKeywords()
304317 */
305318 public function getCamera ()
306319 {
307- if (!isset ($ this ->data [' Model ' ])) {
320+ if (!isset ($ this ->data [self :: CAMERA ])) {
308321 return false ;
309322 }
310323
311- return $ this ->data [' Model ' ];
324+ return $ this ->data [self :: CAMERA ];
312325 }
313326
314327 /**
@@ -318,12 +331,11 @@ public function getCamera()
318331 */
319332 public function getHorizontalResolution ()
320333 {
321- if (!isset ($ this ->data [' XResolution ' ])) {
334+ if (!isset ($ this ->data [self :: HORIZONTAL_RESOLUTION ])) {
322335 return false ;
323336 }
324337
325- $ resolutionParts = explode ('/ ' , $ this ->data ['XResolution ' ]);
326- return (int )reset ($ resolutionParts );
338+ return $ this ->data [self ::HORIZONTAL_RESOLUTION ];
327339 }
328340
329341 /**
@@ -333,12 +345,11 @@ public function getHorizontalResolution()
333345 */
334346 public function getVerticalResolution ()
335347 {
336- if (!isset ($ this ->data [' YResolution ' ])) {
348+ if (!isset ($ this ->data [self :: VERTICAL_RESOLUTION ])) {
337349 return false ;
338350 }
339351
340- $ resolutionParts = explode ('/ ' , $ this ->data ['YResolution ' ]);
341- return (int )reset ($ resolutionParts );
352+ return $ this ->data [self ::VERTICAL_RESOLUTION ];
342353 }
343354
344355 /**
@@ -348,11 +359,11 @@ public function getVerticalResolution()
348359 */
349360 public function getSoftware ()
350361 {
351- if (!isset ($ this ->data [' Software ' ])) {
362+ if (!isset ($ this ->data [self :: SOFTWARE ])) {
352363 return false ;
353364 }
354365
355- return $ this ->data [' Software ' ];
366+ return $ this ->data [self :: SOFTWARE ];
356367 }
357368
358369 /**
@@ -362,12 +373,11 @@ public function getSoftware()
362373 */
363374 public function getFocalLength ()
364375 {
365- if (!isset ($ this ->data [' FocalLength ' ])) {
376+ if (!isset ($ this ->data [self :: FOCAL_LENGTH ])) {
366377 return false ;
367378 }
368379
369- $ parts = explode ('/ ' , $ this ->data ['FocalLength ' ]);
370- return (int )reset ($ parts ) / (int )end ($ parts );
380+ return $ this ->data [self ::FOCAL_LENGTH ];
371381 }
372382
373383 /**
@@ -377,12 +387,10 @@ public function getFocalLength()
377387 */
378388 public function getCreationDate ()
379389 {
380- if (!isset ($ this ->data [' DateTimeOriginal ' ])) {
390+ if (!isset ($ this ->data [self :: CREATION_DATE ])) {
381391 return false ;
382392 }
383393
384- $ dt = \DateTime::createFromFormat ('Y:m:d H:i:s ' , $ this ->data ['DateTimeOriginal ' ]);
385-
386- return $ dt ;
394+ return $ this ->data [self ::CREATION_DATE ];
387395 }
388396}
0 commit comments