<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/image.examples.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'image.examples-png.php',
    1 => 'PNG creation with PHP',
    2 => 'PNG creation with PHP',
  ),
  'up' => 
  array (
    0 => 'image.examples.php',
    1 => 'Приклади',
  ),
  'prev' => 
  array (
    0 => 'image.examples.php',
    1 => 'Приклади',
  ),
  'next' => 
  array (
    0 => 'image.examples-watermark.php',
    1 => 'Adding watermarks to images using alpha channels',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/image/examples.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="image.examples-png" class="section">
  <h2 class="title">PNG creation with PHP</h2>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 PNG creation with PHP</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-type: image/png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$string </span><span style="color: #007700">= </span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'text'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">$im     </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #DD0000">"images/button1.png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$orange </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">220</span><span style="color: #007700">, </span><span style="color: #0000BB">210</span><span style="color: #007700">, </span><span style="color: #0000BB">60</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$px     </span><span style="color: #007700">= (</span><span style="color: #0000BB">imagesx</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">) - </span><span style="color: #0000BB">7.5 </span><span style="color: #007700">* </span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">)) / </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">imagestring</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">, </span><span style="color: #0000BB">$px</span><span style="color: #007700">, </span><span style="color: #0000BB">9</span><span style="color: #007700">, </span><span style="color: #0000BB">$string</span><span style="color: #007700">, </span><span style="color: #0000BB">$orange</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
   This example would be called from a page with a tag like: <code class="literal">&lt;img
   src=&quot;button.php?text=text&quot;&gt;</code>. The above <var class="filename">button.php</var> script
   then takes this <code class="literal">&quot;text&quot;</code> string and overlays it on top of a
   base image which in this case is <code class="literal">&quot;images/button1.png&quot;</code>
   and outputs the resulting image. This is a very convenient way to
   avoid having to draw new button images every time you want to
   change the text of a button. With this method they are
   dynamically generated.
  </p>
 </div><?php manual_footer($setup); ?>