All pastes #552020 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-09 01:54 UTC
rendered paste body
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<b>Original</b>
<img src="/autoSite/img/HN7024.jpg">
<b>Resized</b>
<?php dispImg("img/HN7024.jpg")?>
</body>
</html>
<?php
function dispImg($file)
{
	$wmax = 320;
	$hmax = 9999;
	$bgcol = false;
	   $source = imagecreatefromjpeg($file);
	   $orig_w=imagesx($source);
	   $orig_h=imagesy($source);
	
	   if ($orig_w>$wmax || $orig_h>$hmax)
	   {
		   $thumb_w=$wmax;
		   $thumb_h=$hmax;
		   if ($thumb_w/$orig_w*$orig_h>$thumb_h)
			   $thumb_w=round($thumb_h*$orig_w/$orig_h);
		   else
			   $thumb_h=round($thumb_w*$orig_h/$orig_w);
	   } else
	   {
		   $thumb_w=$orig_w;
		   $thumb_h=$orig_h;
	   }
	   if (!@$bgcol)
	   {
		   $thumb=imagecreatetruecolor($thumb_w,$thumb_h);
		   imagecopyresampled($thumb,$source,
							   0,0,0,0,$thumb_w,$thumb_h,$orig_w,$orig_h);
	   }
	   else
	   {
		   $thumb=imagecreatetruecolor($wmax,$hmax);
		   imagefilledrectangle($thumb,0,0,$wmax-1,$hmax-1,intval($bgcol,16));
		   imagecopyresampled($thumb,$source,
							   round(($wmax-$thumb_w)/2),round(($hmax-$thumb_h)/2),
							   0,0,$thumb_w,$thumb_h,$orig_w,$orig_h);
	   }
	   if (!@$quality) $quality=90;
	   $newfilename = "car.jpg";
	   imagejpeg($thumb,$newfilename,$quality);
	imagedestroy($thumb);
}
?>