<?php
require_once('db_fns.php');
if($SKU){
db_connect();
$query = "SELECT pic,filetype FROM products WHERE SKU=$SKU";
$result = @($query);
$data = @MYSQL_RESULT($result,0,"pic");
$type = @MYSQL_RESULT($result,0,"filetype");
$image = $data;//////////////////////////////////IS This What I Am To pass it?
if (!$max_width)
$max_width = 50:
if(!$max_height)
$max_height = 50;
$size= GetImageSize($image);
echo $size;
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) )
{
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio $height) < $max_height))
{
$tn_height = ceil($y_ratio $height);
$tn_width = $max_width;
}
else
{
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
if ($type == "text/jpeg")
{
$src = ImageCreateFromJPEG($image);
}
else if($type == "text/pjpeg")
{
$src = ImageCreateFromJPEG($image);
}
else if($type == "text/gif")
{
$src = ImageCreateFromGif($image);
}
else ($type == "text/PNG")
{
$src = ImageCreateFromPNG($image);
}
$dst = ImageCreate($th_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0, 0, 0, $tn_width,$tn_height,$width,$height);
Header( "Content-type: $type");
ImageJpeg($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
};
?>