Skip to content
Extraits de code Groupes Projets
Valider 312705a8 rédigé par ARNO*'s avatar ARNO*
Parcourir les fichiers

Correction spip_image_reduite et affin'e choix netpbm

parent aa2c6583
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -79,6 +79,7 @@ else {
if ($image_process) {
ecrire_meta('image_process', $image_process);
ecrire_metas(); // Puisque le switch se fait par lire_meta.
// mettre a jour les formats graphiques lisibles
switch (lire_meta('image_process')) {
case 'gd1':
......@@ -88,7 +89,7 @@ else {
$formats_graphiques = lire_meta('gd_formats');
break;
case 'netpbm':
$formats_graphiques = 'jpg';
$formats_graphiques = lire_meta('gd_formats');
break;
case 'convert':
$formats_graphiques = 'gif,jpg,png';
......
......@@ -197,7 +197,7 @@ function creer_vignette($image, $maxWidth, $maxHeight, $format, $destdir, $destf
$formats_sortie = array('png','jpg','gif');
else
$formats_sortie = array('jpg','png','gif');
if ($process == 'AUTO')
$process = lire_meta('image_process');
......@@ -258,11 +258,26 @@ function creer_vignette($image, $maxWidth, $maxHeight, $format, $destdir, $destf
}
}
if ($process == "netpbm") {
$format_sortie = "jpg";
$vignette = $destination.".".$format_sortie;
if ($format == "jpg") {
$vignette = $destination.".".$format;
exec("$djpeg_command $image | $pnmscale_command -width $destWidth | $cjpeg_command -outfile $vignette");
if (!@file_exists($vignette)) {
spip_log("echec netpbm sur $vignette");
spip_log("echec netpbm-jpg sur $vignette");
return;
}
} else if ($format == "gif") {
$giftopnm_command = ereg_replace("pnmscale", "giftopnm", $pnmscale_command);
exec("$giftopnm_command $image | $pnmscale_command -width $destWidth | $cjpeg_command -outfile $vignette");
if (!@file_exists($vignette)) {
spip_log("echec netpbm-gif sur $vignette");
return;
}
} else if ($format == "png") {
$pngtopnm_command = ereg_replace("pnmscale", "pngtopnm", $pnmscale_command);
exec("$pngtopnm_command $image | $pnmscale_command -width $destWidth | $cjpeg_command -outfile $vignette");
if (!@file_exists($vignette)) {
spip_log("echec netpbm-png sur $vignette");
return;
}
}
......
......@@ -12,12 +12,10 @@ if (defined("_INC_PUBLIC")) {
if ($page['lang_select'])
lang_dselect();
}
// Premier appel inc-public
else {
define("_INC_PUBLIC", "1");
include ("ecrire/inc_version.php3");
//
// Initialisations
//
......
......@@ -44,7 +44,8 @@ function effacer_image($nom) {
}
function tester_vignette ($test_vignette) {
// verifier les formats acceptes par GD
global $djpeg_command, $cjpeg_command, $pnmscale_command;
// verifier les formats acceptes par GD
if ($test_vignette == "gd1") {
$gd_formats = Array();
if (function_exists('ImageCreateFromJPEG')) {
......@@ -69,6 +70,41 @@ function tester_vignette ($test_vignette) {
}
}
if ($gd_formats) $gd_formats = join(",", $gd_formats);
ecrire_meta("gd_formats", $gd_formats);
ecrire_metas();
}
// verifier les formats netpbm
else if ($test_vignette == "netpbm") {
$gd_formats = Array();
$vignette = _DIR_IMG . "test.jpg";
$dest = _DIR_IMG . "test-10.jpg";
exec("$djpeg_command $vignette | $pnmscale_command -width 10 | $cjpeg_command -outfile $dest");
if ($taille = @getimagesize($dest)) {
if ($taille[1] == 10) $gd_formats[] = "jpg";
}
ImageDestroy( $dest );
$giftopnm_command = ereg_replace("pnmscale", "giftopnm", $pnmscale_command);
$vignette = _DIR_IMG . "test.gif";
$dest = _DIR_IMG . "test-gif.jpg";
exec("$giftopnm_command $vignette | $pnmscale_command -width 10 | $cjpeg_command -outfile $dest");
if ($taille = @getimagesize($dest)) {
if ($taille[1] == 10) $gd_formats[] = "gif";
}
ImageDestroy( $dest );
$pngtopnm_command = ereg_replace("pnmscale", "pngtopnm", $pnmscale_command);
$vignette = _DIR_IMG . "test.png";
$dest = _DIR_IMG . "test-gif.jpg";
exec("$pngtopnm_command $vignette | $pnmscale_command -width 10 | $cjpeg_command -outfile $dest");
if ($taille = @getimagesize($dest)) {
if ($taille[1] == 10) $gd_formats[] = "png";
}
ImageDestroy( $dest );
if ($gd_formats) $gd_formats = join(",", $gd_formats);
ecrire_meta("gd_formats", $gd_formats);
ecrire_metas();
......
......@@ -7,12 +7,12 @@ include_ecrire("inc_admin.php3");
if (!$taille_y)
$taille_y = $taille_x;
if (eregi("(.*)\.(jpg|gif|png)$", $logo, $regs)) {
if ($i = cherche_image_nommee($regs[1], array($regs[2]))
AND verifier_action_auteur("reduire $taille_x $taille_y", $hash, $hash_id_auteur))
{
list($dir,$nom,$format) = $i;
list($dir,$nom,$format) = $i;
$logo = $dir . $nom . '.' . $format;
include_ecrire("inc_logos.php3");
$suffixe = '-'.$taille_x.'x'.$taille_y;
......@@ -24,11 +24,10 @@ if (eregi("(.*)\.(jpg|gif|png)$", $logo, $regs)) {
//echo "<img src='$vignette' name='$name' border='0' align='$align' alt='' hspace='$espace' vspace='$espace' width='$width' height='$height' class='spip_logos' />";
$retour = $vignette;
}
else if ($taille_origine = getimagesize($logo))
list ($destWidth,$destHeight) = image_ratio($taille_origine[0], $taille_origine[1], $taille_x, $taille_y);
//echo "<img src='$logo' name='$name' width='$destWidth' height='$destHeight' border='0' align='$align' alt='' hspace='$espace' vspace='$espace' class='spip_logos' />";
$retour = $logo;
else if ($taille_origine = getimagesize($logo)) {
//list ($destWidth,$destHeight) = image_ratio($taille_origine[0], $taille_origine[1], $taille_x, $taille_y);
$retour = $logo;
}
// Afficher l'image resultante, meme grande...
// header("Content-type: image/$format");
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter