Gemme thumbnail
Hejsa. Jeg har et script som genererer thumbnails.Jeg har brug for at scriptet gemmer det genererede thumbnail som thumb_$fil hvor $fil er det originale filnavn....
Koden er :
$navn = "$_GET[file]";
if(stristr($navn,".jpg")){
if($ratio == "on") {
$size = getimagesize("$navn");
if ($size[0] > $maxwidth) {
$ratio = $size[1]/$size[0];
$t_width = $maxwidth;
$t_height = $maxwidth*$ratio;
} else {
$t_width = $size[0];
$t_height = $size[1];
}
}else{
$t_width = $maxwidth;
$t_height = $maxwidth;
}
header("Content-type: image/jpeg");
$srcimage = imagecreatefromjpeg($navn);
$destimage = imagecreatetruecolor($t_width,$t_height);
$width = imageSX($srcimage);
$height = imageSY($srcimage);
imagecopyresized ($destimage,$srcimage,0,0,0,0,$t_width,$t_height,$width,$height);
ImageJPEG($destimage);
ImageDestroy($destimage);
}
else {
$im = imagecreatetruecolor($maxwidth,$maxwidth);
$blue = imagecolorallocate($im,255,255,255);
$red = imagecolorallocate($im,200,200,255);
imagestring($im,7,7,20,"ImageViewer $ver error",$red);
imageJPEG($im);
imagedestroy($im);
}
}
