[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/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-2016 *
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')) {
14 return;
15 }
16
17 function metadata_image_dist($fichier) {
18 $meta = array();
19
20 if ($size_image = @getimagesize($fichier)) {
21 $meta['largeur'] = intval($size_image[0]);
22 $meta['hauteur'] = intval($size_image[1]);
23 $meta['type_image'] = decoder_type_image($size_image[2]);
24 }
25
26 return $meta;
27 }
28
29 /**
30 * Convertit le type numerique retourne par getimagesize() en extension fichier
31 *
32 * @param int $type
33 * @param bool $strict
34 * @return string
35 */
36 // https://code.spip.net/@decoder_type_image
37 function decoder_type_image($type, $strict = false) {
38 switch ($type) {
39 case 1:
40 return 'gif';
41 case 2:
42 return 'jpg';
43 case 3:
44 return 'png';
45 case 4:
46 return $strict ? '' : 'swf';
47 case 5:
48 return 'psd';
49 case 6:
50 return 'bmp';
51 case 7:
52 case 8:
53 return 'tif';
54 default:
55 return '';
56 }
57 }