Je viens d'ecrire un script Php qui dois redimensionner mes images de la base de données de façon proportionel mais malheureusement cela ne fonctionne pas. prière de jetter un coup d'oeil sur le script et de m'aider.
Ma base de données cointient la table photos qui a 2 champs (id_photo,nom).
Je colle ici le script pour que vous le regardez.
<?
ob_start();
///////////////////////////////////////////
/// Paramètres de connexion
//////////////////////////////////////////
$host="localhost";//Nom de l'hôte
$data_user="root";//Nom de l'utilisateur
$pwd="";//Mot de passe
$conn = mysql_connect("$host", "$data_user", "$pwd");//connexion au serveur
mysql_select_db("abidjancel",$conn);//Connexion à la base de données
/////////////////////////////////////////////////////
$sql=mysql_query("select *from photos order by id_photo DESC",$conn); //execution de la requette SQL
$result=mysql_fetch_assoc($sql);
$num=mysql_num_rows($sql); //Nbre d'enregistrement
?>
<?php
while ($num>0)
{
//nom du dossier où les photos sont stockées
$path="photos/";
// nom du fichier
$fichier = $path.$result['nom'];
//echo $fichier;
// Définition de la largeur et de la hauteur maximale
$width = 200;
$height = 200;
// Content type
header('Content-type: image/jpeg');
// Cacul des nouvelles dimensions
list($width_orig, $height_orig) = getimagesize($fichier);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
// Redimensionnement
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($fichier);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Affichage la photo redimensionnée
imagejpeg($image_p, null, 100);
$num=$num-1;
$result=mysql_fetch_assoc($sql);
}
?>
merci pour votre aide