Skip to content
Extraits de code Groupes Projets
Valider 24192b20 rédigé par cerdic's avatar cerdic
Parcourir les fichiers

"#URL_DOCUMENT|image_recadre{largeur,hauteur,alignement}

alignement est pas defaut 'center' si non precise, et prend les valeurs left,right,center,top,bottom
par exemple
#URL_DOCUMENT|image_recadre{150,150,'top left'}
recadrera un carre de 150px dans le coin superieur gauche de l'image d'origine"
parent ec4f8b3e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -21,6 +21,7 @@ include_spip('inc/charsets'); ...@@ -21,6 +21,7 @@ include_spip('inc/charsets');
$GLOBALS['spip_matrice']['image_valeurs_trans'] = ''; $GLOBALS['spip_matrice']['image_valeurs_trans'] = '';
$GLOBALS['spip_matrice']['image_reduire'] = ''; $GLOBALS['spip_matrice']['image_reduire'] = '';
$GLOBALS['spip_matrice']['image_reduire_par'] = ''; $GLOBALS['spip_matrice']['image_reduire_par'] = '';
$GLOBALS['spip_matrice']['image_recadre'] = '';
$GLOBALS['spip_matrice']['image_alpha'] = ''; $GLOBALS['spip_matrice']['image_alpha'] = '';
$GLOBALS['spip_matrice']['image_flip_vertical'] = ''; $GLOBALS['spip_matrice']['image_flip_vertical'] = '';
$GLOBALS['spip_matrice']['image_flip_horizontal'] = ''; $GLOBALS['spip_matrice']['image_flip_horizontal'] = '';
......
...@@ -171,6 +171,63 @@ function image_alpha($im, $alpha = 63) ...@@ -171,6 +171,63 @@ function image_alpha($im, $alpha = 63)
return "<img src='$dest'$tags />"; return "<img src='$dest'$tags />";
} }
function image_recadre($im,$width,$height,$position='center')
{
$image = image_valeurs_trans($im, "recadre-$width-$height-$position");
if (!$image) return("");
$x_i = $image["largeur"];
$y_i = $image["hauteur"];
if ($width==0 OR $width>$x_i) $width==$x_i;
if ($height==0 OR $height>$y_i) $height==$y_i;
$offset_width = $x_i-$width;
$offset_height = $y_i-$height;
$position=strtolower($position);
if (strpos($position,'left')!==FALSE)
$offset_width=0;
elseif (strpos($position,'right')!==FALSE)
$offset_width=$offset_width;
else
$offset_width=intval(ceil($offset_width/2));
if (strpos($position,'top')!==FALSE)
$offset_height=0;
elseif (strpos($position,'bottom')!==FALSE)
$offset_height=$offset_height;
else
$offset_height=intval(ceil($offset_height/2));
$im = $image["fichier"];
$dest = $image["fichier_dest"];
$creer = $image["creer"];
if ($creer) {
$im = $image["fonction_imagecreatefrom"]($im);
$im_ = imagecreatetruecolor($width, $height);
@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, $offset_width, $offset_height, $width, $height);
$image["fonction_image"]($im_, "$dest");
imagedestroy($im_);
imagedestroy($im);
}
$class = $image["class"];
if (strlen($class) > 1) $tags=" class='$class'";
$tags = "$tags alt='".$image["alt"]."'";
$style = $image["style"];
if (strlen($style) > 1) $tags="$tags style='$style'";
return "<img src='$dest'$tags />";
}
// http://doc.spip.org/@image_flip_vertical // http://doc.spip.org/@image_flip_vertical
function image_flip_vertical($im) function image_flip_vertical($im)
{ {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter