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
| <?
header("Content-type: image/png");
function load($imgname) {
$im=@imagecreatefromjpeg(substr($imgname, 2));
if(!$im){
$im=imagecreatetruecolor(150, 30);
$bgc=imagecolorallocate($im, 255, 255, 255);
$tc=imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
imagestring($im, 1, 5, 5, "Erreur de chargement de l'image $imgname", $tc);
}
else {
$cp=$im;
$width=150;
$height=200;
// Cacul des nouvelles dimensions
// Redimensionnement
}
return $im;
}
if(!isset($_GET['url'])) die('URL de l\'image non spécifiée.');
$file=$_GET['url'];
if(file_exists($file)) die('URL de l\'image non spécifiée.');
$picture=load($file);
$info=pathinfo($file);
$thumb_prefix="t_";
imagepng($picture, $info['dirname']."/".$thumb_prefix.$info['basename']);
imagedestroy($picture);
?> |
Partager