I am trying to create thumbnails that will be created by server and then outputted to HTML for user of website but it returns wierd code... My function is:
function createthumbnail($n){
list($width, $height) = getimagesize($n);
$newheight = 100;
$ratio = 100/$height;
$newwidth = $width*$ratio;
$im = imagecreatetruecolor($newwidth, $newheight);
switch(exif_imagetype($n)){
case "jpg":
$foto_r = imagecreatefromjpg($n);
break;
case "png":
$foto_r = imagecreatefrompng($n);
break;
case "bmp":
$foto_r = imagecreatefromwbmp($n);
break;
default:
$foto_r = imagecreatefromjpeg($n);
}
if(!$foto_r){
$im = imagecreatetruecolor($newwidth, $newheight);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
imagestring($im, 1, 5, 5, 'Error loading ' . $n, $tc);
}else{
imagecopyresampled($im, $foto_r, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($im, null, 100);
}
return $foto_r;
}