1. Go to this page and download the library: Download markdock/imalette library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
markdock / imalette example snippets
use Imalette\Imalette;
use Imalette\Palette;
// Image
$image = "images/image.png"; // jpg/jpeg, png, gif, bmp, webp
// Palette
$palette = new Palette();
$palette->addColorRGB(0, 0, 0); // noir
$palette->addColorRGB(127, 127, 127); // gris
$palette->addColorRGB(255, 255, 255); // blanc
$palette->addColorRGBarray(array(255, 0, 0)); // rouge
$palette->addColorRGBarray(array(0, 255, 0)); // vert
$palette->addColorRGBarray(array(0, 0, 255)); // bleu
$palette->addColorRGBarray(array(255, 255, 0)); // jaune
$palette->addColorRGBarray(array(255, 0, 255)); // magenta
$palette->addColorRGBarray(array(0, 255, 255)); // cyan
$palette->addColorHEX("#FFA500"); // Orange
$palette->addColorHEX("#800080"); // Violet
$palette->addColorHEX("#FFC0CB"); // Rose
$palette->addColorHEX("#A52A2A"); // Marron
$palette->addColorHEX("#00FF00"); // Lime
$palette->addColorHEX("#808000"); // Olive
$palette->addColorHEX("#800000"); // Bordeaux
$palette->addColorHEX("#000080"); // Bleu marine
$palette->addColorHEX("#008080"); // Sarcelle
$palette->addColorHEX("#C0C0C0"); // Argent
$palette->addColorHEX("#FFD700"); // Or
// Imalette
$imalette = new Imalette();
$palcol = $imalette->findColor($palette, $image[, $ignore_color]); // Donne la couleur en HEX (exemple: #808000)
// $ignore_color est optionnel, sa valeur par défaut est array(250, 250, 250, '>=')
// Ce paramètre permet d'ignorer la couleur de fond. Les trois premières valeurs sont des valeurs RGB.
// La 4e valeur correspond à l'attitude à adopter vis-à-vis de cette couleur (ignorer seulement celle-ci ? tout ce qui est supérieur ? etc.): '>', '<', '>=', '<=', '==', '!='.
// Notons que les pixels invisibles ou trop transparents sont déjà ignorés.
// $ignore_color peut aussi être égal à -1. Dans ce cas, la couleur du premier pixel de l'image est utilisée pour détecter la couleur de fond et ignorer tous les pixels de la même couleur.
// Palette
$palette = $palette->getPalette(); // array avec toutes les couleurs en HEX
$palette = $palette->getColor(3); // récupère une couleur. paramètre id = [ 0 - (n-1) ]
// Imalette
$colors = $imalette->getColors($image[, $ignore_color]); // array contenant l'ensemble des pixels de l'image en RGB
$distance = $imalette->getDistance($p1, $p2); // calcule la distance Euclidenne entre deux points
$hex = $imalette->rgb2hex($rgb); // conversion rgb -> hex
$rgb = $imalette->hex2rgb($rgb); // conversion hex -> rgb
$lab = $imalette->rgb2lab($rgb); // conversion rgb -> lab
$rgb = $imalette->lab2rgb($rgb); // conversion lab -> rgb
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.