3fb6caba6eb4250690b0def590b9f986b018c277
[lhc/web/clavette_www.git] / www / plugins-dist / medias / metadata / image.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 function metadata_image_dist($fichier){
16 $meta = array();
17
18 if ($size_image = @getimagesize($fichier)) {
19 $meta['largeur'] = intval($size_image[0]);
20 $meta['hauteur'] = intval($size_image[1]);
21 $meta['type_image'] = decoder_type_image($size_image[2]);
22 }
23
24 return $meta;
25 }
26
27 /**
28 * Convertit le type numerique retourne par getimagesize() en extension fichier
29 *
30 * @param int $type
31 * @param bool $strict
32 * @return string
33 */
34 // http://doc.spip.org/@decoder_type_image
35 function decoder_type_image($type, $strict = false) {
36 switch ($type) {
37 case 1:
38 return "gif";
39 case 2:
40 return "jpg";
41 case 3:
42 return "png";
43 case 4:
44 return $strict ? "" : "swf";
45 case 5:
46 return "psd";
47 case 6:
48 return "bmp";
49 case 7:
50 case 8:
51 return "tif";
52 default:
53 return "";
54 }
55 }
56 ?>