2014){ $img2 = $server."/nbbl-jbbl/img/players/".$_REQUEST[saison]."/".$_REQUEST[player_id]."-40.jpg"; // File image location $img = "../../nbbl-jbbl/img/players/".$_REQUEST[saison]."/".$_REQUEST[player_id]."-40.jpg"; // File image location } #print $img; header("Content-Type: image/png"); $expires = 60*60*24*14; header("Pragma: public"); header("Cache-Control: maxage=".$expires); header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); #$img = $server."/images/players/".$_REQUEST[saison]."/png/".$_REQUEST[player_id].".png"; // File image location if (file_exists($img)){ $last_modified_time = filemtime($img); $etag = md5_file($img); header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT"); header("Etag: $etag"); #$w = 40; $h = 40; //Check if GD extension is loaded if (!extension_loaded('gd') && !extension_loaded('gd2')) { trigger_error("GD is not loaded", E_USER_WARNING); return false; } //Get Image size info $imgInfo = getimagesize($img); #print_r($imgInfo); switch ($imgInfo[2]) { case 1: $im = imagecreatefromgif($img); break; case 2: $im = imagecreatefromjpeg($img); break; case 3: $im = imagecreatefrompng($img); break; default: trigger_error('Unsupported filetype!', E_USER_WARNING); break; } //If image dimension is smaller, do not resize if ($imgInfo[0] <= $w && $imgInfo[1] <= $h) { $nHeight = $imgInfo[1]; $nWidth = $imgInfo[0]; }else{ //yeah, resize it, but keep it proportional if ($w/$imgInfo[0] > $h/$imgInfo[1]) { $nWidth = $w; $nHeight = $imgInfo[1]*($w/$imgInfo[0]); }else{ $nWidth = $imgInfo[0]*($h/$imgInfo[1]); $nHeight = $h; } } $nWidth = round($nWidth); $nHeight = round($nHeight); $newImg = imagecreatetruecolor($nWidth, $nHeight); /* Check if this image is PNG or GIF, then set if Transparent*/ if(($imgInfo[2] == 1) OR ($imgInfo[2]==3)){ imagealphablending($newImg, false); imagesavealpha($newImg,true); $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127); imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent); } imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]); $mask = imagecreatefrompng('player-bg2.png'); imagealphablending($mask, 1); imagecopy($mask, $newImg, 0,0,0,0,40,40); imagepng($mask); imagedestroy($mask); }else{ $mask = imagecreatefrompng('player-bg2.png'); imagepng($mask); imagedestroy($mask); } ?>