Page 1 sur 1

fonction codé en php4 ne fonctionne en php5

Posté : 10 janv. 2009, 23:33
par stefane321
Bonjour,

J'ai une fonction que j'utilise depuis longtemps sur mon site afin de redimensionner mes images.

Depuis que mon hébergeur est passé de php4 vers php5 ma fonction ne fonctionne plus et ne trouve pas comment corriger le problème;
function resize_images($max_width, $max_height, $img_path)
{
	$maxwidth = $max_width;
	$maxheight = $max_height;
	$imgpath = $img_path;
	$imagehw = GetImageSize("$imgpath");
	$imagewidth = $imagehw[0];
	$imageheight = $imagehw[1];
	if($imagewidth >= $imageheight)
	{
		if ($imagewidth > $maxwidth)
		{
			$imageprop = ($maxwidth*100)/$imagewidth;
			$imagevsize = ($imageheight*$imageprop)/100 ;
			$r_width = $maxwidth; 
			$r_height = ceil($imagevsize);
		}
		else
		{
			$r_width = $imagewidth;
			$r_height = $imageheight;
		}
	$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight");
	
	}
	else
	{
		if ($imageheight > $maxheight)
		{
			$imageprop = ($maxheight*100)/$imageheight;
			$imagevsize = ($imagewidth*$imageprop)/100 ;
			$r_width = ceil($imagevsize); 
			$r_height = $maxheight; 
		}
		else
		{
			$r_width = $imagewidth;
			$r_height = $imageheight;
		}
	$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight");
	
	}
return $returned;
}
J'appel la fonction comme ceci:
$newwidth=resize_images("250", "250", "$url_racine/produits/img_prod/icones/".$row["image"]."") or die("rezine width erreur");
echo "<a href=\"produits_details.php?id=".$row["id"]."\"><img src=\"produits/img_prod/icones/".$row["image"]."\" border=\"0\" width='".$newwidth[0]."' height='".$newwidth[1]."' alt=\"".$row["name_".$_SESSION["lang"].""]."\"></a>\n";
Pouvez-vous m'aider svp?

Merci!

Posté : 11 janv. 2009, 00:07
par jojolapine
Quelles sont les erreurs?
Vérifie que l'affichage des erreurs est bien activé

Posté : 11 janv. 2009, 00:14
par stefane321
L'erreur est que l'image n'est pas redimensionné

Comment on fait pour activer l'affichage des erreurs?

Merci

Posté : 11 janv. 2009, 00:53
par jojolapine

Posté : 11 janv. 2009, 12:13
par Aureusms
L'erreur est que l'image n'est pas redimensionné

Comment on fait pour activer l'affichage des erreurs?

Merci
Pour afficher des erreurs qui ne sont pas là (en clair tout se passe bien mais tu ne vois rien). Tu n'a qu'à utiliser des mouchards.

Exemple dans ta fonction où tu as
$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight"); 
, il suffit d'ajouter
$returned = array("$r_width", "$r_height", "$imagewidth", "$imageheight"); 
echo '<pre>'; print_r ($returned); echo '</pre>';
Cela te montrera ton tableau $returned et si il manque des variables (ex. $r_width est vide ou quelque chose comme cela) ton mouchard te donneras une piste. On appelle cela la méthode au bouchon.

Posté : 12 janv. 2009, 03:27
par stefane321
C'est réglé ... le problème était que mon hébergeur avait fermé url_fopen