Imagick::sparsecolorimage

creationdev

Documentation

Référencement web expert
Référencement web expert

750$ CAD

Formation référencement web
Formation référencement web

100$ CAD

Référencement web optimisé
Référencement web optimisé

500$ CAD

Conception web ecommerce
Conception web ecommerce

2500$ CAD

Conception web standard
Conception web standard

2500$ CAD

Conception web extra
Conception web extra

5000$ CAD

Référencement web stratégique
Référencement web stratégique

1000$ CAD

Conception web microsite
Conception web microsite

1000$ CAD

Conception d'application web
Conception d'application web

100$ CAD

Référencement web organique
Référencement web organique

300$ CAD

Méthode

Méthode

Imagick::sparsecolorimage

Imagick::sparsecolorimage

Page Vue 26 déc. 2018
Page Vue 13 fois

(PECL imagick 2 >= 2.3.0, PECL imagick 3)

Imagick::sparseColorImage — Interpole les couleurs

Description

public Imagick::sparseColorImage(int $SPARSE_METHOD, array $arguments, int $channel = Imagick::CHANNEL_DEFAULT): bool

Le tableau fourni par le paramètre arguments contient les valeurs numériques utilisées par cette méthode pour interpoler les couleurs trouvées aux coordonnées de l'image entière en utilisant le paramètre sparse_method. Cette méthode n'est disponible que si Imagick a été compilé avec ImageMagick version 6.4.5 ou supérieur.

Liste de paramètres

SPARSE_METHOD

Référez-vous à la liste des constantes pour la méthode sparse.

arguments

Un tableau contenant les coordonnées. Le tableau est au format array(1,1, 2,45).

channel

Fournit une constante de canal valide pour votre mode de canal. Pour l'appliquer à plus d'un canal, combinez les constantes de canaux en utilisant un opérateur sur les bits. Par défaut, vaut Imagick::CHANNEL_DEFAULT. Reportez-vous à la liste des constantes de canaux

Valeurs de retour

Retourne true en cas de succès.

Erreurs / Exceptions

Lance une exception ImagickException si une erreur survient.

Exemples

Exemple #1 Exemple avec imagick::sparsecolorimage() et SPARSECOLORMETHOD_BARYCENTRIC

<?php
function renderImageBarycentric2() {
$points = [
[0.30, 0.10, 'red'],
[0.10, 0.80, 'blue'],
[0.70, 0.60, 'lime'],
[0.80, 0.20, 'yellow'],
];
$imagick = createGradientImage(
400, 400,
$points,
\Imagick::SPARSECOLORMETHOD_BARYCENTRIC
);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}

?>

Exemple #2 Exemple avec imagick::sparsecolorimage() et SPARSECOLORMETHOD_BILINEAR

<?php
function renderImageBilinear() {
$points = [[0.30, 0.10, 'red'], [0.10, 0.80, 'blue'], [0.70, 0.60, 'lime'], [0.80, 0.20, 'yellow'],];
$imagick = createGradientImage(500, 500, $points, \Imagick::SPARSECOLORMETHOD_BILINEAR);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}

?>

Exemple #3 Exemple avec imagick::sparsecolorimage() et SPARSECOLORMETHOD_SPEPARDS

<?php
function renderImageShepards() {
$points = [
[0.30, 0.10, 'red'],
[0.10, 0.80, 'blue'],
[0.70, 0.60, 'lime'],
[0.80, 0.20, 'yellow'],
];
$imagick = createGradientImage(600, 600, $points, \Imagick::SPARSECOLORMETHOD_SPEPARDS);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}

?>

Exemple #4 Exemple avec imagick::sparsecolorimage() et SPARSECOLORMETHOD_VORONOI

<?php
function renderImageVoronoi() {
$points = [
[0.30, 0.10, 'red'],
[0.10, 0.80, 'blue'],
[0.70, 0.60, 'lime'],
[0.80, 0.20, 'yellow'],
];
$imagick = createGradientImage(500, 500, $points, \Imagick::SPARSECOLORMETHOD_VORONOI);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}

?>

Exemple #5 Exemple avec imagick::sparsecolorimage() et SPARSECOLORMETHOD_BARYCENTRIC

<?php
function renderImageBarycentric() {
$points = [
[0, 0, 'skyblue'],
[-1, 1, 'skyblue'],
[1, 1, 'black'],
];
$imagick = createGradientImage(600, 200, $points, \Imagick::SPARSECOLORMETHOD_BARYCENTRIC);
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}

?>

Exemple #6 createGradientImage est utilisé par les autres exemples. imagick::sparsecolorimage()

<?php
function createGradientImage($width, $height, $colorPoints, $sparseMethod, $absolute = false) {

$imagick = new \Imagick();
$imagick->newImage($width, $height, "white");
$imagick->setImageFormat("png");

$barycentricPoints = array();

foreach ($colorPoints as $colorPoint) {

if ($absolute == true) {
$barycentricPoints[] = $colorPoint[0];
$barycentricPoints[] = $colorPoint[1];
}
else {
$barycentricPoints[] = $colorPoint[0] * $width;
$barycentricPoints[] = $colorPoint[1] * $height;
}

if (is_string($colorPoint[2])) {
$imagickPixel = new \ImagickPixel($colorPoint[2]);
}
else if ($colorPoint[2] instanceof \ImagickPixel) {
$imagickPixel = $colorPoint[2];
}
else{
$errorMessage = sprintf(
"Value %s is neither a string nor an ImagickPixel class. Cannot use as a color.",
$colorPoint[2]
);

throw new \InvalidArgumentException(
$errorMessage
);
}

$red = $imagickPixel->getColorValue(\Imagick::COLOR_RED);
$green = $imagickPixel->getColorValue(\Imagick::COLOR_GREEN);
$blue = $imagickPixel->getColorValue(\Imagick::COLOR_BLUE);
$alpha = $imagickPixel->getColorValue(\Imagick::COLOR_ALPHA);

$barycentricPoints[] = $red;
$barycentricPoints[] = $green;
$barycentricPoints[] = $blue;
$barycentricPoints[] = $alpha;
}

$imagick->sparseColorImage($sparseMethod, $barycentricPoints);

return $imagick;
}

?>


Source : http://www.php.net/
Ref : methode-imagick::sparsecolorimage.php




Contact

Contact

Veuillez saisir les infos dans le formulaire d'identification
suivant pour concevoir et référencer votre site.









Veuillez saisir votre message.

Carte d'affaires

Affichage de la carte d'affaires recto/verso.

Carte d'affaires recto
Carte d'affaires verso

Partagez

Partagez

Discussion ayant comme sujet la page Imagick::sparsecolorimage.

©2025 creationdev -  F.A.Q. -  Soutien -  Haut de page
THÈMES: