$ratio_orig) && (($width_orig>$width) || ($height_orig>$height))) $width = $height*$ratio_orig; else $height = $width/$ratio_orig; if (isset($cutheight)) { if ($height<$cutheight) {$dest_y = ($cutheight-$height) / 2;} else {$dest_y = ($cutheight - $height) / 3;} $dest_height = $cutheight; } else {$dest_y = 0; $dest_height=$height;} if (isset($cutwidth)) { $dest_x = ($cutwidth-$width) / 2; $dest_width = $cutwidth; } else {$dest_x = 0; $dest_width=$width;} if ($dest_width>400 || $dest_height>400) { //add to stats include_once "header_a.php"; if (!$admin) { $typeid = intval(preg_replace("/[a-zA-Z]/", "", $id)); $type = fixquotes(preg_replace("/[0-9]/", "", $id)); mysql_query("UPDATE photos SET views=views+1 WHERE id=$typeid AND type='$type'"); } } // Resample $image_p = imagecreatetruecolor($dest_width, $dest_height); //imagefill($image_p, 0, 0, imagecolorallocate($image_p, 255, 255, 255)); $trans_color = imagecolorallocatealpha($image_p,254,253,255,0); imagecolortransparent($image_p,$trans_color); imagefill($image_p, 0,0,$trans_color); $image = @imagecreatefromjpeg($filename); if (!$image) $image = @imagecreatefromgif($filename); if (!$image) $image = @imagecreatefrompng($filename); if (!$image) $image = imagecreatefromjpeg("./images/10.jpg"); imagecopyresampled($image_p, $image, $dest_x, $dest_y, 0, 0, $width, $height, $width_orig, $height_orig); imagedestroy($image); if (isset($video)) { $image = imagecreatefromjpeg("http://img.youtube.com/vi/$video/default.jpg"); imagecopyresampled ($image, $image, 0, 0, 0, 0, 130/140*$width+1, 97/139*$height+1, 130, 100); imagecopymerge($image_p, $image, 7/139*$width, 21/140*$height, 0, 0, 130/140*$width+1, 97/139*$height+1, 100); imagedestroy($image); } if (($width>=300) && ($height>=400)) { $image = imagecreatefromgif("./images/imagelogo.gif"); imagecopymerge($image_p, $image, 3, $height-50, 0, 0, 200, 49, 66); imagedestroy($image); } // Output if (!isset($q)) $q = ($height<61) ? 90 : 80; if ($height<=150) Header ("Cache-Control: max-age=600, s-maxage=600, proxy-revalidate, must-revalidate"); imagejpeg($image_p,null,$q); imagedestroy($image_p); ?>