3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
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 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
15 // Tester nos capacites
16 // http://doc.spip.org/@action_tester_dist
17 function action_tester_dist() {
18 $arg = _request('arg');
20 $gd_formats = $gd_formats_read_gif = "";
21 // verifier les formats acceptes par GD
23 // Si GD est installe et php >= 4.0.2
24 if (function_exists('imagetypes')) {
26 if (imagetypes() & IMG_GIF
) {
27 $gd_formats[] = "gif";
29 # Attention GD sait lire le gif mais pas forcement l'ecrire
30 if (function_exists('ImageCreateFromGIF')) {
31 $srcImage = @ImageCreateFromGIF
(_ROOT_IMG_PACK
."test.gif");
33 $gd_formats_read_gif = ",gif";
34 ImageDestroy( $srcImage );
39 if (imagetypes() & IMG_JPG
)
40 $gd_formats[] = "jpg";
41 if (imagetypes() & IMG_PNG
)
42 $gd_formats[] = "png";
45 else { # ancienne methode de detection des formats, qui en plus
46 # est bugguee car elle teste les formats en lecture
47 # alors que la valeur deduite sert a identifier
48 # les formats disponibles en ecriture... (cf. inc_logos)
50 $gd_formats = Array();
51 if (function_exists('ImageCreateFromJPEG')) {
52 $srcImage = @ImageCreateFromJPEG
(_ROOT_IMG_PACK
."test.jpg");
54 $gd_formats[] = "jpg";
55 ImageDestroy( $srcImage );
58 if (function_exists('ImageCreateFromGIF')) {
59 $srcImage = @ImageCreateFromGIF
(_ROOT_IMG_PACK
."test.gif");
61 $gd_formats[] = "gif";
62 ImageDestroy( $srcImage );
65 if (function_exists('ImageCreateFromPNG')) {
66 $srcImage = @ImageCreateFromPNG
(_ROOT_IMG_PACK
."test.png");
68 $gd_formats[] = "png";
69 ImageDestroy( $srcImage );
74 if ($gd_formats) $gd_formats = join(",", $gd_formats);
75 ecrire_meta("gd_formats_read", $gd_formats.$gd_formats_read_gif);
76 ecrire_meta("gd_formats", $gd_formats);
79 // verifier les formats netpbm
80 else if ($arg == "netpbm") {
81 define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options
82 if (_PNMSCALE_COMMAND
== '') return;
83 $netpbm_formats= Array();
85 $jpegtopnm_command = str_replace("pnmscale",
86 "jpegtopnm", _PNMSCALE_COMMAND
);
87 $pnmtojpeg_command = str_replace("pnmscale",
88 "pnmtojpeg", _PNMSCALE_COMMAND
);
90 $vignette = _ROOT_IMG_PACK
."test.jpg";
91 $dest = _DIR_VAR
. "test-jpg.jpg";
92 $commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND
." -width 10 | $pnmtojpeg_command > $dest";
95 if ($taille = @getimagesize
($dest)) {
96 if ($taille[1] == 10) $netpbm_formats[] = "jpg";
98 $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND
);
99 $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND
);
100 $vignette = _ROOT_IMG_PACK
."test.gif";
101 $dest = _DIR_VAR
. "test-gif.jpg";
102 $commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND
." -width 10 | $pnmtojpeg_command > $dest";
105 if ($taille = @getimagesize
($dest)) {
106 if ($taille[1] == 10) $netpbm_formats[] = "gif";
109 $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND
);
110 $vignette = _ROOT_IMG_PACK
."test.png";
111 $dest = _DIR_VAR
. "test-gif.jpg";
112 $commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND
." -width 10 | $pnmtojpeg_command > $dest";
115 if ($taille = @getimagesize
($dest)) {
116 if ($taille[1] == 10) $netpbm_formats[] = "png";
121 $netpbm_formats = join(",", $netpbm_formats);
123 $netpbm_formats = '';
124 ecrire_meta("netpbm_formats", $netpbm_formats);
127 // et maintenant envoyer la vignette de tests
128 if (in_array($arg,array("gd1","gd2","imagick","convert","netpbm"))) {
129 include_spip('inc/filtres');
130 include_spip('inc/filtres_images_mini');
131 $taille_preview = 150;
132 $image = _image_valeurs_trans(_DIR_IMG_PACK
.'test_image.jpg',"reduire-$taille_preview-$taille_preview",'jpg');
134 $image['fichier_dest']=_DIR_VAR
."test_$arg";
135 if ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true)
136 AND ($preview['width'] * $preview['height'] > 0))
137 redirige_par_entete($preview['fichier']);
141 redirige_par_entete(chemin_image('puce-rouge-anim.gif'));