|
Posted by nescio on 04/03/06 13:43
hello,
i have a function to make a thumbnail.
the functions makes a copy of the thumbnail, so far so good.
the problem is: all the thumbnails have a thin black line at the smallest
site of the image
(when height is 200 and width is 50 it is at the bottom;
when height is 50 and width is 200 it is at the right site)
when the image is larger, let's say 400/350 then it doesn't happen.
how is this possible and how do i get rid of it?
----------------------------- source code ---------------------------
$image: name of the image that must become a thumbnail;
$max_width: max width of the thumbnail;
$max_height: max height of the thumbnail;
$file_name_dest: name of the thumbnail;
function maakPlaatje($image, $max_width, $max_height, $file_name_dest){
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}else{
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
$src = ImageCreateFromJpeg($image);
$dst = imagecreatetruecolor($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0,
$tn_width,$tn_height,$width,$height);
$quality = 100;
$fh=fopen($file_name_dest,'w');
fclose($fh);
imagejpeg($dst,$file_name_dest, $quality);
ImageDestroy($src);
ImageDestroy($dst);
return true;
}
------------------------------------------------------------------------
thanks
Navigation:
[Reply to this message]
|