script implementering
Davs.Jeg har det her script, som bruger GdLib til at resize et billede:
function resizeImage($src_file, $dest_file, $newWidth)
{
// find the image size
$imginfo = @getimagesize($src_file);
if ($imginfo == NULL)
return false;
// height/width
$srcWidth = $imginfo[0];
$srcHeight = $imginfo[1];
$ratioWidth = $srcWidth/$newWidth;
$ratioHeight = 0;
$destWidth = $newWidth;
$destHeight = $srcHeight / $ratioWidth;
$src_img = imagecreatefromjpeg($src_file);
$dst_img = imagecreatetruecolor($destWidth,$destHeight);
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth,(int)$destHeight, $srcWidth, $srcHeight);
imagejpeg($dst_img, $dest_file, 100);
imagedestroy($src_img);
imagedestroy($dst_img);
return $dest_file;
}
Er der nogen der kan sige mig hvordan jeg skal gøre, hvis jeg vil kunne bruge scriptet ved at skrive f.eks.: <img src="thumb.php?src=noget.jpg&width=100">?
