function image_etendre_alpha($im, $coul='000000', $trait=2) { $image = valeurs_image_trans($im, "etendre-$coul-$trait"); if (!$image) return(""); include_ecrire("filtres"); $couleurs = couleur_hex_to_dec($coul); $dr= $couleurs["red"]; $dv= $couleurs["green"]; $db= $couleurs["blue"]; $x_i = $image["largeur"]; $y_i = $image["hauteur"]; $im = $image["fichier"]; $dest = $image["fichier_dest"]; $creer = $image["creer"]; if ($creer) { $im = $image["fonction_imagecreatefrom"]($im); $im_ = imagecreatetruecolor($x_i, $y_i); @imagealphablending($im_, false); @imagesavealpha($im_,true); $color_t = ImageColorAllocateAlpha( $im_, 255, 255, 255 , 127 ); imagefill ($im_, 0, 0, $color_t); $dist = abs($trait); for ($x = 0; $x < $x_i; $x++) { for ($y=0; $y < $y_i; $y++) { $rgb = ImageColorAt($im, $x, $y); $a = ($rgb >> 24) & 0xFF; $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $dif = false; if ($trait > 0) $m = 127; else $m = 0; $t = 0; for ($ix = -1*$dist; $ix <= $dist; $ix++) { for ($iy = -1*$dist; $iy <= $dist; $iy++) { $x2 = max(min($x+$ix, $x_i-1),0); $y2 = max(min($y+$iy, $y_i-1),0); $rgb2 = ImageColorAt($im, $x2, $y2); $a2 = ($rgb2 >> 24) & 0xFF; $r2 = ($rgb2 >> 16) & 0xFF; $g2 = ($rgb2 >> 8) & 0xFF; $b2 = $rgb2 & 0xFF; $dx = $x2-$x; $dy = $y2-$y; if ($dx == 0 AND $dy == 0) { $d = 0; } else if (!$mem[$dx][$dy]) { $d = sqrt(($dx)*($dx)+($dy)*($dy)) / 1.4; $mem[$dx][$dy] = $d; } else { $d = $mem[$dx][$dy]; } if ($d <= abs($trait)) { if ($trait > 0) $m = min($m, $a2); else $m = max($m, $a2); } } } $color = ImageColorAllocateAlpha( $im_, $dr, $dv, $db , round($m) ); imagesetpixel ($im_, $x, $y, $color); } } $image["fonction_image"]($im_, "$dest"); } $class = $image["class"]; if (strlen($class) > 1) $tags=" class='$class'"; $tags = "$tags alt='".$image["alt"]."'"; $style = $image["style"]; return ""; } Le filtre s'utilise, essentiellement, sur une image typographique. Par exemple: [(#TITRE |image_typo{police=big_noodle_titling.ttf,taille=80})] [(#TITRE |image_typo{police=big_noodle_titling.ttf,taille=80} |image_etendre_alpha{ffffff,2})] [(#TITRE |image_typo{police=big_noodle_titling.ttf,taille=80} |image_etendre_alpha{ffffff,-2})]