<?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.imagecrop.php',
    1 => 'imagecrop',
    2 => 'Crop an image to the given rectangle',
  ),
  'up' => 
  array (
    0 => 'ref.image.php',
    1 => 'Функції GD та Image',
  ),
  'prev' => 
  array (
    0 => 'function.imagecreatetruecolor.php',
    1 => 'imagecreatetruecolor',
  ),
  'next' => 
  array (
    0 => 'function.imagecropauto.php',
    1 => 'imagecropauto',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/image/functions/imagecrop.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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, PHP 8)</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">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecrop</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.array.php" class="type array">array</a></span> <code class="parameter">$rectangle</code></span>): <span class="type"><span class="type"><a href="class.gdimage.php" class="type GdImage">GdImage</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></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">Параметри</h3>
  <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">rectangle</code></dt>
    <dd>
     <p class="para">
      The cropping rectangle as <span class="type"><a href="language.types.array.php" class="type array">array</a></span> with keys
      <code class="literal">x</code>, <code class="literal">y</code>, <code class="literal">width</code> and
      <code class="literal">height</code>.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.imagecrop-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Return cropped image object on success або <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в разі помилки.
  </p>
 </div>


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

     <tr>
      <td>8.0.0</td>
      <td>
       On success, this function returns a <span class="classname"><a href="class.gdimage.php" class="classname">GDImage</a></span> instance now;
       previously, a <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> was returned.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.imagecrop-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="imagecrop.example.basic">
   <p><strong>Приклад #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 </span><span style="color: #007700">= </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 </span><span style="color: #007700">= </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">), </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 </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecrop</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, [</span><span style="color: #DD0000">'x' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'y' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'width' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$size</span><span style="color: #007700">, </span><span style="color: #DD0000">'height' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$size</span><span style="color: #007700">]);<br />if (</span><span style="color: #0000BB">$im2 </span><span style="color: #007700">!== </span><span style="color: #0000BB">FALSE</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">, </span><span style="color: #DD0000">'example-cropped.png'</span><span style="color: #007700">);<br />}<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">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.imagecropauto.php" class="function" rel="rdfs-seeAlso">imagecropauto()</a> - Crop an image automatically using one of the available modes</span></li>
  </ul>
 </div>


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