PHP code example of net-tools / gd-indexed-color-converter
1. Go to this page and download the library: Download net-tools/gd-indexed-color-converter 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/ */
net-tools / gd-indexed-color-converter example snippets
// create an image
$image = imagecreatefromjpeg('example.jpg');
// create a gd indexed color converter
$converter = new GDIndexedColorConverter();
// the color palette
$palette = array(
array(0, 0, 0),
array(255, 255, 255),
array(255, 0, 0),
array(0, 255, 0),
array(0, 0, 255)
);
// convert the image to indexed color mode
$new_image = $converter->convertToIndexedColor($image, $palette, 0.8);
// save the new image
imagepng($new_image, 'example_indexed_color.png', 0);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.