Billedresize, thunbnail?
Hej,Jeg skal have lavet en thumbnail, men ved ikke hvorfor mit script ikke virker?
Filen der skal resizes ligger i "galleri/pics/galleri_dias_size.jpg", og den må højest være 50x50.. hvad skal jeg angive værdierne til for at den laver en thumbnail?
Her er scriptet:
function imageresizejpeg($sourcefile,$maxwidth,$maxheight,$destinationfile=false)
{
if($img_src=@imagecreatefromjpeg($sourcefile)) {
copy($sourcefile, $destinationfile);
$info=@getimagesize($sourcefile);
if($info[1]>$maxheight || $info[0]>$maxwidth) {
$ratio_height=$maxheight/$info[1];
$ratio_width=$maxwidth/$info[0];
$ratio=min($ratio_width,$ratio_height);
$newwidth=intval($info[0]*$ratio);
$newheight=intval($info[1]*$ratio);
$img_dst=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $newwidth, $newheight, $info[0], $info[1]);
@imagejpeg($img_dst, $destinationfile);
imagedestroy($img_dst);
echo "Billede gemmes som $destinationfile i størrelse $newwidth x $newheight.<BR>";
}
@imagedestroy($img_src);
return true;
} else {
return false;
}
}
Hvis folk har alternativer, så må de også gerne skrive..
