<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.image.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.imagetruecolortopalette.php',
    1 => 'imagetruecolortopalette',
    2 => 'Convert a true color image to a palette image',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'Функції GD та Image',
  ),
  'prev' => 
  array (
    0 => 'function.imagesy.php',
    1 => 'imagesy',
  ),
  'next' => 
  array (
    0 => 'function.imagettfbbox.php',
    1 => 'imagettfbbox',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/image/functions/imagetruecolortopalette.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.imagetruecolortopalette" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagetruecolortopalette</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">imagetruecolortopalette</span> &mdash; <span class="dc-title">Convert a true color image to a palette image</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagetruecolortopalette-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagetruecolortopalette</strong></span>(<span class="methodparam"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span> <code class="parameter">$image</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$dither</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$num_colors</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>imagetruecolortopalette()</strong></span> 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>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagetruecolortopalette-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    <dt><code class="parameter">image</code></dt><dd><p class="para">Об&#039;єкт
<span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>, що повертається однією з функцій створення
зображення, такою як
<span class="function"><a href="function.imagecreatetruecolor.php" class="function">imagecreatetruecolor()</a></span>.</p></dd>
    
     <dt><code class="parameter">dither</code></dt>
     <dd>
      <p class="para">
       Indicates if the image should be dithered - if it is <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> then
       dithering will be used which will result in a more speckled image but
       with better color approximation.
      </p>
     </dd>
    
    
     <dt><code class="parameter">num_colors</code></dt>
     <dd>
      <p class="para">
       Sets the maximum number of colors that should be retained in the palette.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagetruecolortopalette-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Повертає <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> у разі успіху або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagetruecolortopalette-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  Тепер <code class="parameter">image</code> має бути примірником
  <span class="classname"><a href="class.gdimage.php" class="classname">GdImage</a></span>. Раніше очікувався
  <code class="literal">gd</code>-<span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagetruecolortopalette-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 Converting a true color image to a palette-based image</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Create a new true color image<br /></span><span style="color: #0000BB">$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">, </span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Convert to palette-based with no dithering and 255 colors<br /></span><span style="color: #0000BB">imagetruecolortopalette</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Save the image<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #DD0000">'./paletteimage.png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


</div><?php manual_footer($setup); ?>