function redim($fileName,$source,$target,$widht,$height,$del){
$lalarg = $widht; //Largeur maximale
$lahaut = $height; //Hauteur maximale
$origin = imagecreatefromjpeg($source.$fileName);
$taille = filesize($source.$fileName);
//echo "<b>Taille: </b><i>$taille octets</i><br>";
$larg = imagesx($origin);
$haut = imagesy($origin);
if ($larg>$lalarg || $haut>$lahaut) {
$pc_l = $larg / $lalarg;
$pc_h = $haut / $lahaut;
}
else $pc_l = $pc_h = 1;
$pc_m = $pc_l; if ($pc_h > $pc_l) $pc_m = $pc_h;
//echo "<b>Dimension %: </b><i>$pc_m</i><br>";
$haut2 = $haut / $pc_m;
$larg2 = $larg / $pc_m;
//$iqual = ($taille / $pc_m) /1000;
//$qual = 5000; //Sert pour le jpg
//if ($iqual > 50) $qual = 100 * (50 / $iqual);
//echo "<b>Indice de qualité: </b><i>$iqual</i><br><b>Adaptation qualité %:</b><i>$qual</i><br> ".$chemin."thumb$image généré<br><br>";
$thumb = imagecreatetruecolor($larg2,$haut2);
imagecopyresized($thumb, $origin, 0, 0, 0, 0,$larg2, $haut2, $larg, $haut);
imagepng($thumb,$target.$fileName); //Pour créer un PNG
//imagejpeg($thumb,$target.$fileName,$qual); // Pour créer un JPG
if ($del==1)unlink($source.$fileName);
//imagedestroy($origin);
//imagedestroy($thumb);
}