Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 4148

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 a PNG image to either the browser or a file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagepalettetotruecolor.html">imagepalettetotruecolor</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagepolygon.html">imagepolygon</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.imagepng" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagepng</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">imagepng</span> &mdash; <span class="dc-title">Output a PNG image to either the browser or a file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagepng-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>imagepng</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>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$quality</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$filters</code></span>
  ]]] )</div>

  <p class="para rdfs-comment">
   Outputs or saves a <acronym title="Portable Network Graphics">PNG</acronym> image from the given 
   <code class="parameter">image</code>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagepng-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>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        <strong><code>NULL</code></strong> is invalid if the <code class="parameter">quality</code> and
        <code class="parameter">filters</code> arguments are not used.
       </p>
      </p></blockquote>
     </dd>

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

     <dd>

      <p class="para">
       Compression level: from 0 (no compression) to 9. The current default is 6.
       For more information see the <a href="http://www.zlib.net/manual.html" class="link external">&raquo;&nbsp;zlib manual</a>.
      </p>
     </dd>

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

     <dd>

      <p class="para">
       Allows reducing the PNG file size. It is a bitmask field which may be
       set to any combination of the <em>PNG_FILTER_XXX</em> 
       constants. <strong><code>PNG_NO_FILTER</code></strong> or 
       <strong><code>PNG_ALL_FILTERS</code></strong> may also be used to respectively
       disable or activate all filters.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagepng-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.imagepng-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>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>

      <tr>
       <td>5.1.3</td>
       <td>
        Added the <code class="parameter">filters</code> parameter.
       </td>
      </tr>

      <tr>
       <td>5.1.2</td>
       <td>
        Added the <code class="parameter">quality</code> parameter.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.imagepng-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="informalexample">
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #DD0000">"test.png"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-Type:&nbsp;image/png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<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 seealso" id="refsect1-function.imagepng-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.imagegif.html" class="function" rel="rdfs-seeAlso">imagegif()</a> - Output image to browser or file</span></li>
    <li class="member"><span class="function"><a href="function.imagewbmp.html" class="function" rel="rdfs-seeAlso">imagewbmp()</a> - Output image to browser or file</span></li>
    <li class="member"><span class="function"><a href="function.imagejpeg.html" class="function" rel="rdfs-seeAlso">imagejpeg()</a> - Output image to browser or file</span></li>
    <li class="member"><span class="function"><a href="function.imagetypes.html" class="function" rel="rdfs-seeAlso">imagetypes()</a> - Return the image types supported by this PHP build</span></li>
    <li class="member"><span class="function"><a href="function.imagesavealpha.html" class="function" rel="rdfs-seeAlso">imagesavealpha()</a> - Set the flag to save full alpha channel information (as opposed to single-color transparency) when saving PNG images</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.imagepalettetotruecolor.html">imagepalettetotruecolor</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagepolygon.html">imagepolygon</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>