All pastes #508391 Raw Edit

Kilandor

public php v1 · immutable
·published 2007-05-25 00:06 UTC
rendered paste body
function sed_createthumb($img_big, $img_small, $small_x, $small_y, $keepratio, $extension, $filen, $fsize, $textcolor, $textsize, $bgcolor, $bordersize, $jpegquality, $dim_priority="Width")	{	if (!function_exists('gd_info'))		{ return; }	global $cfg;	$gd_supported = array('jpg', 'jpeg', 'png', 'gif');	switch($extension)		{		case 'gif':		$source = imagecreatefromgif($img_big);		break;		case 'png':		$source = imagecreatefrompng($img_big);		break;		default:		$source = imagecreatefromjpeg($img_big);		break;		}	$big_x = imagesx($source);	$big_y = imagesy($source);		if ($big_y > $big_x) { // If the width is greater than the height it's a horizontal picture        $xoord = ceil(($big_x - $big_y) / 2 );        $big_y = $big_x;      // Then we read a square frame that equals the width      } else {        $yoord = ceil(($big_y - $big_x) / 2);        $big_x = $big_y;      }		$thumb_x = $small_x;		$thumb_y = $small_y;	if ($textsize==0)		{		if ($cfg['th_amode']=='GD1')			{ $new = imagecreate($thumb_x+$bordersize*2, $thumb_y+$bordersize*2); }		else			{ $new = imagecreatetruecolor($thumb_x+$bordersize*2, $thumb_y+$bordersize*2); }		if ($cfg['th_amode']=='GD1')			{ imagecopyresized($new, $source, $bordersize, $bordersize, $xoord, $yoord, $thumb_x, $thumb_y, $big_x, $big_y); }		else			{ imagecopyresampled($new, $source, $bordersize, $bordersize, $xoord, $yoord, $thumb_x, $thumb_y, $big_x, $big_y); }		}   else		{		if ($cfg['th_amode']=='GD1')			{ $new = imagecreate($thumb_x+$bordersize*2, $thumb_y+$bordersize*2+$textsize*3.5+6); }		else			{ $new = imagecreatetruecolor($thumb_x+$bordersize*2, $thumb_y+$bordersize*2+$textsize*3.5+6); }		if ($cfg['th_amode']=='GD1')			{ imagecopyresized($new, $source, $bordersize, $bordersize, $xoord, $yoord, $thumb_x, $thumb_y, $big_x, $big_y); }		else			{ imagecopyresampled($new, $source, $bordersize, $bordersize, $xoord, $yoord, $thumb_x, $thumb_y, $big_x, $big_y); }		imagestring ($new, $textsize, $bordersize, $thumb_y+$bordersize+$textsize+1, $big_x."x".$big_y." ".$fsize."kb", $text_color);		}	switch($extension)		{		case 'gif':		imagegif($new, $img_small);		break;		case 'png':		imagepng($new, $img_small);		break;		default:		imagejpeg($new, $img_small, $jpegquality);		break;		}	imagedestroy($new);	imagedestroy($source);	return;	}