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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
$FontRep="../Commun/";
$file=urldecode($_GET["Fichier"]);
list($WMax,$HMax)=explode("x",$_GET["Dim"]);
list($width, $height) = getimagesize($file);
$percent=max($width/$WMax,$height/$HMax);
// Content type
header('Content-type: image/jpeg');
// Calcul des nouvelles dimensions
if ($percent>1) {
$newwidth = (int)$width / $percent;
$newheight = (int)$height / $percent;
// chargement
$thumb = imagecreatetruecolor($newwidth, $newheight);
imageinterlace($thumb, true);
$source = imagecreatefromjpeg($file);
// Redimensionnement
imagecopyresampled ($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
else {
$thumb = imagecreatefromjpeg($file);
imageinterlace($thumb, true);
};
if (!$thumb) {
$thumb = imagecreatruecolor($WMax,$HMax);
$bgc = imagecolorallocate($thumb, 255, 255, 255);
$tc = imagecolorallocate($thumb, 0, 0, 0);
imagefilledrectangle($thumb, 0, 0, 150, 30, $bgc);
// afficher un message d'erreur
imagestring($thumb, 1, 5, 5, "erreur dans $file", $tc);
};
if (isset($_GET["Surcharge"])) {
$Texte=$_GET["Surcharge"];
$noir = imagecolorallocate($thumb,0,0,0);
$blanc = imagecolorallocate($thumb,255,255,255);
$font = $FontRep.'arial.ttf';
imagettftext($thumb,10,0,5,13,$noir,$font,$Texte);
imagettftext($thumb,10,0,4,12,$blanc,$font,$Texte);
};
// Affichage
imagejpeg($thumb);
imagedestroy($thumb);
?> |
Partager