3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2007 *
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;
14 include_spip('inc/meta');
16 // Tester nos capacites
17 // http://doc.spip.org/@action_tester_dist
18 function action_tester_dist() {
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);
80 // verifier les formats netpbm
81 else if ($arg == "netpbm") {
82 define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options
83 if (_PNMSCALE_COMMAND
== '') return;
84 $netpbm_formats= Array();
86 $jpegtopnm_command = str_replace("pnmscale",
87 "jpegtopnm", _PNMSCALE_COMMAND
);
88 $pnmtojpeg_command = str_replace("pnmscale",
89 "pnmtojpeg", _PNMSCALE_COMMAND
);
91 $vignette = _ROOT_IMG_PACK
."test.jpg";
92 $dest = _DIR_VAR
. "test-jpg.jpg";
93 $commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND
." -width 10 | $pnmtojpeg_command > $dest";
96 if ($taille = @getimagesize($dest)) {
97 if ($taille[1] == 10) $netpbm_formats[] = "jpg";
99 $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND
);
100 $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND
);
101 $vignette = _ROOT_IMG_PACK
."test.gif";
102 $dest = _DIR_VAR
. "test-gif.jpg";
103 $commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND
." -width 10 | $pnmtojpeg_command > $dest";
106 if ($taille = @getimagesize($dest)) {
107 if ($taille[1] == 10) $netpbm_formats[] = "gif";
110 $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND
);
111 $vignette = _ROOT_IMG_PACK
."test.png";
112 $dest = _DIR_VAR
. "test-gif.jpg";
113 $commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND
." -width 10 | $pnmtojpeg_command > $dest";
116 if ($taille = @getimagesize($dest)) {
117 if ($taille[1] == 10) $netpbm_formats[] = "png";
122 $netpbm_formats = join(",", $netpbm_formats);
124 $netpbm_formats = '';
125 ecrire_meta("netpbm_formats", $netpbm_formats);
129 // et maintenant envoyer la vignette de tests
130 if (ereg("^(gd1|gd2|imagick|convert|netpbm)$", $arg)) {
131 include_spip('inc/filtres');
132 include_spip('inc/filtres_images');
133 //$taille_preview = $GLOBALS['meta']["taille_preview"];
134 if ($taille_preview < 10) $taille_preview = 150;
135 $image = image_valeurs_trans(_ROOT_IMG_PACK
.'test_image.jpg',"reduire-$taille_preview-$taille_preview",'jpg');
137 $image['fichier_dest']=_DIR_VAR
."test_$arg";
138 if ($preview = image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true
)
139 AND ($preview['width'] * $preview['height'] > 0))
140 redirige_par_entete($preview['fichier']);
144 redirige_par_entete(_DIR_IMG_PACK
. 'puce-rouge-anim.gif');