Donc j’ai codé mon propre filtre sur la base du filtre image_sepia :
// Passe tous les pixels non transparent de l'image ds la couleur donnée en paramètre
// si pas de paramètre couleur ou paramètre vide, retourne l'image tel quel.
function image_nonTransp2couleur($im, $rgb = "") {
if($rgb=="") return $im;
include_spip('filtres/images_lib');
if (!function_exists("imagecreatetruecolor")) {
return $im;
}
$couleurs = _couleur_hex_to_dec($rgb);
$dr = $couleurs["red"];
$dv = $couleurs["green"];
$db = $couleurs["blue"];
$fonction = array('image_sepia', func_get_args());
$image = _image_valeurs_trans($im, "blanc2couleur-$dr-$dv-$db", false, $fonction);
if (!$image) {
return ("");
}
$x_i = $image["largeur"];
$y_i = $image["hauteur"];
$im = $image["fichier"];
$dest = $image["fichier_dest"];
$creer = $image["creer"];
if ($creer) {
// Creation de l'image en deux temps
// de facon a conserver les GIF transparents
$im = $image["fonction_imagecreatefrom"]($im);
imagepalettetotruecolor($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);
imagecopy($im_, $im, 0, 0, 0, 0, $x_i, $y_i);
for ($x = 0; $x < $x_i; $x++) {
for ($y = 0; $y < $y_i; $y++) {
$rgb = ImageColorAt($im_, $x, $y);
$a = ($rgb >> 24) & 0xFF;
$color = ImageColorAllocateAlpha($im_, $dr, $dv, $db, $a);
imagesetpixel($im_, $x, $y, $color);
}
}
_image_gd_output($im_, $image);
imagedestroy($im_);
imagedestroy($im);
}
return _image_ecrire_tag($image, array('src' => $dest));
}