All pastes #492215 Raw Edit

Mine

public php v1 · immutable
·published 2007-05-17 02:13 UTC
rendered paste body
// constant variables define:$margin = 2;$jpegQuality = 100;$transparency = 100;$txt = "Click To Enlarge";// max width/height$width = 180$height = 180// shrink image proportionallylist($width_orig, $height_orig) = getimagesize($filename52);$ratio_orig = $width_orig/$height_orig;if ($width/$height > $ratio_orig) {	$width = $height*$ratio_orig;} else {	$height = $width/$ratio_orig;}// if the width is lower than the text width, set it as the base pixel width// it will be black in that areaif($width<80) { 	$width=80; }// set the thumbnail final location name:$newname3 = $FinalThumbName . "_thm" . "." . $Extention1;$newname32 = "uploads/thm/" . $newname3;// create the base image, 12 more than the height of the thumbnail, to give room for the text:$im = @imagecreatetruecolor($width, $height+12) or die("Cannot Initialize new GD image stream");// define colors:// NOTE: 0,0,0 == black && 225, 225, 225 == white { u can get exact colors in photoshop palete$background_color = imagecolorallocate($im, 0, 0, 0);$text_color = imagecolorallocate($im, 225, 225, 225);// set the text in the center:$wmX2 = $width/2- strlen($txt)*2-10;$wmY2 = $height+12 - 9 - $margin;// put the text into the base imageimagestring($im, 1, $wmX2, $wmY2, $txt, $text_color);if (strtolower($Extention1) == "jpg") {	$jpegImg = imagecreatefromjpeg($filename52);	imagecopyresampled($im, $jpegImg, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);	imagejpeg($im, $newname32, $jpegQuality);	}if (strtolower($Extention1) == "png" ) {	$jpegImg = imagecreatefrompng($filename52);	imagealphablending($im, false);	imagecopyresampled($im, $jpegImg, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);	imagesavealpha($im, true);	imagepng($im, $newname32, 6);}if (strtolower($Extention1) == "gif" ) {	$jpegImg = imagecreatefromgif($filename52);	imagealphablending($im, false);	imagecopyresampled($im, $jpegImg, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);	imagegif($im, $newname32, $jpegQuality);}