$rH) { $nH = $rH; $nW = floor( $nH * $fW / $fH ); } } } // Allow enlargment if ( $aoe != 1 ) { if ( $nW > $fW ) { // Pas de modification $nW = $fW; $nH = floor( $nW * $fH / $fW ); } if ( $nH > $fH ) { // Pas de modification $nH = $fH; $nW = floor( $nH * $fW / $fH ); } } if ( !isset($_GET["fltr"]) ) { // Création d'une image $image_temp=imagecreatetruecolor($nW,$nH); // Redimensionnement imagecopyresampled($image_temp,$image_source,0,0,0,0,$nW,$nH,$fW,$fH); } } if ( isset($_GET["fltr"]) ) { $arrFltr=explode('|',$_GET["fltr"][0]); switch ( $arrFltr[0] ) { case "ric" : // COINS ARRONDIS $_GET["f"]="png"; $hR = $arrFltr[1]; // Horizontal radius $vR = $arrFltr[2]; // Vetical radius // Gestion du cache $new=urlencode(str_replace("http://","",$_SERVER["HTTP_REFERER"]))."-".md5($src)."-".$nW."-".$nH; if ( isset($_GET["fltr"]) ) $new.="-".str_replace("|","-",$_GET["fltr"][0]); $new.=".".$_GET["f"]; $temp="cache/".$new; if ($cache!=0) { if ( file_exists($temp) ) { header("Content-type: image/png"); readfile($temp); exit; } } @unlink($temp); $mask="cache/mask-".$new; @unlink($mask); // die($new); // Image redimensionnée if ( $zc == 1 ) { // Masque $commande="/usr/bin/convert -size ".$rW."x".$rH." xc:none -draw 'fill black ellipse ".$hR.",".$vR." ".$hR.",".$vR." 0,360' -draw 'fill black ellipse ".($rW-$hR-1).",".$vR." ".$hR.",".$vR." 0,360' -draw 'fill black ellipse ".$hR.",".($rH-$vR-1)." ".$hR.",".$vR." 0,360' -draw 'fill black ellipse ".($rW-$hR-1).",".($rH-$vR-1)." ".$hR.",".$vR." 0,360' -draw 'fill black rectangle ".$hR.",0 ".($rW-$hR-1).",".($rH-1)."' -draw 'fill black rectangle 0,".$vR." ".$rW.",".($rH-$vR-1)."' ".$mask; // Cas d'un cercle if ($hR==floor($rW/2) && $vR==floor($rH/2)) { $commande="/usr/bin/convert -size ".$rW."x".$rH." xc:none -draw 'fill black circle ".($hR-1).",".($vR-1)." 0,".$vR."' ".$mask; } exec($commande); // Fusion pour obtenir l'image temp $commande="/usr/bin/convert ".$src." -alpha set -resize ".$nW."x".$nH." -gravity center -crop ".$rW."x".$rH."+0+0 ".$mask." -compose dst-in -composite ".$temp; exec($commande); } else { // Masque $commande="/usr/bin/convert -size ".$nW."x".$nH." xc:none -draw 'fill black ellipse ".$hR.",".$vR." ".$hR.",".$vR." 0,360' -draw 'fill black ellipse ".($nW-$hR-1).",".$vR." ".$hR.",".$vR." 0,360' -draw 'fill black ellipse ".$hR.",".($nH-$vR-1)." ".$hR.",".$vR." 0,360' -draw 'fill black ellipse ".($nW-$hR-1).",".($nH-$vR-1)." ".$hR.",".$vR." 0,360' -draw 'fill black rectangle ".$hR.",0 ".($nW-$hR-1).",".($nH-1)."' -draw 'fill black rectangle 0,".$vR." ".$nW.",".($nH-$vR-1)."' ".$mask; // die($commande); if ($nW==floor($rW/2) && $nH==floor($rH/2)) { $commande="/usr/bin/convert -size ".$nW."x".$nH." xc:none -draw 'fill black circle ".($hR-1).",".($vR-1)." 0,".$vR."' ".$mask; } exec($commande); // Fusion pour obtenir l'image temp $commande="/usr/bin/convert ".$src." -alpha set -resize ".$nW."x".$nH." ".$mask." -compose dst-in -composite ".$temp; exec($commande); } // On envoie l'image à la sortie header("Content-type: image/png"); readfile($temp); @unlink($mask); exit; break; } } else { // Création d'une image à partir du firHier télérHargé switch ( $_GET['f'] ) { case 'gif' : header("Content-type: image/gif"); // Gestion du cache $new=urlencode(str_replace("http://","",$_SERVER["HTTP_REFERER"]))."-".md5($src)."-".$nW."-".$nH; if ( isset($_GET["fltr"]) ) $new.="-".str_replace("|","-",$_GET["fltr"][0]); $new.=".gif"; $temp="cache/".$new; if ($cache!=0) { if ( file_exists($temp) ) { readfile($temp); exit; } } @imagegif($image_temp,$temp); @imagegif($image_temp); break; case 'png' : header("Content-type: image/png"); // Gestion du cache $new=urlencode(str_replace("http://","",$_SERVER["HTTP_REFERER"]))."-".md5($src)."-".$nW."-".$nH; if ( isset($_GET["fltr"]) ) $new.="-".str_replace("|","-",$_GET["fltr"][0]); $new.=".png"; $temp="cache/".$new; if ($cache!=0) { if ( file_exists($temp) ) { readfile($temp); exit; } } @imagepng($image_temp,$temp); @imagepng($image_temp); break; default: header("Content-type: image/jpeg"); // Gestion du cache $new=urlencode(str_replace("http://","",$_SERVER["HTTP_REFERER"]))."-".md5($src)."-".$nW."-".$nH; if ( isset($_GET["fltr"]) ) $new.="-".str_replace("|","-",$_GET["fltr"][0]); $new.=".jpg"; $temp="cache/".$new; if ($cache!=0) { if ( file_exists($temp) ) { readfile($temp); exit; } } @imagejpeg($image_temp,$temp); @imagejpeg($image_temp); break; } @imagedestroy($image_temp); @imagedestroy($image_source); } } ?>