Sophie

Sophie

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

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>Crop an image to the given rectangle</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagecreatetruecolor.html">imagecreatetruecolor</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagecropauto.html">imagecropauto</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.imagecrop" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecrop</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7)</p><p class="refpurpose"><span class="refname">imagecrop</span> &mdash; <span class="dc-title">Crop an image to the given rectangle</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.imagecrop-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>imagecrop</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$rect</code></span>
   )</div>

  <p class="para rdfs-comment">
   Crops an image to the given rectangular area and returns the resulting image.
   The given <code class="parameter">image</code> is not modified.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.imagecrop-parameters">
  <h3 class="title">Parameters</h3>
  <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">rect</code></dt>

    <dd>

     <p class="para">
      The cropping rectangle as <span class="type"><a href="language.types.array.html" class="type array">array</a></span> with keys
      <em>x</em>, <em>y</em>, <em>width</em> and
      <em>height</em>.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagecrop-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Return cropped image resource on success or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecrop-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-3785">
   <p><strong>Example #1 <span class="function"><strong>imagecrop()</strong></span> example</strong></p>
   <div class="example-contents"><p>
     This example shows how to crop an image to a square area.
   </p></div>
   <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">'example.png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">min</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">),&nbsp;</span><span style="color: #0000BB">imagesy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$im2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecrop</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;[</span><span style="color: #DD0000">'x'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'y'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'width'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$size</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'height'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$size</span><span style="color: #007700">]);<br />if&nbsp;(</span><span style="color: #0000BB">$im2&nbsp;</span><span style="color: #007700">!==&nbsp;</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'example-cropped.png'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">);<br />}<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>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.imagecrop-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.imagecropauto.html" class="function" rel="rdfs-seeAlso">imagecropauto()</a> - Crop an image automatically using one of the available modes</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.imagecreatetruecolor.html">imagecreatetruecolor</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.imagecropauto.html">imagecropauto</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>