1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
function miniaturise($rep, $nomFichier)
{
$fichierSource = $rep.$nomFichier;
$source = ImageCreateFromJpeg($fichierSource);
$largeurSource = imagesx($source);
$hauteurSource = imagesy($source);
$hauteurDestination = 150;
$coeff = $hauteurSource / $hauteurDestination;
$largeurDestination = round($largeurSource / $coeff, 0);
$im = ImageCreateTrueColor($largeurDestination, $hauteurDestination) or die("Erreur lors de la création de l'image");
ImageCopyResampled($im, $source, 0, 0, 0, 0, $largeurDestination, $hauteurDestination, $largeurSource, $hauteurSource);
// ajout de _small au nom de la photo et affichage
$nom_img = strrpos($fichierSource, "/");
$nom_img2 = substr_replace($fichierSource, '', 0, $nom_img+1);
$array_name = explode(".",$nom_img2);
$miniature = $array_name[0].TYPE_IMG.".".$array_name[count($array_name)-1];
ImageJpeg($im, $rep.$miniature);
} |
Partager