[ Index ] |
|
Code source de SPIP 1.9.2c |
1 <?php 2 3 /***************************************************************************\ 4 * SPIP, Systeme de publication pour l'internet * 5 * * 6 * Copyright (c) 2001-2007 * 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 include_spip('inc/meta'); 15 16 // Tester nos capacites 17 // http://doc.spip.org/@action_tester_dist 18 function action_tester_dist() { 19 global $arg; 20 21 // verifier les formats acceptes par GD 22 if ($arg == "gd1") { 23 // Si GD est installe et php >= 4.0.2 24 if (function_exists('imagetypes')) { 25 26 if (imagetypes() & IMG_GIF) { 27 $gd_formats[] = "gif"; 28 } else { 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"); 32 if ($srcImage) { 33 $gd_formats_read_gif = ",gif"; 34 ImageDestroy( $srcImage ); 35 } 36 } 37 } 38 39 if (imagetypes() & IMG_JPG) 40 $gd_formats[] = "jpg"; 41 if (imagetypes() & IMG_PNG) 42 $gd_formats[] = "png"; 43 } 44 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) 49 50 $gd_formats = Array(); 51 if (function_exists('ImageCreateFromJPEG')) { 52 $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK."test.jpg"); 53 if ($srcImage) { 54 $gd_formats[] = "jpg"; 55 ImageDestroy( $srcImage ); 56 } 57 } 58 if (function_exists('ImageCreateFromGIF')) { 59 $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); 60 if ($srcImage) { 61 $gd_formats[] = "gif"; 62 ImageDestroy( $srcImage ); 63 } 64 } 65 if (function_exists('ImageCreateFromPNG')) { 66 $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK."test.png"); 67 if ($srcImage) { 68 $gd_formats[] = "png"; 69 ImageDestroy( $srcImage ); 70 } 71 } 72 } 73 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); 77 ecrire_metas(); 78 } 79 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(); 85 86 $jpegtopnm_command = str_replace("pnmscale", 87 "jpegtopnm", _PNMSCALE_COMMAND); 88 $pnmtojpeg_command = str_replace("pnmscale", 89 "pnmtojpeg", _PNMSCALE_COMMAND); 90 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"; 94 spip_log($commande); 95 exec($commande); 96 if ($taille = @getimagesize($dest)) { 97 if ($taille[1] == 10) $netpbm_formats[] = "jpg"; 98 } 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"; 104 spip_log($commande); 105 exec($commande); 106 if ($taille = @getimagesize($dest)) { 107 if ($taille[1] == 10) $netpbm_formats[] = "gif"; 108 } 109 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"; 114 spip_log($commande); 115 exec($commande); 116 if ($taille = @getimagesize($dest)) { 117 if ($taille[1] == 10) $netpbm_formats[] = "png"; 118 } 119 120 121 if ($netpbm_formats) 122 $netpbm_formats = join(",", $netpbm_formats); 123 else 124 $netpbm_formats = ''; 125 ecrire_meta("netpbm_formats", $netpbm_formats); 126 ecrire_metas(); 127 } 128 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'); 136 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']); 141 } 142 143 # image echec 144 redirige_par_entete(_DIR_IMG_PACK . 'puce-rouge-anim.gif'); 145 } 146 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 10:20:27 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |