Convert a true color image to a palette image in PHP

Description

The following code shows how to convert a true color image to a palette image.

Example


<?php//from  w ww . ja v  a  2s  .  co m
// Create a new true color image
$im = imagecreatetruecolor(100, 100);

// Convert to palette-based with no dithering and 255 colors
imagetruecolortopalette($im, false, 255);

// Save the image
imagepng($im, './test.png');
imagedestroy($im);
?>




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text