L'étape d'après :
function pericolorlister( $liste, $path, $rouge, $vert, $bleu )
{
$files = $bornes = $rouges = $verts = $bleus = array() ; $delta = 25 ;
$colors = array( "rouge", "vert", "bleu" ) ;
foreach( $colors as $color ) $bornes[$color] = array( $$color-$delta, $$color+$delta ) ;
foreach( $liste as $file )
{
$image = ImageCreateFromJpeg( "$path/$file" ) ;
$width = imagesx( $image ) ;
$height = imagesy( $image ) ;
for( $x=0; $x<$width; $x++ ) for( $y=0; $y<$height; $y++ )
{
$rgb = ImageColorAt( $image, $x, $y ) ;
$rouges[] = ( $rgb >> 16 ) & 0xFF ;
$verts[] = ( $rgb >> 8 ) & 0xFF ;
$bleus[] = $rgb & 0xFF ;
}
$nombre = $width * $height ;
$rouge = round( array_sum( $rouges ) / $nombre ) ;
$vert = round( array_sum( $verts ) / $nombre ) ;
$bleu = round( array_sum( $bleus ) / $nombre ) ;
if( $rouge > $bornes["rouge"][0] && $rouge < $bornes["rouge"][1]
&& $vert > $bornes["vert"][0] && $vert < $bornes["vert"][1]
&& $bleu > $bornes["bleu"][0] && $bleu < $bornes["bleu"][1]
)
$files[] = tag( $file, "li" ) ;
}
return tag( "liste des images proches de la couleur indiquée", "h3" ).tag( $files, "ol" ) ;
}
Et la fonction tag :
function tag()
{
$arguments = func_get_args() ;
$curseur = trim( is_array( $arguments[0] ) ? join( NL, $arguments[0] ) : $arguments[0] ) ;
$intercalaire = pallsdenombrer( $curseur ) || strlen( $curseur ) > 200 ? NL : VIDE ;
foreach( $arguments as $no => $argument ) if( $no && $argument )
{
$commentaire = VIDE ;
$attributs = explode( SPACE, $argument ) ;
if( ! defined( "??" ) ) define( "??", TRUE ) ;
foreach( $attributs as $no => $attribut )
if( $no && $attribut ) { $commentaire = ?? ? commenter( $attribut ) : VIDE ; break ; }
$curseur = LT.$argument.GT.$intercalaire.$curseur.$intercalaire.LT.SLASH.$attributs[0].GT.$commentaire ;
}
return $curseur ;
}