<?php
include "config.php";
header("Content-type: image/jpeg");
$id=$_GET["id"];
if(!$id){$resize = imagecreatefromgif("author.gif");}
else {
$q="select * from fisiere where id='$id'";
$qu=mysql_query($q);
$row=mysql_fetch_array($qu);
$file=$row['file'];
$ftype=$row['ftype'];

$image=uploads."/".$ftype."/".$file;
$resheight = 70;
$rever=strrev($image);
$prv=explode(".", $rever);
$extension=strrev($prv[0]);
$smallext=strtolower($extension);
$size = GetImageSize($image);
$imawidth = $size[0];
$imaheight = $size[1];

if($smallext=="gif")
{
$back = imagecreatefromgif("$image");
}
if($smallext=="jpeg")
{
$back = imagecreatefromjpeg("$image");
}
if($smallext=="jpg")
{
$back = imagecreatefromjpeg("$image");
}
if($smallext=="png")
{
$back = imagecreatefrompng("$image");
}

if($imaheight<=$resheight)
{
$resize=$back;
}

if($imaheight>$resheight)
{
$sizey=$resheight; $sizex=$resheight*$imawidth/$imaheight;
$resize=ImageCreateTrueColor($sizex,$sizey);
imagecopyresized($resize, $back, 0, 0, 0, 0, $sizex, $sizey, $imawidth, $imaheight);
}
}
imagejpeg($resize);
imagedestroy($resize);
?>
