Subversion Repositories eFlore/Applications.cel

Rev

Rev 994 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 994 Rev 1155
Line 1... Line 1...
1
<?php
1
<?php
2
/**
2
/**
3
 * Classe d'extraction de metadonnées afin de les mettre dans 
3
 * Classe d'extraction de metadonnées afin de les mettre dans
4
 * un tableau au format du cel
4
 * un tableau au format du cel
5
 * Encodage en entrée : utf8
5
 * Encodage en entrée : utf8
6
 * Encodage en sortie : utf8
6
 * Encodage en sortie : utf8
7
 *
7
 *
8
 * @author Aurélien PERONNET <aurelien@tela-botanica.org>
8
 * @author Aurélien PERONNET <aurelien@tela-botanica.org>
-
 
9
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
10
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
10
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
11
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
11
 * @version $Id$
12
 * @version $Id$
-
 
13
 * @copyright © 2012, Tela Botanica
12
 */
14
 */
13
class ExtracteurMetadonnees {
15
class ExtracteurMetadonnees {
Line -... Line 16...
-
 
16
 
14
 
17
	private $meta = array();
-
 
18
	private $tableau_ids_tags_exif = array(
-
 
19
			'InteropIndex' => '1',
-
 
20
			'InteropVersion' => '2',
-
 
21
			'ProcessingSoftware' => '11',
-
 
22
			'SubfileType' => '254',
-
 
23
			'OldSubfileType' => '255',
-
 
24
			'ImageWidth' => '256',
-
 
25
			'ImageHeight' => '257',
-
 
26
			'BitsPerSample' => '258',
-
 
27
			'Compression' => '259',
-
 
28
			'PhotometricInterpretation' => '262',
-
 
29
			'Thresholding' => '263',
-
 
30
			'CellWidth' => '264',
-
 
31
			'CellLength' => '265',
-
 
32
			'FillOrder' => '266',
-
 
33
			'DocumentName' => '269',
15
	 public function extraireMetadonnees($chemin_fichier)
34
			'ImageDescription' => '270',
-
 
35
			'Make' => '271',
-
 
36
			'Model' => '272',
-
 
37
			'StripOffsets' => '273',
-
 
38
			'Orientation' => '274',
-
 
39
			'SamplesPerPixel' => '277',
-
 
40
			'RowsPerStrip' => '278',
-
 
41
			'StripByteCounts' => '279',
-
 
42
			'MinSampleValue' => '280',
-
 
43
			'MaxSampleValue' => '281',
-
 
44
			'XResolution' => '282',
-
 
45
			'YResolution' => '283',
-
 
46
			'PlanarConfiguration' => '284',
-
 
47
			'PageName' => '285',
-
 
48
			'XPosition' => '286',
-
 
49
			'YPosition' => '287',
-
 
50
			'FreeOffsets' => '288',
-
 
51
			'FreeByteCounts' => '289',
-
 
52
			'GrayResponseUnit' => '290',
-
 
53
			'GrayResponseCurve' => '291',
-
 
54
			'T4Options' => '292',
-
 
55
			'T6Options' => '293',
-
 
56
			'ResolutionUnit' => '296',
-
 
57
			'PageNumber' => '297',
-
 
58
			'ColorResponseUnit' => '300',
-
 
59
			'TransferFunction' => '301',
-
 
60
			'Software' => '305',
-
 
61
			'ModifyDate' => '306',
-
 
62
			'Artist' => '315',
-
 
63
			'HostComputer' => '316',
-
 
64
			'Predictor' => '317',
-
 
65
			'WhitePoint' => '318',
-
 
66
			'PrimaryChromaticities' => '319',
-
 
67
			'ColorMap' => '320',
-
 
68
			'HalftoneHints' => '321',
-
 
69
			'TileWidth' => '322',
-
 
70
			'TileLength' => '323',
-
 
71
			'TileOffsets' => '324',
-
 
72
			'TileByteCounts' => '325',
-
 
73
			'BadFaxLines' => '326',
16
	 {	
74
			'CleanFaxData' => '327',
-
 
75
			'ConsecutiveBadFaxLines' => '328',
17
	 	$metadonnees = $this->decoderMetaDonnees($chemin_fichier); 	
76
			'SubIFD' => '330',
-
 
77
			'InkSet' => '332',
-
 
78
			'InkNames' => '333',
-
 
79
			'NumberofInks' => '334',
-
 
80
			'DotRange' => '336',
-
 
81
			'TargetPrinter' => '337',
-
 
82
			'ExtraSamples' => '338',
-
 
83
			'SampleFormat' => '339',
-
 
84
			'SMinSampleValue' => '340',
-
 
85
			'SMaxSampleValue' => '341',
-
 
86
			'TransferRange' => '342',
-
 
87
			'ClipPath' => '343',
-
 
88
			'XClipPathUnits' => '344',
-
 
89
			'YClipPathUnits' => '345',
-
 
90
			'Indexed' => '346',
-
 
91
			'JPEGTables' => '347',
-
 
92
			'OPIProxy' => '351',
-
 
93
			'GlobalParametersIFD' => '400',
-
 
94
			'ProfileType' => '401',
-
 
95
			'FaxProfile' => '402',
-
 
96
			'CodingMethods' => '403',
-
 
97
			'VersionYear' => '404',
-
 
98
			'ModeNumber' => '405',
-
 
99
			'Decode' => '433',
-
 
100
			'DefaultImageColor' => '434',
-
 
101
			'T82Options' => '435',
-
 
102
			'JPEGTables' => '437',
-
 
103
			'JPEGProc' => '512',
-
 
104
			'ThumbnailOffset' => '513',
-
 
105
			'ThumbnailLength' => '514',
-
 
106
			'JPEGRestartInterval' => '515',
-
 
107
			'JPEGLosslessPredictors' => '517',
-
 
108
			'JPEGPointTransforms' => '518',
-
 
109
			'JPEGQTables' => '519',
-
 
110
			'JPEGDCTables' => '520',
-
 
111
			'JPEGACTables' => '521',
-
 
112
			'YCbCrCoefficients' => '529',
-
 
113
			'YCbCrSubSampling' => '530',
-
 
114
			'YCbCrPositioning' => '531',
-
 
115
			'ReferenceBlackWhite' => '532',
-
 
116
			'StripRowCounts' => '559',
-
 
117
			'ApplicationNotes' => '700',
-
 
118
			'USPTOMiscellaneous' => '999',
-
 
119
			'RelatedImageFileFormat' => '4096',
-
 
120
			'RelatedImageWidth' => '4097',
-
 
121
			'RelatedImageHeight' => '4098',
-
 
122
			'Rating' => '18246',
-
 
123
			'XP_DIP_XML' => '18247',
-
 
124
			'StitchInfo' => '18248',
-
 
125
			'RatingPercent' => '18249',
-
 
126
			'ImageID' => '32781',
-
 
127
			'WangTag1' => '32931',
-
 
128
			'WangAnnotation' => '32932',
-
 
129
			'WangTag3' => '32933',
-
 
130
			'WangTag4' => '32934',
-
 
131
			'Matteing' => '32995',
-
 
132
			'DataType' => '32996',
-
 
133
			'ImageDepth' => '32997',
-
 
134
			'TileDepth' => '32998',
-
 
135
			'Model2' => '33405',
-
 
136
			'CFARepeatPatternDim' => '33421',
-
 
137
			'CFAPattern2' => '33422',
-
 
138
			'BatteryLevel' => '33423',
-
 
139
			'KodakIFD' => '33424',
-
 
140
			'Copyright' => '33432',
-
 
141
			'ExposureTime' => '33434',
-
 
142
			'FNumber' => '33437',
-
 
143
			'MDFileTag' => '33445',
-
 
144
			'MDScalePixel' => '33446',
-
 
145
			'MDColorTable' => '33447',
-
 
146
			'MDLabName' => '33448',
-
 
147
			'MDSampleInfo' => '33449',
-
 
148
			'MDPrepDate' => '33450',
-
 
149
			'MDPrepTime' => '33451',
-
 
150
			'MDFileUnits' => '33452',
-
 
151
			'PixelScale' => '33550',
-
 
152
			'AdventScale' => '33589',
-
 
153
			'AdventRevision' => '33590',
-
 
154
			'UIC1Tag' => '33628',
-
 
155
			'UIC2Tag' => '33629',
-
 
156
			'UIC3Tag' => '33630',
-
 
157
			'UIC4Tag' => '33631',
-
 
158
			'IPTC-NAA' => '33723',
-
 
159
			'IntergraphPacketData' => '33918',
-
 
160
			'IntergraphFlagRegisters' => '33919',
-
 
161
			'IntergraphMatrix' => '33920',
-
 
162
			'INGRReserved' => '33921',
-
 
163
			'ModelTiePoint' => '33922',
-
 
164
			'Site' => '34016',
-
 
165
			'ColorSequence' => '34017',
-
 
166
			'IT8Header' => '34018',
-
 
167
			'RasterPadding' => '34019',
-
 
168
			'BitsPerRunLength' => '34020',
-
 
169
			'BitsPerExtendedRunLength' => '34021',
-
 
170
			'ColorTable' => '34022',
-
 
171
			'ImageColorIndicator' => '34023',
-
 
172
			'BackgroundColorIndicator' => '34024',
-
 
173
			'ImageColorValue' => '34025',
-
 
174
			'BackgroundColorValue' => '34026',
-
 
175
			'PixelIntensityRange' => '34027',
-
 
176
			'TransparencyIndicator' => '34028',
-
 
177
			'ColorCharacterization' => '34029',
-
 
178
			'HCUsage' => '34030',
-
 
179
			'TrapIndicator' => '34031',
-
 
180
			'CMYKEquivalent' => '34032',
-
 
181
			'SEMInfo' => '34118',
-
 
182
			'AFCP_IPTC' => '34152',
-
 
183
			'PixelMagicJBIGOptions' => '34232',
-
 
184
			'ModelTransform' => '34264',
-
 
185
			'WB_GRGBLevels' => '34306',
-
 
186
			'LeafData' => '34310',
-
 
187
			'PhotoshopSettings' => '34377',
-
 
188
			'ExifOffset' => '34665',
-
 
189
			'ICC_Profile' => '34675',
-
 
190
			'TIFF_FXExtensions' => '34687',
-
 
191
			'MultiProfiles' => '34688',
-
 
192
			'SharedData' => '34689',
-
 
193
			'T88Options' => '34690',
-
 
194
			'ImageLayer' => '34732',
-
 
195
			'GeoTiffDirectory' => '34735',
-
 
196
			'GeoTiffDoubleParams' => '34736',
-
 
197
			'GeoTiffAsciiParams' => '34737',
-
 
198
			'ExposureProgram' => '34850',
-
 
199
			'SpectralSensitivity' => '34852',
18
		return $metadonnees ;
200
			'GPSInfo' => '34853',
19
	 }
-
 
-
 
201
			'ISO' => '34855',
-
 
202
			'Opto-ElectricConvFactor' => '34856',
-
 
203
			'Interlace' => '34857',
-
 
204
			'TimeZoneOffset' => '34858',
-
 
205
			'SelfTimerMode' => '34859',
-
 
206
			'SensitivityType' => '34864',
-
 
207
			'StandardOutputSensitivity' => '34865',
-
 
208
			'RecommendedExposureIndex' => '34866',
-
 
209
			'ISOSpeed' => '34867',
-
 
210
			'ISOSpeedLatitudeyyy' => '34868',
-
 
211
			'ISOSpeedLatitudezzz' => '34869',
-
 
212
			'FaxRecvParams' => '34908',
-
 
213
			'FaxSubAddress' => '34909',
-
 
214
			'FaxRecvTime' => '34910',
-
 
215
			'LeafSubIFD' => '34954',
-
 
216
			'ExifVersion' => '36864',
-
 
217
			'DateTimeOriginal' => '36867',
20
	 
218
			'CreateDate' => '36868',
-
 
219
			'ComponentsConfiguration' => '37121',
-
 
220
			'CompressedBitsPerPixel' => '37122',
-
 
221
			'ShutterSpeedValue' => '37377',
-
 
222
			'ApertureValue' => '37378',
-
 
223
			'BrightnessValue' => '37379',
-
 
224
			'ExposureCompensation' => '37380',
-
 
225
			'MaxApertureValue' => '37381',
-
 
226
			'SubjectDistance' => '37382',
-
 
227
			'MeteringMode' => '37383',
-
 
228
			'LightSource' => '37384',
-
 
229
			'Flash' => '37385',
-
 
230
			'FocalLength' => '37386',
-
 
231
			'FlashEnergy' => '37387',
-
 
232
			'SpatialFrequencyResponse' => '37388',
-
 
233
			'Noise' => '37389',
-
 
234
			'FocalPlaneXResolution' => '37390',
-
 
235
			'FocalPlaneYResolution' => '37391',
-
 
236
			'FocalPlaneResolutionUnit' => '37392',
-
 
237
			'ImageNumber' => '37393',
-
 
238
			'SecurityClassification' => '37394',
-
 
239
			'ImageHistory' => '37395',
-
 
240
			'SubjectArea' => '37396',
-
 
241
			'ExposureIndex' => '37397',
-
 
242
			'TIFF-EPStandardID' => '37398',
-
 
243
			'SensingMethod' => '37399',
-
 
244
			'CIP3DataFile' => '37434',
-
 
245
			'CIP3Sheet' => '37435',
-
 
246
			'CIP3Side' => '37436',
-
 
247
			'StoNits' => '37439',
-
 
248
			'MakerNoteCanon' => '37500',
-
 
249
			'UserComment' => '37510',
-
 
250
			'SubSecTime' => '37520',
-
 
251
			'SubSecTimeOriginal' => '37521',
-
 
252
			'SubSecTimeDigitized' => '37522',
-
 
253
			'MSDocumentText' => '37679',
-
 
254
			'MSPropertySetStorage' => '37680',
-
 
255
			'MSDocumentTextPosition' => '37681',
-
 
256
			'ImageSourceData' => '37724',
-
 
257
			'XPTitle' => '40091',
-
 
258
			'XPComment' => '40092',
-
 
259
			'XPAuthor' => '40093',
-
 
260
			'XPKeywords' => '40094',
-
 
261
			'XPSubject' => '40095',
-
 
262
			'FlashpixVersion' => '40960',
-
 
263
			'ColorSpace' => '40961',
-
 
264
			'ExifImageWidth' => '40962',
-
 
265
			'ExifImageHeight' => '40963',
-
 
266
			'RelatedSoundFile' => '40964',
-
 
267
			'InteropOffset' => '40965',
21
	private function peutUtiliserExifTool() {
268
			'FlashEnergy' => '41483',
-
 
269
			'SpatialFrequencyResponse' => '41484',
-
 
270
			'Noise' => '41485',
-
 
271
			'FocalPlaneXResolution' => '41486',
-
 
272
			'FocalPlaneYResolution' => '41487',
-
 
273
			'FocalPlaneResolutionUnit' => '41488',
-
 
274
			'ImageNumber' => '41489',
-
 
275
			'SecurityClassification' => '41490',
-
 
276
			'ImageHistory' => '41491',
-
 
277
			'SubjectLocation' => '41492',
-
 
278
			'ExposureIndex' => '41493',
-
 
279
			'TIFF-EPStandardID' => '41494',
-
 
280
			'SensingMethod' => '41495',
-
 
281
			'FileSource' => '41728',
-
 
282
			'SceneType' => '41729',
-
 
283
			'CFAPattern' => '41730',
-
 
284
			'CustomRendered' => '41985',
-
 
285
			'ExposureMode' => '41986',
-
 
286
			'WhiteBalance' => '41987',
-
 
287
			'DigitalZoomRatio' => '41988',
-
 
288
			'FocalLengthIn35mmFormat' => '41989',
-
 
289
			'SceneCaptureType' => '41990',
-
 
290
			'GainControl' => '41991',
-
 
291
			'Contrast' => '41992',
-
 
292
			'Saturation' => '41993',
22
		// TODO indiquer ceci dans un fichier de config
293
			'Sharpness' => '41994',
-
 
294
			'DeviceSettingDescription' => '41995',
-
 
295
			'SubjectDistanceRange' => '41996',
-
 
296
			'ImageUniqueID' => '42016',
-
 
297
			'OwnerName' => '42032',
-
 
298
			'SerialNumber' => '42033',
-
 
299
			'LensInfo' => '42034',
-
 
300
			'LensMake' => '42035',
-
 
301
			'LensModel' => '42036',
-
 
302
			'LensSerialNumber' => '42037',
-
 
303
			'GDALMetadata' => '42112',
-
 
304
			'GDALNoData' => '42113',
-
 
305
			'Gamma' => '42240',
-
 
306
			'ExpandSoftware' => '44992',
-
 
307
			'ExpandLens' => '44993',
-
 
308
			'ExpandFilm' => '44994',
-
 
309
			'ExpandFilterLens' => '44995',
-
 
310
			'ExpandScanner' => '44996',
-
 
311
			'ExpandFlashLamp' => '44997',
-
 
312
			'PixelFormat' => '48129',
-
 
313
			'Transformation' => '48130',
-
 
314
			'Uncompressed' => '48131',
-
 
315
			'ImageType' => '48132',
-
 
316
			'ImageWidth' => '48256',
-
 
317
			'ImageHeight' => '48257',
-
 
318
			'WidthResolution' => '48258',
-
 
319
			'HeightResolution' => '48259',
-
 
320
			'ImageOffset' => '48320',
-
 
321
			'ImageByteCount' => '48321',
-
 
322
			'AlphaOffset' => '48322',
-
 
323
			'AlphaByteCount' => '48323',
-
 
324
			'ImageDataDiscard' => '48324',
-
 
325
			'AlphaDataDiscard' => '48325',
-
 
326
			'OceScanjobDesc' => '50215',
-
 
327
			'OceApplicationSelector' => '50216',
-
 
328
			'OceIDNumber' => '50217',
-
 
329
			'OceImageLogic' => '50218',
-
 
330
			'Annotations' => '50255',
-
 
331
			'PrintIM' => '50341',
-
 
332
			'USPTOOriginalContentType' => '50560',
-
 
333
			'DNGVersion' => '50706',
-
 
334
			'DNGBackwardVersion' => '50707',
-
 
335
			'UniqueCameraModel' => '50708',
-
 
336
			'LocalizedCameraModel' => '50709',
-
 
337
			'CFAPlaneColor' => '50710',
-
 
338
			'CFALayout' => '50711',
-
 
339
			'LinearizationTable' => '50712',
-
 
340
			'BlackLevelRepeatDim' => '50713',
-
 
341
			'BlackLevel' => '50714',
-
 
342
			'BlackLevelDeltaH' => '50715',
-
 
343
			'BlackLevelDeltaV' => '50716',
-
 
344
			'WhiteLevel' => '50717',
-
 
345
			'DefaultScale' => '50718',
-
 
346
			'DefaultCropOrigin' => '50719',
-
 
347
			'DefaultCropSize' => '50720',
-
 
348
			'ColorMatrix1' => '50721',
-
 
349
			'ColorMatrix2' => '50722',
-
 
350
			'CameraCalibration1' => '50723',
-
 
351
			'CameraCalibration2' => '50724',
-
 
352
			'ReductionMatrix1' => '50725',
-
 
353
			'ReductionMatrix2' => '50726',
-
 
354
			'AnalogBalance' => '50727',
-
 
355
			'AsShotNeutral' => '50728',
-
 
356
			'AsShotWhiteXY' => '50729',
-
 
357
			'BaselineExposure' => '50730',
-
 
358
			'BaselineNoise' => '50731',
-
 
359
			'BaselineSharpness' => '50732',
-
 
360
			'BayerGreenSplit' => '50733',
-
 
361
			'LinearResponseLimit' => '50734',
-
 
362
			'CameraSerialNumber' => '50735',
-
 
363
			'DNGLensInfo' => '50736',
-
 
364
			'ChromaBlurRadius' => '50737',
-
 
365
			'AntiAliasStrength' => '50738',
-
 
366
			'ShadowScale' => '50739',
-
 
367
			'SR2Private' => '50740',
-
 
368
			'MakerNoteSafety' => '50741',
-
 
369
			'RawImageSegmentation' => '50752',
-
 
370
			'CalibrationIlluminant1' => '50778',
-
 
371
			'CalibrationIlluminant2' => '50779',
-
 
372
			'BestQualityScale' => '50780',
-
 
373
			'RawDataUniqueID' => '50781',
-
 
374
			'AliasLayerMetadata' => '50784',
-
 
375
			'OriginalRawFileName' => '50827',
-
 
376
			'OriginalRawFileData' => '50828',
-
 
377
			'ActiveArea' => '50829',
-
 
378
			'MaskedAreas' => '50830',
-
 
379
			'AsShotICCProfile' => '50831',
-
 
380
			'AsShotPreProfileMatrix' => '50832',
-
 
381
			'CurrentICCProfile' => '50833',
-
 
382
			'CurrentPreProfileMatrix' => '50834',
-
 
383
			'ColorimetricReference' => '50879',
-
 
384
			'PanasonicTitle' => '50898',
-
 
385
			'PanasonicTitle2' => '50899',
-
 
386
			'CameraCalibrationSig' => '50931',
-
 
387
			'ProfileCalibrationSig' => '50932',
-
 
388
			'ProfileIFD' => '50933',
-
 
389
			'AsShotProfileName' => '50934',
-
 
390
			'NoiseReductionApplied' => '50935',
-
 
391
			'ProfileName' => '50936',
-
 
392
			'ProfileHueSatMapDims' => '50937',
-
 
393
			'ProfileHueSatMapData1' => '50938',
-
 
394
			'ProfileHueSatMapData2' => '50939',
-
 
395
			'ProfileToneCurve' => '50940',
-
 
396
			'ProfileEmbedPolicy' => '50941',
-
 
397
			'ProfileCopyright' => '50942',
-
 
398
			'ForwardMatrix1' => '50964',
-
 
399
			'ForwardMatrix2' => '50965',
-
 
400
			'PreviewApplicationName' => '50966',
-
 
401
			'PreviewApplicationVersion' => '50967',
-
 
402
			'PreviewSettingsName' => '50968',
-
 
403
			'PreviewSettingsDigest' => '50969',
-
 
404
			'PreviewColorSpace' => '50970',
-
 
405
			'PreviewDateTime' => '50971',
-
 
406
			'RawImageDigest' => '50972',
-
 
407
			'OriginalRawFileDigest' => '50973',
-
 
408
			'SubTileBlockSize' => '50974',
-
 
409
			'RowInterleaveFactor' => '50975',
-
 
410
			'ProfileLookTableDims' => '50981',
-
 
411
			'ProfileLookTableData' => '50982',
-
 
412
			'OpcodeList1' => '51008',
-
 
413
			'OpcodeList2' => '51009',
-
 
414
			'OpcodeList3' => '51022',
-
 
415
			'NoiseProfile' => '51041',
-
 
416
			'Padding' => '59932',
-
 
417
			'OffsetSchema' => '59933',
-
 
418
			'OwnerName' => '65000',
-
 
419
			'SerialNumber' => '65001',
-
 
420
			'Lens' => '65002',
-
 
421
			'KDC_IFD' => '65024',
-
 
422
			'RawFile' => '65100',
-
 
423
			'Converter' => '65101',
-
 
424
			'WhiteBalance' => '65102',
-
 
425
			'Exposure' => '65105',
-
 
426
			'Shadows' => '65106',
-
 
427
			'Brightness' => '65107',
-
 
428
			'Contrast' => '65108',
-
 
429
			'Saturation' => '65109',
-
 
430
			'Sharpness' => '65110',
-
 
431
			'Smoothness' => '65111',
23
		return file_exists('/usr/bin/exiftool') && is_executable('/usr/bin/exiftool');
432
			'MoireFilter' => '65112',
24
	}
433
	);
25
	
434
 
26
	private function decoderMetadonnees($chemin_image) {
-
 
27
		
-
 
28
		$metadonnees = array();
-
 
29
		
435
	public function extraireMetadonnees($cheminImage) {
30
		if($this->peutUtiliserExifTool()) {		
436
		if ($this->peutUtiliserExifTool()) {
31
			$res = $this->decoderMetadonneesExifTool($chemin_image);			
437
			$this->meta = $this->decoderMetadonneesExifTool($cheminImage);
32
		} else {
438
		} else {
33
			$res = $this->decoderMetadonneesBasique($chemin_image);		
439
			$this->meta = $this->decoderMetadonneesBasique($cheminImage);
34
		}
440
		}
35
				
441
 
36
		$metadonnees['meta_exif'] = $this->convertirExifVersXML(&$res);
442
		$metadonnees = array();
37
		$metadonnees['meta_iptc'] = $this->convertirIptcVersXML(&$res);
443
		$metadonnees['hauteur'] = $this->obtenirHauteur();
38
		$metadonnees['meta_xmp'] = $this->convertirXmpVersXML(&$res);
444
		$metadonnees['largeur'] = $this->obtenirLargeur();
39
		$metadonnees['meta_makernote'] = $this->convertirMakernoteVersXML(&$res); 
-
 
40
		
445
		$metadonnees['date_prise_de_vue'] = $this->obtenirDatePriseDeVue();
41
		$metadonnees['appareil_fabriquant'] = $this->obtenirAppareilFabricant(&$res);
446
		$metadonnees['appareil_fabriquant'] = $this->obtenirAppareilFabricant();
42
		$metadonnees['appareil_modele'] = $this->obtenirAppareilModele(&$res);
-
 
-
 
447
		$metadonnees['appareil_modele'] = $this->obtenirAppareilModele();
43
		
448
		$metadonnees['meta_exif'] = $this->convertirMetaVersXML('EXIF');
44
		$metadonnees['hauteur'] = $this->obtenirHauteur(&$res);
449
		$metadonnees['meta_iptc'] = $this->convertirMetaVersXML('IPTC');
45
		$metadonnees['largeur'] = $this->obtenirLargeur(&$res);
-
 
46
		
450
		$metadonnees['meta_xmp'] = $this->convertirMetaVersXML('XMP');
47
		$metadonnees['date_prise_de_vue'] = $this->obtenirDatePriseDeVue(&$res);
-
 
48
		
451
		$metadonnees['meta_makernote'] = $this->convertirMetaVersXML('MAKERNOTE');
49
		return $metadonnees;
452
		return $metadonnees;
50
	}
453
	}
51
	
-
 
52
	private function obtenirAppareilFabricant($infos_meta) {
-
 
53
		
-
 
54
		$fabriquant = '';
-
 
55
		
-
 
56
		if(isset($infos_meta['EXIF']['Make'])) {
-
 
57
			$fabriquant = $infos_meta['EXIF']['Make']['valeur'];
-
 
58
		}	
-
 
59
		
-
 
60
		return $fabriquant;	
-
 
61
	}
-
 
62
	
-
 
63
	private function obtenirAppareilModele($infos_meta) {
-
 
64
		
-
 
65
		$modele = '';
-
 
66
		
-
 
67
		if(isset($infos_meta['EXIF']['CameraModelName'])) {
-
 
68
			$modele = $infos_meta['EXIF']['CameraModelName']['valeur'];
-
 
69
		}	
-
 
70
		
-
 
71
		return $modele;		
-
 
72
	}
-
 
73
	
454
 
74
	private function obtenirHauteur($infos_meta) {
-
 
75
		$hauteur = '';
-
 
76
		
-
 
77
		if(isset($infos_meta['File']['ImageHeight'])) {
-
 
78
			$hauteur = $infos_meta['File']['ImageHeight']['valeur'];
-
 
79
		}	
-
 
80
		
-
 
81
		return $hauteur;		
-
 
82
	}
-
 
83
	
455
	private function peutUtiliserExifTool() {
84
	private function obtenirLargeur($infos_meta) {
-
 
85
		$largeur = '';
-
 
86
		
-
 
87
		if(isset($infos_meta['File']['ImageWidth'])) {
-
 
88
			$largeur = $infos_meta['File']['ImageWidth']['valeur'];
-
 
89
		}	
-
 
90
		
-
 
91
		return $largeur;		
-
 
92
	}
-
 
93
	
-
 
94
	private function obtenirDatePriseDeVue($infos_meta) {
-
 
95
		
-
 
96
		$date = '';
-
 
97
		
-
 
98
		if(isset($infos_meta['EXIF']['DateTimeOriginal'])) {
456
		// TODO indiquer ceci dans un fichier de config
99
			$date = $infos_meta['EXIF']['DateTimeOriginal']['valeur'];
-
 
100
		}	
-
 
101
		
-
 
102
		return $date;		
457
		return file_exists('/usr/bin/exiftool') && is_executable('/usr/bin/exiftool');
103
	}
458
	}
104
	
459
 
105
	private function decoderMetadonneesExifTool($chemin_image) {
460
	private function decoderMetadonneesExifTool($cheminImage) {
106
		$metadata = array();
461
		$metadata = array();
107
		$res = exec('/usr/bin/exiftool -g -D '.$chemin_image, $metadata);	
462
		$res = exec('/usr/bin/exiftool -g -D '.$cheminImage, $metadata);
108
		
463
 
109
		$metadata_decodees = array();
-
 
110
		
464
		$metadata_decodees = array();
111
		$categorie = '';
465
		$categorie = '';
112
		foreach($metadata as &$data) {
466
		foreach($metadata as &$data) {
113
			if($this->estUnSeparateurCategorieExifTool($data)) {
467
			if ($this->estUnSeparateurCategorieExifTool($data)) {
114
				$categorie = trim(str_replace('----','',$data));
468
				$categorie = trim(str_replace('----', '', $data));
115
			} else {
469
			} else {
116
				$data_decodee = $this->parserValeurMetadonneeExifTool($data);
470
				$data_decodee = $this->parserValeurMetadonneeExifTool($data);
117
				$cle_metadonnee = str_replace(' ', '', $data_decodee['cle']);
471
				$cle_metadonnee = str_replace(' ', '', $data_decodee['cle']);
118
				$metadata_decodees[$categorie][$cle_metadonnee] = $data_decodee;
472
				$metadata_decodees[$categorie][$cle_metadonnee] = $data_decodee;
119
			}
473
			}
120
		}
-
 
121
				
474
		}
122
		return $metadata_decodees;
475
		return $metadata_decodees;
123
	}
476
	}
124
	
477
 
125
	private function estUnSeparateurCategorieExifTool($data) {
478
	private function estUnSeparateurCategorieExifTool($data) {
126
		return preg_match('^---- (.)* ----^',$data);	
479
		return preg_match('^---- (.)* ----^',$data);
127
	}
480
	}
128
	
481
 
129
	private function parserValeurMetadonneeExifTool($data) {
482
	private function parserValeurMetadonneeExifTool($data) {
130
		$cle_valeur = explode(':',$data,2);
483
		$cle_valeur = explode(':',$data,2);
131
		
484
 
132
		$valeur = '';
485
		$valeur = '';
133
		if(count($cle_valeur) == 2) {
486
		if(count($cle_valeur) == 2) {
134
			$valeur	= trim($cle_valeur[1]);
487
			$valeur	= trim($cle_valeur[1]);
135
		}
488
		}
136
		
489
 
137
		$id_cle = explode(' ',trim($cle_valeur[0]),2);
490
		$id_cle = explode(' ',trim($cle_valeur[0]),2);
138
		
491
 
139
		$id_cle[1] = str_replace(array('-','/'),'',$id_cle[1]);
492
		$id_cle[1] = str_replace(array('-','/'),'',$id_cle[1]);
140
				
493
 
141
		$cle_id_valeur = array('cle' => $id_cle[1], 'id' => str_replace('-','',$id_cle[0]), 'valeur' => $valeur);
494
		$cle_id_valeur = array('cle' => $id_cle[1], 'id' => str_replace('-','',$id_cle[0]), 'valeur' => $valeur);
142
		return $cle_id_valeur;		
495
		return $cle_id_valeur;
143
	}
-
 
144
	
-
 
Line 145... Line -...
145
	private function convertirExifVersXML($donnees_meta) {
-
 
146
 
-
 
147
		$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
-
 
148
		$xml .= '<exif>';
-
 
149
		if (isset($donnees_meta['EXIF'])) {
-
 
150
			foreach ($donnees_meta['EXIF'] as $prop => &$valeur) {
-
 
151
				$xml .= '<'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
-
 
152
			}
-
 
153
		}
-
 
154
		$xml .= '</exif>'."\n"."\n";
-
 
155
		
-
 
156
		return $xml;
-
 
157
	}
-
 
158
	
-
 
159
	private function convertirIptcVersXML($donnees_meta) {
-
 
160
		
-
 
161
		$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
-
 
162
		$xml .= '<iptc>';
-
 
163
		if (isset($donnees_meta['IPTC'])) {
-
 
164
			foreach ($donnees_meta['IPTC'] as $prop => &$valeur) {
-
 
165
				$xml .= '<'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
-
 
166
			}
-
 
167
		}
-
 
168
		$xml .= '</iptc>'."\n"."\n";
-
 
169
		
-
 
170
		return $xml;
-
 
171
	}
-
 
172
	
-
 
173
	private function convertirXmpVersXML($donnees_meta) {
-
 
174
		
-
 
175
		$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
-
 
176
		$xml .= '<xmp>';
-
 
177
		if (isset($donnees_meta['XMP'])) {
-
 
178
			foreach ($donnees_meta['XMP'] as $prop => &$valeur) {
-
 
179
				$xml .= '<'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
-
 
180
			}
-
 
181
		}
-
 
182
		$xml .= '</xmp>';
-
 
183
		
-
 
184
		return $xml;
-
 
185
	}
-
 
186
	
-
 
187
	private function convertirMakernoteVersXML($donnees_meta) {
-
 
188
		
-
 
189
		$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
-
 
190
		$xml .= '<makernote>';
-
 
191
		if (isset($donnees_meta['MAKERNOTE'])) {
-
 
192
			foreach ($donnees_meta['MAKERNOTE'] as $prop => &$valeur) {
-
 
193
				$xml .= '<'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
-
 
194
			}
-
 
195
		}
-
 
196
		$xml .= '</makernote>';
-
 
197
		
-
 
198
		return '';
-
 
199
	}     
496
	}
200
 
-
 
201
    public function decoderMetadonneesBasique($chemin_fichier)
-
 
202
    {   
497
 
203
    	$metadonnees = array();
498
	public function decoderMetadonneesBasique($chemin_fichier) {
204
        $exif = @exif_read_data($chemin_fichier,"EXIF,COMPUTED,IFD0,FILE,COMMENT",true,false);
499
    	$exif = @exif_read_data($chemin_fichier, "EXIF,COMPUTED,IFD0,FILE,COMMENT", true, false);
-
 
500
 
205
        
501
        // tant pis pour les makernote et xmp, les décoder demande trop de librairies externes, autant installer exiftool alors
206
        // tant pis pour les makernote et xmp, les décoder demande trop de librairies externes, autant installer exiftool alors
502
        $metadonnees = array();
207
		$metadonnees['XMP'] = array();
503
		$metadonnees['XMP'] = array();
208
		unset($metadonnees['EXIF']['MakerNote']);
-
 
209
		$metadonnees['MAKERNOTE'] = array();
504
		unset($metadonnees['EXIF']['MakerNote']);
210
        
505
		$metadonnees['MAKERNOTE'] = array();
211
		$metadonnees_non_formatees = array_merge($exif['EXIF'],$exif['IFD0']);
506
		$metadonnees_non_formatees = array_merge($exif['EXIF'], $exif['IFD0']);
-
 
507
		$metadonnees['EXIF'] = $this->formaterTableauExif(&$metadonnees_non_formatees);
212
		$metadonnees['EXIF'] = $this->formaterTableauExif(&$metadonnees_non_formatees);
508
        $metadonnees['IPTC'] = $this->extraireIptc($chemin_fichier);
213
        $metadonnees['IPTC'] = $this->extraireIptc($chemin_fichier);
509
        $metadonnees['File'] = array(
214
        $metadonnees['File'] = array('ImageWidth' => array('id' => '', 'valeur' => $exif['COMPUTED']['Width']), 
-
 
215
									 'ImageHeight' => array('id' => '', 'valeur' => $exif['COMPUTED']['Height']));
510
        	'ImageWidth' => array('id' => '', 'valeur' => $exif['COMPUTED']['Width']),
216
        
511
			'ImageHeight' => array('id' => '', 'valeur' => $exif['COMPUTED']['Height']));
217
        return $metadonnees ;
512
        return $metadonnees ;
218
    }
513
    }
219
    
-
 
220
    private function formaterTableauExif($tableau) {
514
 
221
    	
515
    private function formaterTableauExif($tableau) {
222
    	$tableau_exif_formate = array();
516
    	$tableau_exif_formate = array();
223
    	
-
 
224
    	foreach($tableau as $nom_tag => $valeur) {
517
 
225
    		
518
    	foreach ($tableau as $nom_tag => $valeur) {
226
    		$id = '';
519
    		$id = '';
227
    		if(isset($this->tableau_ids_tags_exif[$nom_tag])) {
520
    		if (isset($this->tableau_ids_tags_exif[$nom_tag])) {
228
    			$id = $this->tableau_ids_tags_exif[$nom_tag];
-
 
229
    		}
521
    			$id = $this->tableau_ids_tags_exif[$nom_tag];
230
    		
522
    		}
231
    		$tableau_exif_formate[$nom_tag] = array('id' => $id, 'valeur' => $valeur);
523
    		$tableau_exif_formate[$nom_tag] = array('id' => $id, 'valeur' => $valeur);
232
    	}
524
    	}
233
    	
525
 
234
    	return $tableau_exif_formate;
526
    	return $tableau_exif_formate;
235
    }
527
    }
236
   
528
 
237
    /**
529
    /**
238
    * Extraction des metadonnées iptc
530
    * Extraction des metadonnées iptc
239
    **/
-
 
240
    public function extraireIptc($chemin_fichier)
531
    **/
241
    {
532
    public function extraireIptc($chemin_fichier) {
242
    	$meta = array();
533
    	$meta = array();
243
    	
534
 
244
        // getimagesize renvoie les infos iptc dans le tableau info
535
        // getimagesize renvoie les infos iptc dans le tableau info
245
        $info = array();
536
        $info = array();
246
        $size = getimagesize($chemin_fichier, $info);
537
        $size = getimagesize($chemin_fichier, $info);
247
        
538
 
248
        // s'il existe
-
 
249
        if (isset($info["APP13"]))
539
        // s'il existe
250
        {
540
        if (isset($info["APP13"])) {
251
            // on parse les donnees
541
            // on parse les donnees
252
            $iptc = iptcparse($info["APP13"]);
542
            $iptc = iptcparse($info["APP13"]);
253
            if ($iptc) {
543
            if ($iptc) {
254
                // et on les analyse
-
 
255
                foreach ($iptc as $marker => $section)
544
                // et on les analyse
256
                {
-
 
257
                    foreach ($section as $nom => $val)
545
                foreach ($iptc as $marker => $section) {
258
                    {
546
                    foreach ($section as $nom => $val) {
259
                        // pour remplir le tableau de donnees
547
                        // pour remplir le tableau de donnees
260
                        $this->decoderValeurIptc($marker, $val ,&$meta) ;
548
                        $this->decoderValeurIptc($marker, $val, &$meta);
261
                    }
549
                    }
262
                }
550
                }
263
            }
551
            }
264
        }
552
        }
265
       
553
 
266
        return $meta ;
554
        return $meta;
267
    }
555
    }
268
   
556
 
269
    /**
557
    /**
270
    * Stocke une valeur de metadonnées iptc dans le champ du tableau correspondant
558
    * Stocke une valeur de metadonnées iptc dans le champ du tableau correspondant
271
    * @param String $nom nom de la valeur
559
    * @param String $nom nom de la valeur
272
    * @param String $val valeur
560
    * @param String $val valeur
273
    * @param String $data référence vers le tableau où la donnée sera stockée
561
    * @param String $data référence vers le tableau où la donnée sera stockée
274
    **/
-
 
275
    private function decoderValeurIptc($nom, $val ,$data_tab)
562
    **/
276
    {  
-
 
277
        switch($nom)
563
    private function decoderValeurIptc($nom, $val, $data_tab) {
278
        {
-
 
279
            // mots cles iptc
564
        switch ($nom) {
280
            case "2#005" :
565
            case "2#005" :// mots cles iptc
281
                $data_tab['Category'] = array('id' => '5', 'valeur' => $val);
-
 
282
            break;
566
                $data_tab['Category'] = array('id' => '5', 'valeur' => $val);
283
           
-
 
284
            // champ by line
567
            	break;
285
            case "2#080" :
568
            case "2#080" :// champ by line
286
                $data_tab['By-Line']  = array('id' => '80', 'valeur' => $val);
-
 
287
            break ;
569
                $data_tab['By-Line']  = array('id' => '80', 'valeur' => $val);
288
           
-
 
289
            // champ by line titre
570
            	break ;
290
            case "2#085" :
571
            case "2#085" :// champ by line titre
291
                $data_tab['By-LineTitle'] = array('id' => '85', 'valeur' => $val);
-
 
292
            break ;
-
 
293
           
572
                $data_tab['By-LineTitle'] = array('id' => '85', 'valeur' => $val);
294
            // ville
573
            	break ;
295
            case "2#090" :
574
            case "2#090" :// ville
296
                $data_tab['City'] = array('id' => '90', 'valeur' => $val);
-
 
297
            break ;
575
                $data_tab['City'] = array('id' => '90', 'valeur' => $val);
298
           
-
 
299
            // sous location
576
            	break ;
300
            case "2#092" :
577
            case "2#092" :// sous location
301
                $data_tab['SubLocation'] = array('id' => '92', 'valeur' => $val);
-
 
302
            break ;
578
                $data_tab['SubLocation'] = array('id' => '92', 'valeur' => $val);
303
           
-
 
304
            // etat (pour les us)
579
            	break ;
305
            case "2#095" :
580
            case "2#095" :// etat (pour les us)
306
                $data_tab['ProvinceState'] = array('id' => '95', 'valeur' => $val);
-
 
307
            break ;
-
 
308
           
581
                $data_tab['ProvinceState'] = array('id' => '95', 'valeur' => $val);
309
            // code pays
582
            	break ;
310
            case "2#100" :
583
            case "2#100" :// code pays
311
                $data_tab['CountryPrimaryLocationCode'] = array('id' => '100', 'valeur' => $val);
-
 
312
            break ;
-
 
313
           
584
                $data_tab['CountryPrimaryLocationCode'] = array('id' => '100', 'valeur' => $val);
314
            // code pays
585
            	break ;
315
            case "2#101" :
586
            case "2#101" :// code pays
316
                $data_tab['CountryName'] = array('id' => '101', 'valeur' => $val);
-
 
317
            break ;
587
                $data_tab['CountryName'] = array('id' => '101', 'valeur' => $val);
318
           
-
 
319
            // titre principal
588
            	break ;
320
            case "2#105" :
589
            case "2#105" :// titre principal
321
                $data_tab['Headline'] = array('id' => '105', 'valeur' => $val);
-
 
322
            break ;
-
 
323
           
590
                $data_tab['Headline'] = array('id' => '105', 'valeur' => $val);
324
            // credit
591
            	break ;
325
            case "2#110" :
592
            case "2#110" :// credit
326
                $data_tab['Credit'] = array('id' => '110', 'valeur' => $val);
-
 
327
            break ;
-
 
328
           
593
                $data_tab['Credit'] = array('id' => '110', 'valeur' => $val);
329
            // copyright
594
            	break ;
330
            case "2#116" :
595
            case "2#116" :// copyright
331
                $data_tab['CopyrightNotice'] = array('id' => '116', 'valeur' => $val);
-
 
332
            break ;
-
 
333
           
596
                $data_tab['CopyrightNotice'] = array('id' => '116', 'valeur' => $val);
334
            // contact
597
            	break ;
335
            case "2#118" :
598
            case "2#118" :// contact
336
                $data_tab['Contact'] = array('id' => '118', 'valeur' => $val);
-
 
337
            break ;
599
                $data_tab['Contact'] = array('id' => '118', 'valeur' => $val);
338
            
600
            	break ;
339
            default:
-
 
340
            	unset($data_tab['nom']);
601
            default:
341
            break;
602
            	unset($data_tab['nom']);
758
		'MoireFilter' => '65112',
643
    	return $xml;
759
	);
-
 
760
}
644
    }
-
 
645
}
761
?> 
646
?>