rendered paste body//To resize a imageif(isset($tnsize)){ $tnsize = (integer) $tnsize; if (($tnsize < 20) || ($tnsize > 300)) { // If not, it creates an error image and displays it $img = imagecreate(150, 150); $red = imagecolorallocate($img, 255, 0, 0); $yellow = imagecolorallocate($img, 255,255, 0); imagestring($img, 4, 20, 20, "Afmetingen", $yellow); imagestring($img, 4, 20, 40, "kloppen", $yellow); imagestring($img, 4, 20, 60, "niet!", $yellow); imagepng($img); imagedestroy($img); exit(); } if ($ext == ".jpg" || $ext == "jpeg") { $bigimage = @imagecreatefromjpeg($img); } if ($ext == ".gif") { $bigimage = @imagecreatefromgif($img); } if ($ext == ".png" || $ext == "jpeg") { $bigimage = @imagecreatefrompng($img); } //Create an empty image of the given size $tnimage = imagecreate($tnsize, $tnsize); $darkblue = imagecolorallocate($tnimage, 0,0, 127); imagecolortransparent($tnimage,$darkblue); //Calculate the resizing image factor $sz = getimagesize($img); $x = $sz[0]; $y = $sz[1]; if ($x > $y) { $dx = 0; $w = $tnsize; $h = ($y / $x) * $tnsize; $dy = ($tnsize - $h) / 2; } else { $dy = 0; $h = $tnsize; $w = ($x / $y) * $tnsize; $dx = ($tnsize - $w) / 2; } // Resizes the image imagecopyresized($tnimage, $bigimage, $dx, $dy, 0, 0, $w, $h,$x, $y); // Displays the image imagepng($tnimage); // Clears the variables imagedestroy($tnimage); imagedestroy($bigimage);}else{ if($config["type"]=="redirect"){ header("Location: ".$url.$img); } else if($config["type"]=="readfile"){ readfile($pathtoread."/".$img); } else { echo "Error: unknown displaytype"; }}