Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 4133

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Output GD image to browser or file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagegd2.html">imagegd2</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagegetclip.html">imagegetclip</a></div>
 <div class="up"><a href="ref.image.html">GD and Image Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.imagegd" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagegd</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">imagegd</span> &mdash; <span class="dc-title">Output GD image to browser or file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagegd-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>imagegd</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$to</code><span class="initializer"> = NULL</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Outputs a GD image to the given <code class="parameter">to</code>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagegd-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>
<code class="parameter">
image</code></dt>
<dd>
<p class="para">An image resource, returned by one of the image creation functions,
such as <span class="function"><a href="function.imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>.</p></dd>

    
     <dt>
<code class="parameter">to</code></dt>

     <dd>

      <p class="para">The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or <strong><code>NULL</code></strong>, the raw image stream will be outputted directly.</p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagegd-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure.
  </p>
  <div class="caution"><strong class="caution">Caution</strong><p class="simpara">However, if libgd fails to output the image, this function returns <strong><code>TRUE</code></strong>.</p></div>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.imagegd-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.2.0</td>
       <td>
        <span class="function"><strong>imagegd()</strong></span> now allows to output truecolor images.
        Formerly, these have been implicitly converted to palette.
       </td>
      </tr>

      <tr>
       <td>5.4.0</td>
       <td>
        Added support for passing a stream <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span> to
        <code class="parameter">to</code>.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.imagegd-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-3813">
    <p><strong>Example #1 Outputting a GD 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">//&nbsp;Create&nbsp;a&nbsp;blank&nbsp;image&nbsp;and&nbsp;add&nbsp;some&nbsp;text<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">120</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$text_color&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">233</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">14</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">91</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">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;&nbsp;</span><span style="color: #DD0000">"A&nbsp;Simple&nbsp;Text&nbsp;String"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text_color</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Output&nbsp;the&nbsp;image<br /></span><span style="color: #0000BB">imagegd</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Free&nbsp;up&nbsp;memory<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3814">
    <p><strong>Example #2 Saving a GD 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">//&nbsp;Create&nbsp;a&nbsp;blank&nbsp;image&nbsp;and&nbsp;add&nbsp;some&nbsp;text<br /></span><span style="color: #0000BB">$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">120</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">20</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$text_color&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">233</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">14</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">91</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">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;&nbsp;</span><span style="color: #DD0000">"A&nbsp;Simple&nbsp;Text&nbsp;String"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$text_color</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Save&nbsp;the&nbsp;gd&nbsp;image<br />//&nbsp;The&nbsp;file&nbsp;format&nbsp;for&nbsp;GD&nbsp;images&nbsp;is&nbsp;.gd,&nbsp;see&nbsp;http://www.libgd.org/GdFileFormats<br /></span><span style="color: #0000BB">imagegd</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'simple.gd'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Free&nbsp;up&nbsp;memory<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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

 <div class="refsect1 notes" id="refsect1-function.imagegd-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    The GD format is commonly used to allow fast loading of parts of images.
    Note that the GD format is only usable in GD-compatible applications.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagegd-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.imagegd2.html" class="function" rel="rdfs-seeAlso">imagegd2()</a> - Output GD2 image to browser or file</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagegd2.html">imagegd2</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagegetclip.html">imagegetclip</a></div>
 <div class="up"><a href="ref.image.html">GD and Image Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>