Pages vues depuis 25/05/2001 : 109 412 536
Index du forum »» Le coin des codeurs »» Fonction de création d'image
<?php
$adresseimage = $the_path.$nom_img;
list($width, $height, $type, $attr) = getimagesize($adresseimage);
$new_height = 85;
$coef_reduc=$new_height/$height;
$coef_reduc=ceil($coef_reduc);//arrondit coef
$new_width=$width*$coef_reduc;
$miniature = imagecreatetruecolor ($new_width, $new_height);
imagecopyresized ($miniature, $adresseimage, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg ($miniature, "modules/fanart/images/".$nom_img."-mini", 90);
imagedestroy ($miniature);
flush();
?>
<?
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);
}
?>