Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1149 gduche 1
<?php
2
 
3
class MigrationImages extends Cel {
1189 jpm 4
 
1160 aurelien 5
	public static $bdd_cel_migration;
6
	public static $bdd_utilisateurs;
1189 jpm 7
 
1160 aurelien 8
	const truncate = true; //Doit on vider les tables de destination ?
1189 jpm 9
 
1149 gduche 10
	const separateur_champs_metadonnees = ';';
11
	const separateur_valeurs_metadonnees = ':';
1189 jpm 12
 
1149 gduche 13
	private $id_cle_metadonnees = array();
1189 jpm 14
 
1149 gduche 15
	/** Tableau associatif permettant de stocker l'avancement dans une boucle.
16
	* La clé est un md5 du message à afficher au démarrage de la boucle.
17
	* @var array
18
	*/
19
	private static $avancement = array();
1189 jpm 20
 
1160 aurelien 21
	const dry_run = false;
1189 jpm 22
 
1149 gduche 23
	private $tableau_utilisateurs = array();
24
	private $tableau_observations = array();
25
	private $tableau_mots_cles = array();
1189 jpm 26
 
27
	private $tableau_nouveau_ancien = array(
1149 gduche 28
		'id_image' => 'ci_id_image',
29
		'ordre' =>'ci_ordre',
30
		'ce_utilisateur' => 'traiterIdentifiantUtilisateur',
31
		'prenom_utilisateur' => 'traiterPrenomUtilisateur',
32
		'nom_utilisateur' => 'traiterNomUtilisateur',
33
		'courriel_utilisateur' => 'ci_ce_utilisateur',
34
		'hauteur' => 'ci_meta_height',
35
		'largeur' => 'ci_meta_width',
36
		'appareil_fabriquant' => 'ci_meta_make',
37
		'appareil_modele' => 'ci_meta_model',
38
		'date_prise_de_vue' => 'ci_meta_date_time',
39
		'note_qualite' => 'ci_note_image',
40
		'mots_cles_texte' => 'traiterMotsClesTexte',
41
		'commentaire' => 'ci_meta_comment',
42
		'nom_original' => 'ci_nom_original',
43
		'md5' => 'ci_md5',
44
		'meta_exif' => 'traiterExif',
45
		'meta_iptc' => 'traiterIptc',
46
		'meta_xmp' => 'traiterXmp',
47
		'meta_makernote' => 'traiterMakernote',
48
		'date_modification' => 'ci_meta_date',
49
		'date_creation' => 'ci_meta_date_ajout'
50
	);
1189 jpm 51
 
1149 gduche 52
	private $champs_exifs_non_gardes = array(
53
		'ci_meta_x_resolution',
54
		'ci_meta_y_resolution',
55
		'ci_meta_gps',
56
		'ci_meta_user_comment',
57
		'ci_meta_exif_exposure_time',
58
		'ci_meta_exif_f_number',
59
		'ci_meta_exif_exif_version',
60
		'ci_meta_exif_compressed_bits_per_pixel',
61
		'ci_meta_exif_shutter_speed_value',
62
		'ci_meta_exif_aperture_value',
63
		'ci_meta_exif_exposure_bias_value',
64
		'ci_meta_exif_max_aperture_value',
65
		'ci_meta_exif_metering_mode',
66
		'ci_meta_exif_light_source',
67
		'ci_meta_exif_flash',
68
		'ci_meta_exif_focal_length',
69
		'ci_meta_exif_flash_pix_version',
70
		'ci_meta_exif_color_space',
71
		'ci_meta_exif_interoperability_offset',
72
		'ci_meta_exif_focal_plane_x_resolution',
73
		'ci_meta_exif_focal_plane_y_resolution',
74
		'ci_meta_exif_focal_plane_resolution_unit',
75
		'ci_meta_exif_sensing_method',
76
		'ci_meta_exif_file_source',
77
		'ci_meta_exif_custom_rendered',
78
		'ci_meta_exif_exposure_mode',
79
		'ci_meta_exif_white_balance',
80
		'ci_meta_exif_digital_zoom_ratio',
81
		'ci_meta_exif_scene_capture_type',
82
		'ci_meta_exif_gain_control',
83
		'ci_meta_exif_contrast',
84
		'ci_meta_exif_saturation',
85
		'ci_meta_exif_sharpness',
86
		'ci_meta_exif_subject_distance_range'
87
	);
1189 jpm 88
 
1149 gduche 89
	private $champs_iptc_non_gardes = array(
90
		'ci_meta_iptc_category',
91
		'ci_meta_iptc_by_line',
92
		'ci_meta_iptc_by_line_title',
93
		'ci_meta_iptc_city',
94
		'ci_meta_iptc_sub_location',
95
		'ci_meta_iptc_province_state',
96
		'ci_meta_iptc_country_primary_location_code',
97
		'ci_meta_iptc_country_name',
98
		'ci_meta_iptc_headline',
99
		'ci_meta_iptc_credit',
100
		'ci_meta_iptc_copyright_notice',
101
		'ci_meta_iptc_contact'
102
	);
1189 jpm 103
 
1149 gduche 104
	private $champs_divers_non_gardes = array(
105
		'ci_publiable_eflore',
106
		'ci_meta_mots_cles'
107
	);
1189 jpm 108
 
1149 gduche 109
	/**
110
	* Utiliser cette méthode dans une boucle pour afficher un message suivi du nombre de tour de boucle effectué.
111
	* Vous devrez vous même gérer le retour à la ligne à la sortie de la boucle.
112
	*
113
	* @param string le message d'information.
114
	* @param int le nombre de départ à afficher.
115
	* @return void le message est affiché dans la console.
116
	*/
117
	protected function afficherAvancement($message, $depart = 0) {
1160 aurelien 118
		if (! isset(self::$avancement[$message])) {
119
			self::$avancement[$message] = $depart;
120
			echo "$message : ";
1189 jpm 121
 
1160 aurelien 122
			$actuel =& self::$avancement[$message];
123
			echo $actuel++;
124
		} else {
125
			$actuel =& self::$avancement[$message];
1189 jpm 126
 
1160 aurelien 127
			// Cas du passage de 99 (= 2 caractères) à 100 (= 3 caractères)
128
			$passage = 0;
129
			if (strlen((string) ($actuel - 1)) < strlen((string) ($actuel))) {
130
			$passage = 1;
131
		}
1189 jpm 132
 
1160 aurelien 133
			echo str_repeat(chr(8), (strlen((string) $actuel) - $passage));
134
			echo $actuel++;
135
		}
1149 gduche 136
	}
1189 jpm 137
 
1149 gduche 138
	/**
139
	 * Méthode appelée avec une requête de type GET.
140
	 */
141
	public function getElement($params) {
1189 jpm 142
 
1160 aurelien 143
		if(!isset($this->config['database_cel']['database_migration']) || $this->config['database_cel']['database_migration'] == '') {
144
			echo 'Attention la variable de configuration database_migration dans la section database_cel, contenant la base de données d\'arrivée, doit être remplie '."\n";
145
			exit;
146
		}
1189 jpm 147
 
1160 aurelien 148
		if(!isset($this->config['database_ident']['database']) || $this->config['database_ident']['database'] == '') {
149
			echo 'Attention la variable de configuration database dans la section database_ident, contenant la base de données utilisateurs, doit être remplie '."\n";
150
			exit;
151
		}
1189 jpm 152
 
1160 aurelien 153
		self::$bdd_cel_migration = $this->config['database_cel']['database_migration'];
154
		self::$bdd_utilisateurs = $this->config['database_ident']['database'];
1189 jpm 155
 
1149 gduche 156
		$this->id_cle_metadonnees = array_merge($this->tableau_ids_tags_exif, $this->tableau_ids_tags_iptc);
1160 aurelien 157
 
158
		echo "--MIGRATION DES IMAGES --------------------------------------\n";
159
		//1. TEMPORAIRE : vider les tables de destinations
160
		if (self::truncate) {
161
			echo "-------------------------------------------------------------------\n\n";
162
			echo "  ETAPE 0. Vider les tables ... \n\n";
163
			echo "-------------------------------------------------------------------\n\n";
1189 jpm 164
			$nouvellesTables = array('cel_images', 'cel_obs_images');
1160 aurelien 165
			foreach ($nouvellesTables as $nomTable) {
166
				echo 'Vider la table '.$nomTable.'...';
167
				$requeteTruncate = 'TRUNCATE TABLE '.self::$bdd_cel_migration.'.'.$nomTable;
168
				$resultatTruncate = $this->executerRequete($requeteTruncate);
169
				echo "ok \n";
170
			}
1189 jpm 171
 
1160 aurelien 172
			echo "\n---------------------------------------------------------------- OK\n\n";
173
		}
1189 jpm 174
 
1160 aurelien 175
		echo "-------------------------------------------------------------------\n\n";
176
		echo "  ETAPE 1. Paramétrage ... \n\n";
177
		echo "-------------------------------------------------------------------\n\n";
1149 gduche 178
		$this->getUtilisateurs();
179
		$this->getMotsCles();
180
		$this->getObservations();
1189 jpm 181
 
1160 aurelien 182
		echo "-------------------------------------------------------------------\n\n";
183
		echo "  ETAPE 2. Migration des images ... \n\n";
184
		echo "-------------------------------------------------------------------\n\n";
185
		$this->migrerImages();
1149 gduche 186
		echo "\n"."\n"."\n";
1189 jpm 187
 
1160 aurelien 188
		echo "-------------------------------------------------------------------\n\n";
189
		echo "  ETAPE 3. migration des liaisons obs images ... \n\n";
190
		echo "-------------------------------------------------------------------\n\n";
1181 aurelien 191
		$this->migrerLiaisonsObsImages();
1149 gduche 192
		echo "\n"."\n"."\n";
193
	}
1189 jpm 194
 
1149 gduche 195
	private function getUtilisateurs() {
1160 aurelien 196
		echo "\n-------------------------------------------------------------------\n";
197
		echo "--SELECTION DES UTILISATEURS---------------------------------------\n\n";
1189 jpm 198
 
1160 aurelien 199
		$requete_selection_utilisateurs = 'SELECT U_ID as id, U_MAIL as mail, U_NAME as nom, U_SURNAME as prenom, U_PASSWD as pass FROM '.self::$bdd_utilisateurs.'.annuaire_tela';
1149 gduche 200
		$tableau_utilisateurs = $this->executerRequete($requete_selection_utilisateurs);
1189 jpm 201
 
1149 gduche 202
		foreach( $tableau_utilisateurs as &$utilisateur) {
203
			$this->tableau_utilisateurs[$utilisateur['mail']] = $utilisateur;
204
		}
1189 jpm 205
 
1160 aurelien 206
		echo sizeof($this->tableau_utilisateurs)." utilisateurs sélectionnés";
207
		echo "\n-----------------------------------------------------------------OK\n";
1149 gduche 208
	}
1189 jpm 209
 
1149 gduche 210
	private function getMotsCles() {
1160 aurelien 211
		echo "\n-------------------------------------------------------------------\n";
212
		echo "--SELECTION DES MOTS-CLES -----------------------------------------\n\n";
1189 jpm 213
 
1160 aurelien 214
		$requete_selection_mots_cles = 'SELECT cmc_id_proprietaire as id_utilisateur, cmc_id_mot_cle_utilisateur as id_mot_cle, cmc_mot_cle as mot_cle FROM cel_mots_cles_obs';
1149 gduche 215
		$tableau_mots_cles = $this->executerRequete($requete_selection_mots_cles);
216
 
1160 aurelien 217
		foreach( $tableau_mots_cles as &$mot_cle) {
1149 gduche 218
			$this->tableau_mots_cles[$mot_cle['id_utilisateur']][$mot_cle['id_mot_cle']] = $mot_cle;
219
		}
1189 jpm 220
 
1160 aurelien 221
		echo sizeof($this->tableau_mots_cles)." mots-clés sélectionnés";
222
		echo "\n-----------------------------------------------------------------OK\n";
1189 jpm 223
 
1149 gduche 224
	}
1189 jpm 225
 
1149 gduche 226
	private function getObservations() {
1189 jpm 227
 
1149 gduche 228
		$pas = 5000;
1189 jpm 229
 
1149 gduche 230
		$nObs = "SELECT COUNT(*) AS nb FROM cel_inventory";
231
		$resultatNbObs = $this->executerRequete($nObs);
232
		$nbObs = $resultatNbObs[0]['nb'];
1189 jpm 233
 
1149 gduche 234
		for ($i = 0; $i < 230000; $i += $pas ) {
235
			$requete_selection_observations = 'SELECT id, ordre, identifiant FROM cel_inventory LIMIT '.$i.", $pas";
236
			$tableau_observations = $this->executerRequete($requete_selection_observations);
237
			foreach($tableau_observations as &$obs) {
238
				$this->tableau_observations[$obs['identifiant']][$obs['ordre']] = $obs['id'];
239
			}
1189 jpm 240
 
1160 aurelien 241
			$this->afficherAvancement('Selection des observations (par '.$pas.' )', $nbObs);
1149 gduche 242
		}
1189 jpm 243
 
1160 aurelien 244
		echo "\n\n";
1149 gduche 245
	}
1189 jpm 246
 
1149 gduche 247
	public function executerRequeteSimple($requete) {
248
		// Fonction de commodité pour afficher les requetes au lieu de les executer
249
		if (self::dry_run) {
1189 jpm 250
			echo str_replace('),','),'."\n", $requete)."\n";
1149 gduche 251
			return true;
252
		} else {
253
			return parent::executerRequeteSimple($requete);
254
		}
255
	}
1189 jpm 256
 
1149 gduche 257
	private function migrerImages() {
1189 jpm 258
 
1149 gduche 259
		$debut = 0;
1189 jpm 260
		$pas = 200;
261
		$fin = 150000;
262
 
1160 aurelien 263
		//Selectionner le nombre d'images
264
		$requeteNbImg = "SELECT COUNT(*) as nb FROM cel_images";
265
		$resultatNbImg = $this->executerRequete($requeteNbImg);
266
		$fin = $resultatNbImg[0]['nb'];
1189 jpm 267
 
1149 gduche 268
		for ($i = $debut; $i <= $fin ; $i += $pas) {
269
			$requete_selection_images = 'SELECT * FROM cel_images '.
270
											'ORDER BY ci_id_image ASC LIMIT '.$i.','.$pas;
1189 jpm 271
 
272
			$images = @$this->requeter($requete_selection_images);
273
 
1160 aurelien 274
			$requete_insertion_images = 'INSERT INTO '.self::$bdd_cel_migration.'.cel_images (';
1149 gduche 275
			foreach ($this->tableau_nouveau_ancien as $nouveau_champ => $ancien_champ) {
276
				$requete_insertion_images .= $nouveau_champ.',';
1189 jpm 277
			}
1149 gduche 278
			$requete_insertion_images = rtrim($requete_insertion_images, ',');
1189 jpm 279
 
1149 gduche 280
			$requete_insertion_images = $requete_insertion_images.') VALUES ';
1189 jpm 281
 
282
			if (is_array($images)) {
283
 
1149 gduche 284
				$nb_images_a_traiter = count($images);
1189 jpm 285
 
1149 gduche 286
				foreach($images as $image) {
1189 jpm 287
 
1149 gduche 288
					$nouvelle_image = $this->traiterLigneImage($image);
1189 jpm 289
 
1149 gduche 290
					$nouvelle_image = array_map(array($this,'proteger'),$nouvelle_image);
291
					$requete_insertion_images .= '('.join(',',array_values($nouvelle_image)).'),';
292
				}
1189 jpm 293
 
1149 gduche 294
				$requete_insertion_images = rtrim($requete_insertion_images, ',');
295
				$migration_images = $this->executer($requete_insertion_images);
1189 jpm 296
 
1149 gduche 297
				if (!$migration_images) {
298
					echo 'la migration des images '.$i.' à '.($i+$nb_images_a_traiter).' a échoué '."\n";
299
				} else {
1160 aurelien 300
					$this->afficherAvancement('Migration des images (par '.$pas.' )', $fin);
1189 jpm 301
				}
1149 gduche 302
			}
1189 jpm 303
 
1149 gduche 304
			if(count($images) < $pas) {
1160 aurelien 305
				echo "\n---------------------------------------------------------------- OK\n\n";
1149 gduche 306
				return;
307
			}
308
		}
309
	}
1189 jpm 310
 
1149 gduche 311
	private function migrerLiaisonsObsImages() {
312
		$debut = 0;
1189 jpm 313
		$pas = 500;
314
		$fin = 50000;
315
 
1160 aurelien 316
		$liaisons_obs_inexistantes = 0;
1189 jpm 317
 
1160 aurelien 318
		//Selectionner le nombre de liaisons
319
		$requeteNbImgObs = "SELECT COUNT(*) as nb FROM cel_obs_images";
320
		$resultatNbImgObs = $this->executerRequete($requeteNbImgObs);
321
		$fin = $resultatNbImgObs[0]['nb'];
1189 jpm 322
 
1149 gduche 323
		for ($i = $debut; $i <= $fin ; $i += $pas) {
1189 jpm 324
 
1160 aurelien 325
			if($i > $fin) {
326
				$i = $fin;
327
			}
1189 jpm 328
 
1149 gduche 329
			$requete_selection_liaisons = 'SELECT * FROM cel_obs_images LIMIT '.$i.','.$pas;
330
			$tableau_liaisons = $this->executerRequete($requete_selection_liaisons);
1189 jpm 331
 
1160 aurelien 332
			$requete_migration_liaison = 'INSERT INTO '.self::$bdd_cel_migration.'.cel_obs_images '.
333
											'(id_image, id_utilisateur, id_observation, date_liaison) '.
1149 gduche 334
											'VALUES ';
1189 jpm 335
 
1149 gduche 336
			$sous_requete_insertion = '';
1189 jpm 337
 
1160 aurelien 338
			if(is_array($tableau_liaisons)) {
339
				foreach($tableau_liaisons as &$liaison) {
1189 jpm 340
 
1160 aurelien 341
					$mail_utilisateur = $liaison['coi_ce_utilisateur'];
1181 aurelien 342
					$utilisateur = $this->renvoyerIdPourMigration($mail_utilisateur);
1189 jpm 343
 
1160 aurelien 344
					$id_obs = $liaison['coi_ce_observation'];
1189 jpm 345
 
1160 aurelien 346
					if (isset($this->tableau_observations[$mail_utilisateur][$id_obs])) {
347
						$id_obs =  $this->tableau_observations[$mail_utilisateur][$id_obs];
1189 jpm 348
 
1160 aurelien 349
						$sous_requete_insertion .= '('.$this->proteger($liaison['coi_ce_image']).','.
350
							$this->proteger($utilisateur).','.
351
							$this->proteger($id_obs).','.
352
							$this->proteger($liaison['coi_date_liaison']).
353
						'),';
354
					} else {
355
						// cas d'une observation inexistante, la liaison est ignorée
356
						$liaisons_obs_inexistantes++;
357
					}
1149 gduche 358
				}
1189 jpm 359
 
1160 aurelien 360
				$sous_requete_insertion = rtrim($sous_requete_insertion,',');
361
				$requete_migration_liaison = $requete_migration_liaison.$sous_requete_insertion;
1189 jpm 362
 
1160 aurelien 363
				$migration_liaison = $this->executerRequeteSimple($requete_migration_liaison);
1189 jpm 364
 
1160 aurelien 365
				if (!$migration_liaison) {
366
					echo 'la migration des liaisons obs images de '.$i.' à '.($i+$pas).' a échoué ! '."\n<br />";
1149 gduche 367
				} else {
1160 aurelien 368
					$this->afficherAvancement('Migration des liaisons obs images (par '.$pas.' )', $fin);
1189 jpm 369
				}
1149 gduche 370
			}
371
		}
1160 aurelien 372
		echo "\n\n";
373
		echo $liaisons_obs_inexistantes ? $liaisons_obs_inexistantes." liaisons image obs ont été ignorées car les obs sont absentes" : '' ;
374
		echo "\n";
375
		echo "\n---------------------------------------------------------------- OK\n\n";
1149 gduche 376
	}
1189 jpm 377
 
1149 gduche 378
	private function traiterLigneImage($image) {
1189 jpm 379
 
1149 gduche 380
		$nouvelle_image = array();
1189 jpm 381
 
382
		foreach ($this->tableau_nouveau_ancien as $nouveau_champ_image => $ancien_champ_image) {
383
 
1149 gduche 384
			if ($this->estUnChampATraiter($ancien_champ_image)) {
385
				if (method_exists($this,$ancien_champ_image)) {
386
					$nouvelle_image[$nouveau_champ_image] = $this->$ancien_champ_image($image);
387
				} else {
388
					echo 'methode manquante : '.$ancien_champ_image."\n";
389
					$nouvelle_image[$nouveau_champ_image] = '';
390
				}
391
 
392
			} else {
393
				$nouvelle_image[$nouveau_champ_image] = $image[$ancien_champ_image];
394
			}
395
		}
1189 jpm 396
 
1149 gduche 397
		return $nouvelle_image;
398
	}
1189 jpm 399
 
1149 gduche 400
	private function estUnChampATraiter($champ) {
1189 jpm 401
 
1149 gduche 402
		return strpos($champ, 'traiter') !== false;
403
	}
1189 jpm 404
 
1149 gduche 405
	private function traiterMotsClesTexte($ligne_image) {
1189 jpm 406
 
1149 gduche 407
		$mail_image = $ligne_image['ci_ce_utilisateur'];
408
		$retour = $ligne_image['ci_meta_mots_cles'];
1189 jpm 409
 
1149 gduche 410
		if (isset($this->tableau_mots_cles[$mail_image])) {
1189 jpm 411
 
1149 gduche 412
			$mots_cles_tableau = $this->parserMotsCles($mail_image, $ligne_image['ci_meta_mots_cles'], ',');
413
			$retour =  join(';',$mots_cles_tableau);
414
			$retour = ltrim($retour,';;') ;
415
		}
1189 jpm 416
 
1149 gduche 417
		return $retour;
1189 jpm 418
	}
419
 
1149 gduche 420
	private function parserMotsCles($utilisateur, $mot_cles, $separateur = ',') {
1189 jpm 421
 
1149 gduche 422
		$tableau_mots_cles = explode($separateur,$mot_cles);
423
		$tableau_mots_cles_formates = array();
1189 jpm 424
 
1149 gduche 425
		foreach($tableau_mots_cles as $mot_cle) {
1189 jpm 426
 
1149 gduche 427
			$mot_cle = str_replace($separateur.$separateur,'',$mot_cle);
428
			$mot_cle = str_replace('null','',$mot_cle);
1189 jpm 429
 
1149 gduche 430
			if ($this->estUnIdentifiantMotCle($mot_cle)) {
1189 jpm 431
 
1149 gduche 432
				// certains mots clés mal formatés contiennent des virgules
433
				if (strpos($mot_cle,',') !== false) {
434
					$tab_mot_cle_mal_formate = explode(',',$mot_cle);
1189 jpm 435
 
1149 gduche 436
					foreach ($tab_mot_cle_mal_formate as $mot_cle_mal_formate) {
437
						if ($this->estUnIdentifiantMotCle($mot_cle_mal_formate)) {
438
							$tableau_mots_cles_formates[$mot_cle_mal_formate] = $this->tableau_mots_cles[$utilisateur][$mot_cle_mal_formate]['mot_cle'];
439
						}
1189 jpm 440
					}
1149 gduche 441
				} else {
442
					// on met le mot clé dans sa propre case afin d'éviter
1189 jpm 443
					// facilement les doublons provoqués par de mauvais formatages
1160 aurelien 444
					if(isset($this->tableau_mots_cles[$utilisateur][$mot_cle])) {
445
						$tableau_mots_cles_formates[$mot_cle] = $this->tableau_mots_cles[$utilisateur][$mot_cle]['mot_cle'];
446
					}
1149 gduche 447
				}
448
 
449
			}
450
		}
1189 jpm 451
 
1149 gduche 452
		return $tableau_mots_cles_formates;
453
	}
1189 jpm 454
 
1149 gduche 455
	private function estUnIdentifiantMotCle($chaine) {
456
		return trim($chaine) != '' && preg_match('/[0-9A-Z]+\.[0-9A-Z]+/i', $chaine) ;
457
	}
1189 jpm 458
 
1149 gduche 459
	private function traiterIdentifiantUtilisateur($ligne_image) {
1189 jpm 460
 
1149 gduche 461
		$mail_image = $ligne_image['ci_ce_utilisateur'];
1181 aurelien 462
		$retour = $this->renvoyerIdPourMigration($mail_image);
1189 jpm 463
 
1149 gduche 464
		return $retour;
465
	}
1189 jpm 466
 
1149 gduche 467
	private function traiterPrenomUtilisateur($ligne_image) {
1189 jpm 468
 
1149 gduche 469
		$mail_image = $ligne_image['ci_ce_utilisateur'];
470
		$retour = $mail_image;
1189 jpm 471
 
1149 gduche 472
		if (isset($this->tableau_utilisateurs[$mail_image])) {
473
			$retour =  $this->tableau_utilisateurs[$mail_image]['prenom'];
1181 aurelien 474
		} else {
475
			$retour = '';
1149 gduche 476
		}
1189 jpm 477
 
1149 gduche 478
		return $retour;
479
	}
1189 jpm 480
 
1149 gduche 481
	private function traiterNomUtilisateur($ligne_image) {
1189 jpm 482
 
1149 gduche 483
		$mail_image = $ligne_image['ci_ce_utilisateur'];
484
		$retour = $mail_image;
1189 jpm 485
 
1149 gduche 486
		if (isset($this->tableau_utilisateurs[$mail_image])) {
487
			$retour =  $this->tableau_utilisateurs[$mail_image]['nom'];
1181 aurelien 488
		} else {
489
			$retour = '';
1149 gduche 490
		}
1189 jpm 491
 
1149 gduche 492
		return $retour;
493
	}
1189 jpm 494
 
1149 gduche 495
	private function decoderTableauMetaDonnees($chaine) {
1189 jpm 496
 
1149 gduche 497
		$tableau_valeurs_decodees = array();
498
 
1189 jpm 499
		if (trim($chaine) != '') {
1149 gduche 500
			$tableau_meta = explode(self::separateur_champs_metadonnees,$chaine);
501
			foreach ($tableau_meta as &$chaine_meta) {
1189 jpm 502
 
1149 gduche 503
				$cle_valeur = explode(self::separateur_valeurs_metadonnees, $chaine_meta);
504
				if (is_array($cle_valeur) && count($cle_valeur) == 2) {
505
					$cle = ltrim($cle_valeur[0],' ');
506
					$tableau_valeurs_decodees[$cle] = $cle_valeur[1];
507
				}
508
			}
509
		}
1189 jpm 510
 
1149 gduche 511
		return $tableau_valeurs_decodees;
512
	}
1189 jpm 513
 
1149 gduche 514
	private function convertirTableauMetadonneesEnXml($tableau) {
1189 jpm 515
 
1149 gduche 516
		$xml = '';
1189 jpm 517
 
1160 aurelien 518
		foreach($tableau as $cle => $valeur) {
1149 gduche 519
 
520
			$cle = str_replace('ci_meta_exif_','',$cle);
521
			$cle = str_replace('ci_meta_iptc_','',$cle);
522
			$cle = str_replace('ci_meta_','',$cle);
523
			$cle = str_replace('_',' ',$cle);
524
			$cle = str_replace(' ','',ucwords($cle));
525
			$valeur = str_replace("\0",'',$valeur);
1160 aurelien 526
			$id = isset($this->id_cle_metadonnees[$cle]) ? $this->id_cle_metadonnees[$cle] : $cle;
527
			$xml .= '<'.$cle.' id="'.$id.'">'.$valeur.'</'.$cle.'>'."\n";
528
		}
1189 jpm 529
 
1149 gduche 530
		return $xml;
531
	}
1189 jpm 532
 
1149 gduche 533
	private function peutUtiliserExifTool() {
534
		return file_exists('/usr/bin/exiftool') && is_executable('/usr/bin/exiftool');
535
	}
1189 jpm 536
 
1149 gduche 537
	private function decoderMetadonnees($chemin_image) {
1189 jpm 538
 
1149 gduche 539
		$res = '';
1189 jpm 540
 
1149 gduche 541
		if($this->peutUtiliserExifTool()) {
542
			$res = $this->decoderMetadonneesExifTool($chemin_image);
1189 jpm 543
 
1149 gduche 544
			$xml_meta = '<?xml version="1.0" encoding="UTF-8" ?>';
545
			$xml_meta .= '<exif>';
1189 jpm 546
 
1149 gduche 547
			foreach($res['EXIF'] as $prop => $valeur) {
548
				$xml_meta .= '    <'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
549
			}
550
			$xml_meta .= '</exif>'."\n";
1189 jpm 551
 
1149 gduche 552
			$xml_meta .= '<iptc>';
553
			foreach($res['IPTC'] as $prop => $valeur) {
554
				$xml_meta .= '    <'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
555
			}
556
			$xml_meta .= '</iptc>'."\n";
1189 jpm 557
 
1149 gduche 558
			$xml_meta .= '<xmp>';
559
			foreach($res['XMP'] as $prop => $valeur) {
560
				$xml_meta .= '    <'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
561
			}
562
			$xml_meta .= '</xmp>'."\n";
563
		} else {
1189 jpm 564
 
1149 gduche 565
		}
1189 jpm 566
 
1149 gduche 567
		return $xml_meta;
568
	}
1189 jpm 569
 
1149 gduche 570
	private function decoderMetadonneesExifTool($chemin_image) {
571
		$metadata = array();
1189 jpm 572
		$res = exec('/usr/bin/exiftool -g -D '.$chemin_image, $metadata);
573
 
1149 gduche 574
		$metadata_decodees = array();
1189 jpm 575
 
1149 gduche 576
		$categorie = '';
577
		foreach($metadata as &$data) {
578
			if($this->estUnSeparateurCategorieExifTool($data)) {
579
				$categorie = trim(str_replace('----','',$data));
580
			} else {
581
				$data_decodee = $this->parserValeurMetadonneeExifTool($data);
582
				$cle_metadonnee = str_replace(' ', '', $data_decodee['cle']);
583
				$metadata_decodees[$categorie][$cle_metadonnee] = $data_decodee;
584
				$this->id_cle_metadonnees[$cle_metadonnee] = $data_decodee['id'];
585
			}
586
		}
1189 jpm 587
 
1149 gduche 588
		return $metadata_decodees;
589
	}
1189 jpm 590
 
1149 gduche 591
	private function estUnSeparateurCategorieExifTool($data) {
1189 jpm 592
		return preg_match('^---- (.)* ----^',$data);
1149 gduche 593
	}
1189 jpm 594
 
1149 gduche 595
	private function parserValeurMetadonneeExifTool($data) {
596
		$cle_valeur = explode(':',$data);
1189 jpm 597
 
1149 gduche 598
		$valeur = '';
599
		if(count($cle_valeur) == 2) {
600
			$valeur	= trim($cle_valeur[1]);
601
		}
1189 jpm 602
 
1149 gduche 603
		$id_cle = explode(' ',trim($cle_valeur[0]),2);
1189 jpm 604
 
1149 gduche 605
		$id_cle[1] = str_replace(array('-','/'),'',$id_cle[1]);
1189 jpm 606
 
1149 gduche 607
		$cle_id_valeur = array('cle' => $id_cle[1], 'id' => str_replace('-','',$id_cle[0]), 'valeur' => $valeur);
1189 jpm 608
		return $cle_id_valeur;
1149 gduche 609
	}
1189 jpm 610
 
1149 gduche 611
	private function traiterExif($ligne_image) {
612
 
613
		$metadonnees_autres = $this->decoderTableauMetaDonnees($ligne_image['ci_meta_exif_autres']);
614
		$metadonnees = array_intersect_key($ligne_image, array_flip($this->champs_exifs_non_gardes))+$metadonnees_autres;
1189 jpm 615
 
1149 gduche 616
		$xml_meta = '<?xml version="1.0" encoding="UTF-8" ?>';
617
		$xml_meta .= '<exif>';
618
		$xml_meta .= $this->convertirTableauMetadonneesEnXml($metadonnees);
619
		$xml_meta .= '</exif>';
1189 jpm 620
 
1149 gduche 621
		return $xml_meta;
622
	}
1189 jpm 623
 
1149 gduche 624
	private function traiterIptc($ligne_image) {
1189 jpm 625
 
1149 gduche 626
		$metadonnees_autres = $this->decoderTableauMetaDonnees($ligne_image['ci_meta_iptc_autres']);
627
		$metadonnees = array_intersect_key($ligne_image, array_flip($this->champs_iptc_non_gardes))+$metadonnees_autres;
1189 jpm 628
 
1149 gduche 629
		$xml_meta = '<?xml version="1.0" encoding="UTF-8" ?>';
630
		$xml_meta .= '<iptc>';
631
		$xml_meta .= $this->convertirTableauMetadonneesEnXml($metadonnees);
632
		$xml_meta .= '</iptc>';
1189 jpm 633
 
1149 gduche 634
		return $xml_meta;
635
	}
1189 jpm 636
 
1149 gduche 637
	private function traiterXmp($ligne_image) {
1189 jpm 638
 
1149 gduche 639
		$chemin = $this->obtenirCheminImageOriginale($ligne_image['ci_id_image']);
1160 aurelien 640
		// TODO décommenté car pour le moment ça n'est pas necessaire, à éxécuter à part
1149 gduche 641
		//$res = $this->decoderMetadonneesExifTool($chemin);
642
		$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
643
		$xml .= '<xmp>';
644
		if (isset($res['XMP'])) {
645
			foreach ($res['XMP'] as $prop => $valeur) {
646
				$xml .= '    <'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
647
			}
648
		}
649
		$xml .= '</xmp>';
1189 jpm 650
 
1149 gduche 651
		return $xml;
652
	}
1189 jpm 653
 
1149 gduche 654
	private function traiterMakernote($ligne_image) {
1189 jpm 655
 
1149 gduche 656
		$chemin = $this->obtenirCheminImageOriginale($ligne_image['ci_id_image']);
657
		//$res = $this->decoderMetadonneesExifTool($chemin);
658
		$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
659
		$xml .= '<makernote>';
660
		if (isset($res['MAKERNOTE'])) {
661
			foreach ($res['MAKERNOTE'] as $prop => $valeur) {
662
				$xml .= '    <'.$prop.' id="'.$valeur['id'].'">'.$valeur['valeur'].'</'.$prop.'>'."\n";
663
			}
664
		}
665
		$xml .= '</makernote>';
1189 jpm 666
 
1149 gduche 667
		return '';
668
	}
1189 jpm 669
 
1149 gduche 670
	public function obtenirCheminImageOriginale($id_image) {
671
		$nom = $this->convertirIdBddVersNomFichier($id_image, 'O');
672
		$dossier = $this->obtenirDossierPourFormat($id_image,'O');
1189 jpm 673
 
1149 gduche 674
		return $dossier.'/'.$nom;
675
	}
1189 jpm 676
 
1149 gduche 677
	public function convertirIdBddVersNomFichier($id, $format, $extension = 'jpg') {
678
		// creation du format original
679
		$id_avec_zeros = sprintf('%09s', $id) ;
680
		$id_avec_zeros_underscores = wordwrap($id_avec_zeros, 3 , '_', true) ;
1189 jpm 681
 
1149 gduche 682
		$nom_fichier = $id_avec_zeros_underscores.'_'.$format.'.'.$extension;
1189 jpm 683
 
1149 gduche 684
		return $nom_fichier;
685
	}
1189 jpm 686
 
1149 gduche 687
	public function obtenirDossierPourFormat($id, $format) {
688
		$chemin_base = $this->config['cel']['chemin_images'];
1189 jpm 689
 
1149 gduche 690
		$chemin_sur_serveur = $chemin_base;
1189 jpm 691
 
1149 gduche 692
		$id = sprintf('%09s', $id);
693
		$id = wordwrap($id, 3 , '_', true);
1189 jpm 694
 
1149 gduche 695
		list($dossierNiveau1, $dossierNiveau2) = explode('_', $id);
1189 jpm 696
 
1149 gduche 697
		$chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2.'/'.$format;
1189 jpm 698
 
1149 gduche 699
		return $chemin_sur_serveur_final;
700
	}
1189 jpm 701
 
1181 aurelien 702
	private function renvoyerIdPourMigration($utilisateur) {
703
		// si tout les test suivant échouent, on garde l'utilisateur tel quel
704
		// (cas de la chaine de session des utilisateur anonymes)
705
		$retour = $utilisateur;
706
		// si le mail correspond a un utilisateur de la bdd
707
		if (isset($this->tableau_utilisateurs[$utilisateur])) {
708
			// on renvoie son id
709
			$retour =  $this->tableau_utilisateurs[$utilisateur]['id'];
710
		} else {
711
			// sinon si c'est un mail inconnu, on garde le md5
712
			if($this->mailValide($utilisateur)) {
713
				$retour = md5($utilisateur);
714
			}
715
		}
1189 jpm 716
 
1181 aurelien 717
		return $retour;
718
	}
1189 jpm 719
 
1181 aurelien 720
	public function mailValide($mail) {
721
		// vérification bidon mais ça suffit pour ici
1189 jpm 722
		return !(strpos('@',$mail) === false);
1181 aurelien 723
	}
1189 jpm 724
 
1149 gduche 725
	private $tableau_ids_tags_exif = array('InteropIndex' => '1',
726
		'InteropVersion' => '2',
727
		'ProcessingSoftware' => '11',
728
		'SubfileType' => '254',
729
		'OldSubfileType' => '255',
730
		'ImageWidth' => '256',
731
		'ImageHeight' => '257',
732
		'BitsPerSample' => '258',
733
		'Compression' => '259',
734
		'PhotometricInterpretation' => '262',
735
		'Thresholding' => '263',
736
		'CellWidth' => '264',
737
		'CellLength' => '265',
738
		'FillOrder' => '266',
739
		'DocumentName' => '269',
740
		'ImageDescription' => '270',
741
		'Make' => '271',
742
		'Model' => '272',
743
		'StripOffsets' => '273',
744
		'Orientation' => '274',
745
		'SamplesPerPixel' => '277',
746
		'RowsPerStrip' => '278',
747
		'StripByteCounts' => '279',
748
		'MinSampleValue' => '280',
749
		'MaxSampleValue' => '281',
750
		'XResolution' => '282',
751
		'YResolution' => '283',
752
		'PlanarConfiguration' => '284',
753
		'PageName' => '285',
754
		'XPosition' => '286',
755
		'YPosition' => '287',
756
		'FreeOffsets' => '288',
757
		'FreeByteCounts' => '289',
758
		'GrayResponseUnit' => '290',
759
		'GrayResponseCurve' => '291',
760
		'T4Options' => '292',
761
		'T6Options' => '293',
762
		'ResolutionUnit' => '296',
763
		'PageNumber' => '297',
764
		'ColorResponseUnit' => '300',
765
		'TransferFunction' => '301',
766
		'Software' => '305',
767
		'ModifyDate' => '306',
768
		'Artist' => '315',
769
		'HostComputer' => '316',
770
		'Predictor' => '317',
771
		'WhitePoint' => '318',
772
		'PrimaryChromaticities' => '319',
773
		'ColorMap' => '320',
774
		'HalftoneHints' => '321',
775
		'TileWidth' => '322',
776
		'TileLength' => '323',
777
		'TileOffsets' => '324',
778
		'TileByteCounts' => '325',
779
		'BadFaxLines' => '326',
780
		'CleanFaxData' => '327',
781
		'ConsecutiveBadFaxLines' => '328',
782
		'SubIFD' => '330',
783
		'InkSet' => '332',
784
		'InkNames' => '333',
785
		'NumberofInks' => '334',
786
		'DotRange' => '336',
787
		'TargetPrinter' => '337',
788
		'ExtraSamples' => '338',
789
		'SampleFormat' => '339',
790
		'SMinSampleValue' => '340',
791
		'SMaxSampleValue' => '341',
792
		'TransferRange' => '342',
793
		'ClipPath' => '343',
794
		'XClipPathUnits' => '344',
795
		'YClipPathUnits' => '345',
796
		'Indexed' => '346',
797
		'JPEGTables' => '347',
798
		'OPIProxy' => '351',
799
		'GlobalParametersIFD' => '400',
800
		'ProfileType' => '401',
801
		'FaxProfile' => '402',
802
		'CodingMethods' => '403',
803
		'VersionYear' => '404',
804
		'ModeNumber' => '405',
805
		'Decode' => '433',
806
		'DefaultImageColor' => '434',
807
		'T82Options' => '435',
808
		'JPEGTables' => '437',
809
		'JPEGProc' => '512',
810
		'ThumbnailOffset' => '513',
811
		'ThumbnailLength' => '514',
812
		'JPEGRestartInterval' => '515',
813
		'JPEGLosslessPredictors' => '517',
814
		'JPEGPointTransforms' => '518',
815
		'JPEGQTables' => '519',
816
		'JPEGDCTables' => '520',
817
		'JPEGACTables' => '521',
818
		'YCbCrCoefficients' => '529',
819
		'YCbCrSubSampling' => '530',
820
		'YCbCrPositioning' => '531',
821
		'ReferenceBlackWhite' => '532',
822
		'StripRowCounts' => '559',
823
		'ApplicationNotes' => '700',
824
		'USPTOMiscellaneous' => '999',
825
		'RelatedImageFileFormat' => '4096',
826
		'RelatedImageWidth' => '4097',
827
		'RelatedImageHeight' => '4098',
828
		'Rating' => '18246',
829
		'XP_DIP_XML' => '18247',
830
		'StitchInfo' => '18248',
831
		'RatingPercent' => '18249',
832
		'ImageID' => '32781',
833
		'WangTag1' => '32931',
834
		'WangAnnotation' => '32932',
835
		'WangTag3' => '32933',
836
		'WangTag4' => '32934',
837
		'Matteing' => '32995',
838
		'DataType' => '32996',
839
		'ImageDepth' => '32997',
840
		'TileDepth' => '32998',
841
		'Model2' => '33405',
842
		'CFARepeatPatternDim' => '33421',
843
		'CFAPattern2' => '33422',
844
		'BatteryLevel' => '33423',
845
		'KodakIFD' => '33424',
846
		'Copyright' => '33432',
847
		'ExposureTime' => '33434',
848
		'FNumber' => '33437',
849
		'MDFileTag' => '33445',
850
		'MDScalePixel' => '33446',
851
		'MDColorTable' => '33447',
852
		'MDLabName' => '33448',
853
		'MDSampleInfo' => '33449',
854
		'MDPrepDate' => '33450',
855
		'MDPrepTime' => '33451',
856
		'MDFileUnits' => '33452',
857
		'PixelScale' => '33550',
858
		'AdventScale' => '33589',
859
		'AdventRevision' => '33590',
860
		'UIC1Tag' => '33628',
861
		'UIC2Tag' => '33629',
862
		'UIC3Tag' => '33630',
863
		'UIC4Tag' => '33631',
864
		'IPTC-NAA' => '33723',
865
		'IntergraphPacketData' => '33918',
866
		'IntergraphFlagRegisters' => '33919',
867
		'IntergraphMatrix' => '33920',
868
		'INGRReserved' => '33921',
869
		'ModelTiePoint' => '33922',
870
		'Site' => '34016',
871
		'ColorSequence' => '34017',
872
		'IT8Header' => '34018',
873
		'RasterPadding' => '34019',
874
		'BitsPerRunLength' => '34020',
875
		'BitsPerExtendedRunLength' => '34021',
876
		'ColorTable' => '34022',
877
		'ImageColorIndicator' => '34023',
878
		'BackgroundColorIndicator' => '34024',
879
		'ImageColorValue' => '34025',
880
		'BackgroundColorValue' => '34026',
881
		'PixelIntensityRange' => '34027',
882
		'TransparencyIndicator' => '34028',
883
		'ColorCharacterization' => '34029',
884
		'HCUsage' => '34030',
885
		'TrapIndicator' => '34031',
886
		'CMYKEquivalent' => '34032',
887
		'SEMInfo' => '34118',
888
		'AFCP_IPTC' => '34152',
889
		'PixelMagicJBIGOptions' => '34232',
890
		'ModelTransform' => '34264',
891
		'WB_GRGBLevels' => '34306',
892
		'LeafData' => '34310',
893
		'PhotoshopSettings' => '34377',
894
		'ExifOffset' => '34665',
895
		'ICC_Profile' => '34675',
896
		'TIFF_FXExtensions' => '34687',
897
		'MultiProfiles' => '34688',
898
		'SharedData' => '34689',
899
		'T88Options' => '34690',
900
		'ImageLayer' => '34732',
901
		'GeoTiffDirectory' => '34735',
902
		'GeoTiffDoubleParams' => '34736',
903
		'GeoTiffAsciiParams' => '34737',
904
		'ExposureProgram' => '34850',
905
		'SpectralSensitivity' => '34852',
906
		'GPSInfo' => '34853',
907
		'ISO' => '34855',
908
		'Opto-ElectricConvFactor' => '34856',
909
		'Interlace' => '34857',
910
		'TimeZoneOffset' => '34858',
911
		'SelfTimerMode' => '34859',
912
		'SensitivityType' => '34864',
913
		'StandardOutputSensitivity' => '34865',
914
		'RecommendedExposureIndex' => '34866',
915
		'ISOSpeed' => '34867',
916
		'ISOSpeedLatitudeyyy' => '34868',
917
		'ISOSpeedLatitudezzz' => '34869',
918
		'FaxRecvParams' => '34908',
919
		'FaxSubAddress' => '34909',
920
		'FaxRecvTime' => '34910',
921
		'LeafSubIFD' => '34954',
922
		'ExifVersion' => '36864',
923
		'DateTimeOriginal' => '36867',
924
		'CreateDate' => '36868',
925
		'ComponentsConfiguration' => '37121',
926
		'CompressedBitsPerPixel' => '37122',
927
		'ShutterSpeedValue' => '37377',
928
		'ApertureValue' => '37378',
929
		'BrightnessValue' => '37379',
930
		'ExposureCompensation' => '37380',
931
		'MaxApertureValue' => '37381',
932
		'SubjectDistance' => '37382',
933
		'MeteringMode' => '37383',
934
		'LightSource' => '37384',
935
		'Flash' => '37385',
936
		'FocalLength' => '37386',
937
		'FlashEnergy' => '37387',
938
		'SpatialFrequencyResponse' => '37388',
939
		'Noise' => '37389',
940
		'FocalPlaneXResolution' => '37390',
941
		'FocalPlaneYResolution' => '37391',
942
		'FocalPlaneResolutionUnit' => '37392',
943
		'ImageNumber' => '37393',
944
		'SecurityClassification' => '37394',
945
		'ImageHistory' => '37395',
946
		'SubjectArea' => '37396',
947
		'ExposureIndex' => '37397',
948
		'TIFF-EPStandardID' => '37398',
949
		'SensingMethod' => '37399',
950
		'CIP3DataFile' => '37434',
951
		'CIP3Sheet' => '37435',
952
		'CIP3Side' => '37436',
953
		'StoNits' => '37439',
954
		'MakerNoteCanon' => '37500',
955
		'UserComment' => '37510',
956
		'SubSecTime' => '37520',
957
		'SubSecTimeOriginal' => '37521',
958
		'SubSecTimeDigitized' => '37522',
959
		'MSDocumentText' => '37679',
960
		'MSPropertySetStorage' => '37680',
961
		'MSDocumentTextPosition' => '37681',
962
		'ImageSourceData' => '37724',
963
		'XPTitle' => '40091',
964
		'XPComment' => '40092',
965
		'XPAuthor' => '40093',
966
		'XPKeywords' => '40094',
967
		'XPSubject' => '40095',
968
		'FlashpixVersion' => '40960',
969
		'ColorSpace' => '40961',
970
		'ExifImageWidth' => '40962',
971
		'ExifImageHeight' => '40963',
972
		'RelatedSoundFile' => '40964',
973
		'InteropOffset' => '40965',
974
		'FlashEnergy' => '41483',
975
		'SpatialFrequencyResponse' => '41484',
976
		'Noise' => '41485',
977
		'FocalPlaneXResolution' => '41486',
978
		'FocalPlaneYResolution' => '41487',
979
		'FocalPlaneResolutionUnit' => '41488',
980
		'ImageNumber' => '41489',
981
		'SecurityClassification' => '41490',
982
		'ImageHistory' => '41491',
983
		'SubjectLocation' => '41492',
984
		'ExposureIndex' => '41493',
985
		'TIFF-EPStandardID' => '41494',
986
		'SensingMethod' => '41495',
987
		'FileSource' => '41728',
988
		'SceneType' => '41729',
989
		'CFAPattern' => '41730',
990
		'CustomRendered' => '41985',
991
		'ExposureMode' => '41986',
992
		'WhiteBalance' => '41987',
993
		'DigitalZoomRatio' => '41988',
994
		'FocalLengthIn35mmFormat' => '41989',
995
		'SceneCaptureType' => '41990',
996
		'GainControl' => '41991',
997
		'Contrast' => '41992',
998
		'Saturation' => '41993',
999
		'Sharpness' => '41994',
1000
		'DeviceSettingDescription' => '41995',
1001
		'SubjectDistanceRange' => '41996',
1002
		'ImageUniqueID' => '42016',
1003
		'OwnerName' => '42032',
1004
		'SerialNumber' => '42033',
1005
		'LensInfo' => '42034',
1006
		'LensMake' => '42035',
1007
		'LensModel' => '42036',
1008
		'LensSerialNumber' => '42037',
1009
		'GDALMetadata' => '42112',
1010
		'GDALNoData' => '42113',
1011
		'Gamma' => '42240',
1012
		'ExpandSoftware' => '44992',
1013
		'ExpandLens' => '44993',
1014
		'ExpandFilm' => '44994',
1015
		'ExpandFilterLens' => '44995',
1016
		'ExpandScanner' => '44996',
1017
		'ExpandFlashLamp' => '44997',
1018
		'PixelFormat' => '48129',
1019
		'Transformation' => '48130',
1020
		'Uncompressed' => '48131',
1021
		'ImageType' => '48132',
1022
		'ImageWidth' => '48256',
1023
		'ImageHeight' => '48257',
1024
		'WidthResolution' => '48258',
1025
		'HeightResolution' => '48259',
1026
		'ImageOffset' => '48320',
1027
		'ImageByteCount' => '48321',
1028
		'AlphaOffset' => '48322',
1029
		'AlphaByteCount' => '48323',
1030
		'ImageDataDiscard' => '48324',
1031
		'AlphaDataDiscard' => '48325',
1032
		'OceScanjobDesc' => '50215',
1033
		'OceApplicationSelector' => '50216',
1034
		'OceIDNumber' => '50217',
1035
		'OceImageLogic' => '50218',
1036
		'Annotations' => '50255',
1037
		'PrintIM' => '50341',
1038
		'USPTOOriginalContentType' => '50560',
1039
		'DNGVersion' => '50706',
1040
		'DNGBackwardVersion' => '50707',
1041
		'UniqueCameraModel' => '50708',
1042
		'LocalizedCameraModel' => '50709',
1043
		'CFAPlaneColor' => '50710',
1044
		'CFALayout' => '50711',
1045
		'LinearizationTable' => '50712',
1046
		'BlackLevelRepeatDim' => '50713',
1047
		'BlackLevel' => '50714',
1048
		'BlackLevelDeltaH' => '50715',
1049
		'BlackLevelDeltaV' => '50716',
1050
		'WhiteLevel' => '50717',
1051
		'DefaultScale' => '50718',
1052
		'DefaultCropOrigin' => '50719',
1053
		'DefaultCropSize' => '50720',
1054
		'ColorMatrix1' => '50721',
1055
		'ColorMatrix2' => '50722',
1056
		'CameraCalibration1' => '50723',
1057
		'CameraCalibration2' => '50724',
1058
		'ReductionMatrix1' => '50725',
1059
		'ReductionMatrix2' => '50726',
1060
		'AnalogBalance' => '50727',
1061
		'AsShotNeutral' => '50728',
1062
		'AsShotWhiteXY' => '50729',
1063
		'BaselineExposure' => '50730',
1064
		'BaselineNoise' => '50731',
1065
		'BaselineSharpness' => '50732',
1066
		'BayerGreenSplit' => '50733',
1067
		'LinearResponseLimit' => '50734',
1068
		'CameraSerialNumber' => '50735',
1069
		'DNGLensInfo' => '50736',
1070
		'ChromaBlurRadius' => '50737',
1071
		'AntiAliasStrength' => '50738',
1072
		'ShadowScale' => '50739',
1073
		'SR2Private' => '50740',
1074
		'MakerNoteSafety' => '50741',
1075
		'RawImageSegmentation' => '50752',
1076
		'CalibrationIlluminant1' => '50778',
1077
		'CalibrationIlluminant2' => '50779',
1078
		'BestQualityScale' => '50780',
1079
		'RawDataUniqueID' => '50781',
1080
		'AliasLayerMetadata' => '50784',
1081
		'OriginalRawFileName' => '50827',
1082
		'OriginalRawFileData' => '50828',
1083
		'ActiveArea' => '50829',
1084
		'MaskedAreas' => '50830',
1085
		'AsShotICCProfile' => '50831',
1086
		'AsShotPreProfileMatrix' => '50832',
1087
		'CurrentICCProfile' => '50833',
1088
		'CurrentPreProfileMatrix' => '50834',
1089
		'ColorimetricReference' => '50879',
1090
		'PanasonicTitle' => '50898',
1091
		'PanasonicTitle2' => '50899',
1092
		'CameraCalibrationSig' => '50931',
1093
		'ProfileCalibrationSig' => '50932',
1094
		'ProfileIFD' => '50933',
1095
		'AsShotProfileName' => '50934',
1096
		'NoiseReductionApplied' => '50935',
1097
		'ProfileName' => '50936',
1098
		'ProfileHueSatMapDims' => '50937',
1099
		'ProfileHueSatMapData1' => '50938',
1100
		'ProfileHueSatMapData2' => '50939',
1101
		'ProfileToneCurve' => '50940',
1102
		'ProfileEmbedPolicy' => '50941',
1103
		'ProfileCopyright' => '50942',
1104
		'ForwardMatrix1' => '50964',
1105
		'ForwardMatrix2' => '50965',
1106
		'PreviewApplicationName' => '50966',
1107
		'PreviewApplicationVersion' => '50967',
1108
		'PreviewSettingsName' => '50968',
1109
		'PreviewSettingsDigest' => '50969',
1110
		'PreviewColorSpace' => '50970',
1111
		'PreviewDateTime' => '50971',
1112
		'RawImageDigest' => '50972',
1113
		'OriginalRawFileDigest' => '50973',
1114
		'SubTileBlockSize' => '50974',
1115
		'RowInterleaveFactor' => '50975',
1116
		'ProfileLookTableDims' => '50981',
1117
		'ProfileLookTableData' => '50982',
1118
		'OpcodeList1' => '51008',
1119
		'OpcodeList2' => '51009',
1120
		'OpcodeList3' => '51022',
1121
		'NoiseProfile' => '51041',
1122
		'Padding' => '59932',
1123
		'OffsetSchema' => '59933',
1124
		'OwnerName' => '65000',
1125
		'SerialNumber' => '65001',
1126
		'Lens' => '65002',
1127
		'KDC_IFD' => '65024',
1128
		'RawFile' => '65100',
1129
		'Converter' => '65101',
1130
		'WhiteBalance' => '65102',
1131
		'Exposure' => '65105',
1132
		'Shadows' => '65106',
1133
		'Brightness' => '65107',
1134
		'Contrast' => '65108',
1135
		'Saturation' => '65109',
1136
		'Sharpness' => '65110',
1137
		'Smoothness' => '65111',
1138
		'MoireFilter' => '65112',
1139
	);
1189 jpm 1140
 
1149 gduche 1141
	private $tableau_ids_tags_iptc = array('ApplicationRecordVersion' => '0',
1142
		'ObjectTypeReference' => '3',
1143
		'ObjectAttributeReference' => '4',
1144
		'ObjectName' => '5',
1145
		'EditStatus' => '7',
1146
		'EditorialUpdate' => '8',
1147
		'Urgency' => '16',
1148
		'SubjectReference' => '18',
1149
		'Category' => '21',
1150
		'SupplementalCategories' => '32',
1151
		'FixtureIdentifier' => '34',
1152
		'Keywords' => '37',
1153
		'ContentLocationCode' => '38',
1154
		'ContentLocationName' => '39',
1155
		'ReleaseDate' => '48',
1156
		'ReleaseTime' => '53',
1157
		'ExpirationDate' => '55',
1158
		'ExpirationTime' => '56',
1159
		'SpecialInstructions' => '64',
1160
		'ActionAdvised' => '66',
1161
		'ReferenceService' => '69',
1162
		'ReferenceDate' => '71',
1163
		'ReferenceNumber' => '80',
1164
		'DateCreated' => '85',
1165
		'TimeCreated' => '96',
1166
		'DigitalCreationDate' => '98',
1167
		'DigitalCreationTime' => '99',
1168
		'OriginatingProgram' => '101',
1169
		'ProgramVersion' => '112',
1170
		'ObjectCycle' => '117',
1171
		'By-line' => '128',
1172
		'By-lineTitle' => '133',
1173
		'City' => '144',
1174
		'Sub-location' => '146',
1175
		'Province-State' => '149',
1176
		'Country-PrimaryLocationCode' => '256',
1177
		'Country-PrimaryLocationName' => '257',
1178
		'OriginalTransmissionReference' => '259',
1179
		'Headline' => '261',
1180
		'Credit' => '272',
1181
		'Source' => '277',
1182
		'CopyrightNotice' => '278',
1183
		'Contact' => '280',
1184
		'Caption-Abstract' => '288',
1185
		'LocalCaption' => '289',
1186
		'Writer-Editor' => '290',
1187
		'RasterizedCaption' => '293',
1188
		'ImageType' => '304',
1189
		'ImageOrientation' => '305',
1190
		'LanguageIdentifier' => '309',
1191
		'AudioType' => '336',
1192
		'AudioSamplingRate' => '337',
1193
		'AudioSamplingResolution' => '338',
1194
		'AudioDuration' => '339',
1195
		'AudioOutcue' => '340',
1196
		'JobID' => '388',
1197
		'MasterDocumentID' => '389',
1198
		'ShortDocumentID' => '390',
1199
		'UniqueDocumentID' => '391',
1200
		'OwnerID' => '392',
1201
		'ObjectPreviewFileFormat' => '512',
1202
		'ObjectPreviewFileVersion' => '513',
1203
		'ObjectPreviewData' => '514',
1204
		'Prefs' => '545',
1205
		'ClassifyState' => '549',
1206
		'SimilarityIndex' => '552',
1207
		'DocumentNotes' => '560',
1208
		'DocumentHistory' => '561',
1209
		'ExifCameraInfo' => '562',
1210
		'CatalogSets' => '597',
1211
	);
1212
}