<?php
require_once "../config/config.php";
require_once "product_class.php";
$loProductClass = new product_class();
$id=$_REQUEST ['id'];;
$query = 'SELECT logo FROM '.TABLE_PREFIX.'products WHERE id=?';
$lsValues = array($id);
$imageData = $loProductClass->View($query,$lsValues,null);
$bindata=$imageData[0]['logo'];
$type='jpg';
$ex=".";
$file="temp.".$type;
$Handle = fopen($file, 'w');
fwrite($Handle, $bindata);
fclose($Handle);
$thumb_size = 75;
$size = getimagesize($file);
$width = $size[0];
$height = $size[1];
if($width> $height) {
$x = ceil(($width - $height) / 2 );
$width = $height;
} elseif($height> $width) {
$y = ceil(($height - $width) / 2);
$height = $width;
}
$new_im= @imagecreatetruecolor($thumb_size,$thumb_size);
if($type=="jpg" or $type=="JPEG")
{
$im=@imagecreatefromjpeg($file);
}
imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height);
if($type=="jpg" or $type=="JPEG")
{
//header("Content-type: image/jpg");
while (@ob_end_clean());
header("Content-type:image/jpeg");
imagejpeg($new_im);
}
//imagejpeg($new_im,"temp/".$row['Name'],100);
unlink($file);
?>