website logo
Auteur
avatar
Tribal-Dolphin

Forum » » Le coin des codeurs » » Fonction de création d'image


Posté : 22 oct. 2004 à 07:25 icone du post

Voici le code que j'utilise, et qui marche.
fait le tri



<?
function CreateThumb($Image $Source $Destination $Largeur$Hauteur$ext){

  if (
$ext == "gif"{
    $src = imagecreatefromgif($Source.$Image);
  
} else {
    $src = imagecreatefromjpeg($Source.$Image);
  
}

  $size = getimagesize($Source.$Image);
  $h_i = $size
[1];
  $w_i = $size
[0];

  if($w_i >$Largeur)
  
{ 
     $convert = $Largeur/$w_i;
     $w_i = $Largeur;
     $h_i = ceil($h_i*$convert);
     if($h_i > $Hauteur)
       
{ 
         $convert = $Hauteur/$h_i;
         $h_i = $Hauteur;
         $w_i = ceil($w_i*$convert);
      
}
  
}

  if(function_exists(
"imagecreatetruecolor")) {
    $im = imagecreatetruecolor($w_i, $h_i);
  
} else {
    $im = imagecreate($w_i, $h_i);
  
}
  
  //$textcolor = imagecolorallocate($im, 255, 255, 255);
  //imagestring($im, 1, 5, 5, 
"Bonjour le monde !", $textcolor);

  imagecopyresized($im, $src, 0, 0, 0, 0, $w_i, $h_i, $size
[0], $size[1]);
  imagejpeg($im, $Destination.$Image, 50);
}
?>



Cet article provient de NPDS
https://www.npds.org/viewtopic.php?topic=13957&forum=5