<?
$img = $Picture;
if(eregi(".jpg$", $img) && file_exists("./$img"));
{
    $sTargetfile = "/tmp/".mktime().".jpg";
    touch($sTargetfile); 
    chmod ($sTargetfile, 0755); 

    $img_src_size=getimagesize($_SERVER["DOCUMENT_ROOT"]."$img"); 
    $img_src=imagecreatefromjpeg($_SERVER["DOCUMENT_ROOT"]."$img");
    if($img_src_size[0] > 500)
    {
        $Scale = 500 / $img_src_size[0];
        $Height = $img_src_size[1] * $Scale;
        $Width = 500;
    }
    else
    {
        $Height=$img_src_size[1];
        $Width=$img_src_size[0];
    }
    $img_dst= imagecreatetruecolor(500,$Height);
    imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, 500, $Height, $img_src_size[0], $img_src_size[1]); 
    imagejpeg($img_dst); 
    imagedestroy($img_dst); 
    imagedestroy($img_src); 
    system("rm -rf $sTargetfile");
}
?>
