<HTML ><HEAD ><TITLE >imagetruecolortopalette</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Image functions" HREF="ref.image.html"><LINK REL="PREVIOUS" TITLE="imagesy" HREF="function.imagesy.html"><LINK REL="NEXT" TITLE="imagettfbbox" HREF="function.imagettfbbox.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.imagesy.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.imagettfbbox.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.imagetruecolortopalette" ></A >imagetruecolortopalette</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN36705" ></A ><P > (PHP 4 >= 4.0.6)</P >imagetruecolortopalette -- Convert a true color image to a palette image</DIV ><DIV CLASS="refsect1" ><A NAME="AEN36708" ></A ><H2 >Description</H2 >void <B CLASS="methodname" >imagetruecolortopalette</B > ( resource image, bool dither, int ncolors)<BR ></BR ><P > <B CLASS="function" >imagetruecolortopalette()</B > converts a truecolor image to a palette image. The code for this function was originally drawn from the Independent JPEG Group library code, which is excellent. The code has been modified to preserve as much alpha channel information as possible in the resulting palette, in addition to preserving colors as well as possible. This does not work as well as might be hoped. It is usually best to simply produce a truecolor output image instead, which guarantees the highest output quality. </P ><P > <TT CLASS="parameter" ><I >dither</I ></TT > indicates if the image should be dithered - if it is <TT CLASS="constant" ><B >TRUE</B ></TT > then dithering will be used which will result in a more speckled image but with better color approximation. </P ><P > <TT CLASS="parameter" ><I >ncolors</I ></TT > sets the maximum number of colors that should be retained in the palette. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > This function was added in PHP 4.0.6 and requires GD 2.0.1 or later </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.imagesy.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.imagettfbbox.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >imagesy</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.image.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >imagettfbbox</TD ></TR ></TABLE ></DIV ></BODY ></HTML >