X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Faction%2Ftester.php;fp=www%2Fecrire%2Faction%2Ftester.php;h=8873f3a0956e76e9816fa842dd93555b98b85d8d;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/ecrire/action/tester.php b/www/ecrire/action/tester.php new file mode 100644 index 0000000..8873f3a --- /dev/null +++ b/www/ecrire/action/tester.php @@ -0,0 +1,142 @@ += 4.0.2 + if (function_exists('imagetypes')) { + + if (imagetypes() & IMG_GIF) { + $gd_formats[] = "gif"; + } else { + # Attention GD sait lire le gif mais pas forcement l'ecrire + if (function_exists('ImageCreateFromGIF')) { + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); + if ($srcImage) { + $gd_formats_read_gif = ",gif"; + ImageDestroy( $srcImage ); + } + } + } + + if (imagetypes() & IMG_JPG) + $gd_formats[] = "jpg"; + if (imagetypes() & IMG_PNG) + $gd_formats[] = "png"; + } + + else { # ancienne methode de detection des formats, qui en plus + # est bugguee car elle teste les formats en lecture + # alors que la valeur deduite sert a identifier + # les formats disponibles en ecriture... (cf. inc_logos) + + $gd_formats = Array(); + if (function_exists('ImageCreateFromJPEG')) { + $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK."test.jpg"); + if ($srcImage) { + $gd_formats[] = "jpg"; + ImageDestroy( $srcImage ); + } + } + if (function_exists('ImageCreateFromGIF')) { + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK."test.gif"); + if ($srcImage) { + $gd_formats[] = "gif"; + ImageDestroy( $srcImage ); + } + } + if (function_exists('ImageCreateFromPNG')) { + $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK."test.png"); + if ($srcImage) { + $gd_formats[] = "png"; + ImageDestroy( $srcImage ); + } + } + } + + if ($gd_formats) $gd_formats = join(",", $gd_formats); + ecrire_meta("gd_formats_read", $gd_formats.$gd_formats_read_gif); + ecrire_meta("gd_formats", $gd_formats); + } + + // verifier les formats netpbm + else if ($arg == "netpbm") { + define('_PNMSCALE_COMMAND', 'pnmscale'); // chemin a changer dans mes_options + if (_PNMSCALE_COMMAND == '') return; + $netpbm_formats= Array(); + + $jpegtopnm_command = str_replace("pnmscale", + "jpegtopnm", _PNMSCALE_COMMAND); + $pnmtojpeg_command = str_replace("pnmscale", + "pnmtojpeg", _PNMSCALE_COMMAND); + + $vignette = _ROOT_IMG_PACK."test.jpg"; + $dest = _DIR_VAR . "test-jpg.jpg"; + $commande = "$jpegtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; + spip_log($commande); + exec($commande); + if ($taille = @getimagesize($dest)) { + if ($taille[1] == 10) $netpbm_formats[] = "jpg"; + } + $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND); + $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND); + $vignette = _ROOT_IMG_PACK."test.gif"; + $dest = _DIR_VAR . "test-gif.jpg"; + $commande = "$giftopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; + spip_log($commande); + exec($commande); + if ($taille = @getimagesize($dest)) { + if ($taille[1] == 10) $netpbm_formats[] = "gif"; + } + + $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND); + $vignette = _ROOT_IMG_PACK."test.png"; + $dest = _DIR_VAR . "test-gif.jpg"; + $commande = "$pngtopnm_command $vignette | "._PNMSCALE_COMMAND." -width 10 | $pnmtojpeg_command > $dest"; + spip_log($commande); + exec($commande); + if ($taille = @getimagesize($dest)) { + if ($taille[1] == 10) $netpbm_formats[] = "png"; + } + + + if ($netpbm_formats) + $netpbm_formats = join(",", $netpbm_formats); + else + $netpbm_formats = ''; + ecrire_meta("netpbm_formats", $netpbm_formats); + } + + // et maintenant envoyer la vignette de tests + if (in_array($arg,array("gd1","gd2","imagick","convert","netpbm"))) { + include_spip('inc/filtres'); + include_spip('inc/filtres_images_mini'); + $taille_preview = 150; + $image = _image_valeurs_trans(_DIR_IMG_PACK.'test_image.jpg',"reduire-$taille_preview-$taille_preview",'jpg'); + + $image['fichier_dest']=_DIR_VAR."test_$arg"; + if ($preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) + AND ($preview['width'] * $preview['height'] > 0)) + redirige_par_entete($preview['fichier']); + } + + # image echec + redirige_par_entete(chemin_image('puce-rouge-anim.gif')); +} +?>