je souhaite redimensionner à l'affichage des photos qui sont uploadées dans une base de données en taille 460x352 aussi bien les chats que sur les chatons voir page exemple : http://www.chats-persans.com/_fr/fiche. ... d_chat=236 ou bien alors je souhaite que les photos soit redimensionnées lors de l'upload.
Merci pour votre aide.
Voici le code ma page ou les photos s'affichent :
Code : Tout sélectionner
<?php
header('Content-Type: text/html; charset=utf-8');
include "../admin/image.class.php";
if(!isset($_GET['lg'])) $_GLOBAL['lg'] = 'fr';
else $_GLOBAL['lg'] = $_GET['lg'];
include 'php/mysql.inc.php';
include_once '../php/chatterie.inc.php';
$fiche = fiche($_GET['id']);
$id = $_GET['id'];
$requete = "
SELECT id_chats, type_chats, img_ronde, img_carre, nom_chats, desc_chats, race_chats, dispo_chats, pere_chats, mere_chats, ligne_chats, sexe_chats, place
FROM adh_chats
WHERE id_chatterie = '".$id."'
ORDER BY place DESC";
$result = mysql_query($requete);
$m = 0;
$f = 0;
$c = 0;
while ($tab = mysql_fetch_array($result)):
//print_r($tab);
if(!isset($_GET['id_chat']) AND !isset($details_c)) $details_c = @getimagesize("../upimages/".$tab['img_carre']);
if(!isset($_GET['id_chat']) AND !isset($file_c)) $file_c = "../upimages/".$tab['img_carre'];
if(!isset($_GET['id_chat']) AND !isset($nom)) $nom = utf8_encode($tab['nom_chats']);
if(!isset($_GET['id_chat']) AND !isset($desc)) $desc = utf8_encode($tab['race_chats']);
if($tab['type_chats'] != 3)
$file = "../upimages/".$tab['img_ronde'];
else
$file = "../upimages/".$tab['img_carre'];
$details = @getimagesize($file);
// ---------------------------------------------------------------------------------------
// fonction de redimensionnement A L'AFFICHAGE
// ---------------------------------------------------------------------------------------
// La FONCTION : fctaffichimage($img_Src, $W_max, $H_max)
// Les parametres :
// - $img_Src : URL (chemin + NOM) de l image Source
// - $W_max : LARGEUR maxi finale ----> ou 0 : largeur libre
// - $H_max : HAUTEUR maxi finale ----> ou 0 : hauteur libre
// ---------------------------------------------------------------------------------------
// Affiche : src="..." width="..." height="..." pour la balise img
// Utilisation :
// <img alt="" <?php fctaffichimage('repimg/monimage.jpg', 120, 100)
if (file_exists($file)) {
// ----------------------------------------------------
// Lit les dimensions de l'image source
$img_size = GetImageSize($file);
$W_file = $img_size[0]; // largeur source
$H_file = $img_size[1]; // hauteur source
// ----------------------------------------------------
if(!$W_max) { $W_max = 460; }
if(!$H_max) { $H_max = 352; }
// ----------------------------------------------------
// Teste les dimensions tenant dans la zone
//$W_test = round($W_file * ($H_max / $H_file));
//$H_test = round($H_file * ($W_max / $W_file));
// ----------------------------------------------------
// si l image est plus petite que la zone
if($W_file<$W_max && $H_file<$H_max) {
$W = $W_file;
$H = $H_file;
// sinon si $W_max et $H_max non definis
} elseif($W_max==0 && $H_max==0) {
$W = $W_file;
$H = $H_file;
// sinon si $W_max libre
} elseif($W_max==0) {
$W = $W_test;
$H = $H_max;
// sinon si $H_max libre
} elseif($H_max==0) {
$W = $W_max;
$H = $H_test;
// sinon les dimensions qui tiennent dans la zone
} elseif($H_test > $H_max) {
$W = $W_test;
$H = $H_max;
} else {
$W = $W_max;
$H = $H_test;
}
// ----------------------------------------------------
} else { // si le fichier image n existe pas
$W = 0;
$H = 0;
}
// ----------------------------------------------------
// AFFICHE les dimensions optimales
//echo ' src="'.$img_file.'" width="'.$W.'" height="'.$H.'"';
// Affiche : src="..." width="..." height="..." pour la balise img
// ---------------------------------------------------------------------------------------
if($tab['id_chats'] == $_GET['id_chat']):
$file_c = "../upimages/".$tab['img_carre'];
$details_c = getimagesize($file_c);
$nom = utf8_encode($tab['nom_chats']);
$desc = utf8_encode($tab['race_chats']);
endif;
if($tab['type_chats'] == "1"):
$male[$m]['img'] = "<td width=\"10%\"><div align=\"center\"><a href=\"fiche.php?id=".$id."&id_chat=".$tab['id_chats']."\"><img src=\"".$file."\" width=\"".$details[0]."\" height=\"".$details[1]."\" border=\"0\" alt=\"male\" /></a></div></td>\n";
$male[$m]['desc'] = $tab['desc_chats'];
$male[$m]['nom'] = $tab['nom_chats'];
$male[$m]['pere'] = $tab['pere_chats'];
$male[$m]['mere'] = $tab['mere_chats'];
$male[$m]['ligne'] = $tab['ligne_chats'];
$m++;
elseif($tab['type_chats'] == "2"):
$femelle[$f]['img'] = "<td width=\"10%\"><div align=\"center\"><a href=\"fiche.php?id=".$id."&id_chat=".$tab['id_chats']."\"><img src=\"".$file."\" width=\"".$details[0]."\" height=\"".$details[1]."\" border=\"0\" alt=\"femelle\"/></a></div></td>\n";
$femelle[$f]['desc'] = $tab['desc_chats'];
$femelle[$f]['nom'] = $tab['nom_chats'];
$femelle[$f]['pere'] = $tab['pere_chats'];
$femelle[$f]['mere'] = $tab['mere_chats'];
$femelle[$f]['ligne'] = $tab['ligne_chats'];
$f++;
elseif($tab['type_chats'] == "3" || $tab['type_chats'] == 1 || $tab['type_chats'] == 2):
if($details[0]>=460 || $details[1]>=352):
//echo 'redim';
$img=new image($file);
$img->transformeImage('redimension',460,352);
$img->sauvegarderImage2($file);
$img->detruireImage();
//$details[0]=200;
//$details[1]=134;
endif;
$retaille=$details[0];
$retaille2=$details[1];
$chaton[$c]['img'] = "<td width=\"50%\"><div align=\"center\"><img src=\"".$file."\" width=\"".$retaille."\" height=\"".$retaille2."\" border=\"0\" alt=\"chaton\"/></div></td>\n";
$chaton[$c]['desc'] =utf8_encode($tab['desc_chats']);
$chaton[$c]['nom'] = $tab['nom_chats'];
$chaton[$c]['pere'] = $tab['pere_chats'];
$chaton[$c]['mere'] = $tab['mere_chats'];
$chaton[$c]['ligne'] = $tab['ligne_chats'];
$chaton[$c]['sexe'] = $tab['sexe_chats'];
if($tab['dispo_chats'] == 0):
$chaton[$c]['dispo_msg'] = "Non disponible";
$chaton[$c]['dispo_img'] = "../images/not_dispo.gif";
elseif($tab['dispo_chats'] == 1):
$chaton[$c]['dispo_msg'] = "Disponible";
$chaton[$c]['dispo_img'] = "../images/dispo.gif";
endif;
$c++;
endif;
endwhile;
$messageok = 0;
if($_POST['text']!=''):
if (eregi("\n",$_POST['mail']) OR eregi("\r",$_POST['mail']) OR eregi('Content-Type',$_POST['mail']) OR eregi('Content-Type',$_POST['text'])):
exit('SPAM Erreur Injection');
endif;
$headers = "Content-Type:text/plai; charset=utf-8\n"
."From:".$_POST['mail'];
@mail("[email protected]", "[Chats-Persans] Message d'un visiteur", $_POST['text'], $headers);
@mail($fiche['email_chatterie'], "[Chats-Persans] Message d'un visiteur", $_POST['text'], $headers);
$messageok = 1;
endif;
$_SITE['lang'] = 'fr';
include '_include/head.php';
include '_include/header.php';
?>
<table style="clear:both;width:80%;margin:10px auto;" border="0" align="center" cellspacing="0">
<tr>
<td colspan="2"><table width="100%" border="0">
<tr>
<td width="38%" align="center" valign="middle"><span class="Style2">
<?php /*echo $fiche['nom_chatterie'][0];*/ ?>
</span><span class="Style2"></span><span class="Style5"><?php echo utf8_encode($fiche['nom_chatterie']); ?></span></td>
<td width="12%" align="center" valign="middle"><div align="center"><a href="france.php"><img src="../images/drapeaux/france.jpg" width="61" height="64" border="0" /></a></div></td>
<td width="50%" align="center" valign="middle"><div align="center"><a href="index.php"><img src="../images/logo_small.gif" width="350" height="52" border="0" /></a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td width="40%" valign="top"> </td>
<td> </td>
</tr>
<tr align="center" valign="middle">
<td colspan="2"><div align="center">
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="10%" bgcolor="#54ADFF" class="soustitre"><?php echo $lang['fr']['Males']; ?></td>
<td class="type"> </td>
<td width="10%" bgcolor="#54ADFF" class="soustitre"><?php echo $lang['fr']['Femelles']; ?></td>
</tr>
<tr>
<?php
echo $male1 = isset($male[0]['img']) ? $male[0]['img'] : "<td width=\"10%\"><div align=\"center\"> </div></td>\n";
?>
<td rowspan="6" align="center" valign="middle"><div align="center">
<table width="100%" border="0">
<tr>
<td><div align="center"><img src="<?=$file_c;?>" width="<?=$details_c[0];?>" height="<?=$details_c[1];?>" /></div></td>
</tr>
<tr>
<td><div align="center"><span class="rub_black">
<?=$nom;?>
<br />
</span>
<?=$desc;?>
</div></td>
</tr>
</table>
</div></td>
<?php
echo $femelle1 = isset($femelle[0]['img']) ? $femelle[0]['img'] : "<td width=\"10%\"><div align=\"center\"> </div></td>\n";
?>
</tr>
<tr>
<?php
echo $male2 = isset($male[1]['img']) ? $male[1]['img'] : "<td width=\"10%\"><div align=\"center\"> </div></td>\n";
echo $femelle2 = isset($femelle[1]['img']) ? $femelle[1]['img'] : "<td width=\"10%\"><div align=\"center\"></div></td>\n";
?>
</tr>
<tr>
<?php
echo $male3 = isset($male[2]['img']) ? $male[2]['img'] : "<td width=\"10%\"><div align=\"center\"> </div></td>\n";
echo $femelle3 = isset($femelle[2]['img']) ? $femelle[2]['img'] : "<td width=\"10%\"><div align=\"center\"></div></td>\n";
?>
</tr>
<tr>
<?php
echo $male4 = isset($male[3]['img']) ? $male[3]['img'] : "<td width=\"10%\"><div align=\"center\"> </div></td>\n";
echo $femelle4 = isset($femelle[3]['img']) ? $femelle[3]['img'] : "<td width=\"10%\"><div align=\"center\"></div></td>\n";
?>
</tr>
<tr>
<?php
echo $male5 = isset($male[4]['img']) ? $male[4]['img'] : "<td width=\"10%\"><div align=\"center\"> </div></td>\n";
echo $femelle5 = isset($femelle[4]['img']) ? $femelle[4]['img'] : "<td width=\"10%\"><div align=\"center\"></div></td>\n";
?>
</tr>
<tr>
<?php
echo $male6 = isset($male[5]['img']) ? $male[5]['img'] : "<td width=\"10%\"><div align=\"center\"> </div></td>\n";
echo $femelle6 = isset($femelle[5]['img']) ? $femelle[5]['img'] : "<td width=\"10%\"><div align=\"center\"></div></td>\n";
?>
</tr>
</table>
</div></td>
</tr>
<tr>
<td valign="top"> </td>
<td> </td>
</tr>
<?php if(isset($chaton) AND count($chaton) != 0) : ?>
<tr bgcolor="#C1E1FF">
<td colspan="2"><?php echo $lang['fr']['Chatons']; ?></td>
</tr>
<tr>
<td colspan="2" valign="top"><table width="100%">
<tr>
<td><br /></td>
</tr>
<tr align="center"> <?php echo $chaton1 = isset($chaton[0]['img']) ? $chaton[0]['img'] : "<td width=\"100%\"><div align=\"center\"> </div></td>\n"; ?> </tr>
<tr align="center">
<td><?php echo $nom_chaton1 = isset($chaton[0]['nom']) ? "<span class=\"rub_black\">".utf8_encode($chaton[0]['nom'])."</span><br />".($chaton[0]['desc'])."\n" : null;?></td>
</tr>
<tr align="center">
<td><?php echo $statu_chaton1 = isset($chaton[0]['dispo_msg']) ? "<strong><img src=\"".$chaton[0]['dispo_img']."\" width=\"14\" height=\"14\" /> ".$chaton[0]['dispo_msg']."</strong>\n" : null; ?></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr align="center"> <?php echo $chaton2 = isset($chaton[1]['img']) ? $chaton[1]['img'] : "<td width=\"100%\"><div align=\"center\"> </div></td>\n"; ?> </tr>
<tr align="center">
<td><?php echo $nom_chaton2 = isset($chaton[1]['nom']) ? "<span class=\"rub_black\">".utf8_encode($chaton[1]['nom'])."</span><br />".($chaton[1]['desc'])."\n" : null; ?></td>
</tr>
<tr align="center">
<td><?php echo $statu_chaton2 = isset($chaton[1]['dispo_msg']) ? "<strong><img src=\"".$chaton[1]['dispo_img']."\" width=\"14\" height=\"14\" /> ".$chaton[1]['dispo_msg']."</strong></tr>\n" : null; ?></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr align="center"> <?php echo $chaton2 = isset($chaton[2]['img']) ? $chaton[2]['img'] : "<td width=\"100%\"><div align=\"center\"> </div></td>\n"; ?> </tr>
<tr align="center">
<td><?php echo $nom_chaton2 = isset($chaton[2]['nom']) ? "<span class=\"rub_black\">".utf8_encode($chaton[2]['nom'])."</span><br />".($chaton[2]['desc'])."\n" : null; ?></td>
</tr>
<tr align="center">
<td><?php echo $statu_chaton2 = isset($chaton[2]['dispo_msg']) ? "<strong><img src=\"".$chaton[2]['dispo_img']."\" width=\"14\" height=\"14\" /> ".$chaton[2]['dispo_msg']."</strong></tr>\n" : null; ?></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr align="center"> <?php echo $chaton2 = isset($chaton[3]['img']) ? $chaton[3]['img'] : "<td width=\"100%\"><div align=\"center\"> </div></td>\n"; ?> </tr>
<tr align="center">
<td><?php echo $nom_chaton2 = isset($chaton[3]['nom']) ? "<span class=\"rub_black\">".utf8_encode($chaton[3]['nom'])."</span><br />".($chaton[3]['desc'])."\n" : null; ?></td>
</tr>
<tr align="center">
<td><?php echo $statu_chaton2 = isset($chaton[3]['dispo_msg']) ? "<strong><img src=\"".$chaton[3]['dispo_img']."\" width=\"14\" height=\"14\" /> ".$chaton[3]['dispo_msg']."</strong></tr>\n" : null; ?></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr align="center"> <?php echo $chaton2 = isset($chaton[4]['img']) ? $chaton[4]['img'] : "<td width=\"100%\"><div align=\"center\"> </div></td>\n"; ?> </tr>
<tr align="center">
<td><?php echo $nom_chaton2 = isset($chaton[4]['nom']) ? "<span class=\"rub_black\">".utf8_encode($chaton[4]['nom'])."</span><br />".($chaton[4]['desc'])."\n" : null; ?></td>
</tr>
<tr align="center">
<td><?php echo $statu_chaton2 = isset($chaton[4]['dispo_msg']) ? "<strong><img src=\"".$chaton[4]['dispo_img']."\" width=\"14\" height=\"14\" /> ".$chaton[4]['dispo_msg']."</strong></tr>\n" : null; ?></td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr align="center"> <?php echo $chaton2 = isset($chaton[5]['img']) ? $chaton[5]['img'] : "<td width=\"100%\"><div align=\"center\"> </div></td>\n"; ?> </tr>
<tr align="center">
<td><?php echo $nom_chaton2 = isset($chaton[5]['nom']) ? "<span class=\"rub_black\">".utf8_encode($chaton[5]['nom'])."</span><br />".($chaton[5]['desc'])."\n" : null; ?></td>
</tr>
<tr align="center">
<td><?php echo $statu_chaton2 = isset($chaton[5]['dispo_msg']) ? "<strong><img src=\"".$chaton[5]['dispo_img']."\" width=\"14\" height=\"14\" /> ".$chaton[5]['dispo_msg']."</strong></tr>\n" : null; ?></td>
</tr>
</table></td>
</tr>
<?php endif; ?>
<tr>
<td valign="top" bgcolor="#54ADFF" class="soustitre">Description</td>
<td> </td>
</tr>
<tr>
<td colspan="2" valign="top"><p align="justify"> </p>
<p align="justify"><?php echo (utf8_encode($fiche['desc'.$_GLOBAL['lg'].'_chatterie'])); ?></p>
<p align="justify"><br />
<span class="bold_underline"><?php echo $lang['fr']['Petit_com']; ?></span></p>
<?php
if(isset($male)):
?>
<p><span class="rub_blue"><?php echo utf8_encode($lang['fr']['nosmales']); ?></span></p>
<?php
for($i=0;$i<4;$i++):
// MALE
if(isset($male[$i]['nom']) && $male[$i]['nom'] != ''):
?>
<p><span class="rub_black"><?php echo utf8_decode($male[$i]['nom']); ?><br />
</span><?php echo utf8_encode($male[$i]['desc']); ?><br />
<?php
if(isset($male[$i]['pere']) && $male[$i]['pere'] != ''):
?>
Père : <?php echo utf8_encode($male[$i]['pere']); ?><br />
<?php
endif;
if(isset($male[$i]['mere']) && $male[$i]['mere'] != ''):
?>
Mère : <?php echo utf8_encode($male[$i]['mere']); ?><br />
<?php
endif;
if(isset($male[$i]['ligne']) && $male[$i]['ligne'] != ''):
?>
Lignée : <?php echo utf8_encode($male[$i]['ligne']); ?>
<?php
endif;
?>
</p>
<?php
endif;
endfor;
endif;
?>
<?php
if(isset($femelle)):
?>
<p><span class="rub_blue"><?php echo $lang['fr']['nosfemmel']; ?></span></p>
<?php
for($i=0;$i<4;$i++):
// FEMELLE
if(isset($femelle[$i]['nom']) && $femelle[$i]['nom'] != ''):
?>
<p><span class="rub_black"><?php echo utf8_decode($femelle[$i]['nom']); ?><br />
</span><?php echo utf8_encode($femelle[$i]['desc']); ?><br />
<?php
if(isset($femelle[$i]['pere']) && $femelle[$i]['pere'] != ''):
?>
Père : <?php echo utf8_encode($femelle[$i]['pere']); ?><br />
<?php
endif;
if(isset($femelle[$i]['mere']) && $femelle[$i]['mere'] != ''):
?>
Mère : <?php echo utf8_encode($femelle[$i]['mere']); ?><br />
<?php
endif;
if(isset($femelle[$i]['ligne']) && $femelle[$i]['ligne'] != ''):
?>
Lignée : <?php echo utf8_encode($femelle[$i]['ligne']); ?>
<?php
endif;
?>
</p>
<?php
endif;
endfor;
endif;
?>
<?php
if(isset($chaton)):
?>
<p><span class="rub_blue"><?php echo $lang['fr']['noschatons']; ?></span></p>
<?php
for($i=0;$i<6;$i++):
// FEMELLE
if(isset($chaton[$i]['nom']) && $chaton[$i]['nom'] != ''):
?>
<p><span class="rub_black"><?php echo utf8_encode($chaton[$i]['nom']); ?><br />
</span><?php echo ($chaton[$i]['desc']); ?><br />
<?php
if(isset($chaton[$i]['pere']) && $chaton[$i]['pere'] != ''):
?>
Père : <?php echo utf8_encode($chaton[$i]['pere']); ?><br />
<?php
endif;
if(isset($chaton[$i]['mere']) && $chaton[$i]['mere'] != ''):
?>
Mère : <?php echo utf8_encode($chaton[$i]['mere']); ?><br />
<?php
endif;
if(isset($chaton[$i]['ligne']) && $chaton[$i]['ligne'] != ''):
?>
Lignée : <?php echo utf8_encode($chaton[$i]['ligne']); ?>
<?php
endif;
?>
</p>
<?php
endif;
endfor;
endif;
?></td>
</tr>
<tr>
<td valign="top"> </td>
<td> </td>
</tr>
<tr>
<td valign="top" bgcolor="#54ADFF" class="soustitre"><?php echo $lang['fr']['Contact']; ?></td>
<td> </td>
</tr>
<tr>
<td valign="top"><p><span class="rub_black"><?php echo utf8_encode($fiche['nomc_chatterie']); ?></span><br />
<?php echo utf8_encode($fiche['adr_chatterie']); ?><br />
<?php if($fiche['adrc_chatterie'] != ''): ?>
<?php echo utf8_encode($fiche['adrc_chatterie']); ?><br />
<?php endif; ?>
<?php echo $fiche['code_chatterie']; ?> <?php echo utf8_encode($fiche['ville_chatterie']); ?><br />
<br />
<span class="rub_black"><?php echo $fiche['pays_chatterie']; ?></span> <br />
</p></td>
<td valign="top"><p>
<?php if($fiche['tel_chatterie'] != ''): ?>
<strong>Tél :</strong> <?php echo utf8_encode($fiche['tel_chatterie']); ?><br />
<?php endif; ?>
<?php if($fiche['fax_chatterie'] != ''): ?>
<strong>Fax :</strong> <?php echo utf8_encode($fiche['fax_chatterie']); ?><br />
<?php endif; ?>
<?php if($fiche['mob_chatterie'] != ''): ?>
<strong>Mobile :</strong> <?php echo utf8_encode($fiche['mob_chatterie']); ?><br />
<?php endif; ?>
<?php if($fiche['cert_chatterie'] != ''): ?>
<span class="rub_black">N° de Certificat de Capacité :</span> <?php echo utf8_encode($fiche['cert_chatterie']); ?><br />
<?php endif; ?>
<?php if($fiche['siret_chatterie'] != ''): ?>
<strong>N° de Siret : </strong><?php echo utf8_encode($fiche['siret_chatterie']); ?><br />
<?php endif; ?>
<?php if($fiche['url_chatterie'] != ''): ?>
<span class="rub_black">Website :</span> <a href="<?php echo $fiche['url_chatterie']; ?>" target="_blank"><?php echo $fiche['url_chatterie']; ?></a></p>
<?php endif; ?></td>
</tr>
<tr>
<td valign="top" bgcolor="#54ADFF" class="soustitre">Nous ecrire</td>
<td> </td>
</tr>
<tr>
<td colspan="2"><?php if($messageok): ?>
<p id="envoiok"><strong style="color:green">Votre message a bien été envoyé ! Merci</strong></p>
<?php else: ?>
<form method="post" action="fiche.php?id=<?php echo $_GET['id']; ?>#envoiok">
<p>
<label>Votre adresse email : </label>
<input type="text" name="mail" value="" />
</p>
<p>
<label>Votre message : </label>
<textarea name="text"></textarea>
</p>
<p>
<input type="submit" value="Envoyer" name="valid" />
</p>
</form>
<?php endif; ?></td>
</tr>
</table>
<?php
include '_include/foot.php';
?>