<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.imagick.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'imagick.deskewimage.php',
    1 => 'Imagick::deskewImage',
    2 => 'Removes skew from the image',
  ),
  'up' => 
  array (
    0 => 'class.imagick.php',
    1 => 'Imagick',
  ),
  'prev' => 
  array (
    0 => 'imagick.deleteimageproperty.php',
    1 => 'Imagick::deleteImageProperty',
  ),
  'next' => 
  array (
    0 => 'imagick.despeckleimage.php',
    1 => 'Imagick::despeckleImage',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/imagick/imagick/deskewimage.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="imagick.deskewimage" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Imagick::deskewImage</h1>
  <p class="verinfo">(PECL imagick 2 &gt;= 2.3.0, PECL imagick 3 &gt;= 3.3.0)</p><p class="refpurpose"><span class="refname">Imagick::deskewImage</span> &mdash; <span class="dc-title">Removes skew from the image</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-imagick.deskewimage-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Imagick::deskewImage</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.float.php" class="type float">float</a></span> <code class="parameter">$threshold</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   This method can be used to remove skew from for example scanned images where the paper
   was not properly placed on the scanning surface. This method is available if Imagick has been compiled against ImageMagick version 6.4.5 or newer.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-imagick.deskewimage-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">threshold</code></dt>
     <dd>
      <p class="para">
       Deskew threshold
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-imagick.deskewimage-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">

  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-imagick.deskewimage-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
    <div class="example" id="example-1">
      <p><strong>Example #1  <span class="function"><strong>Imagick::deskewImage()</strong></span></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: #007700">function </span><span style="color: #0000BB">deskewImage</span><span style="color: #007700">(</span><span style="color: #0000BB">$threshold</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$imagick </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">(</span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">"images/NYTimes-Page1-11-11-1918.jpg"</span><span style="color: #007700">));<br />    </span><span style="color: #0000BB">$deskewImagick </span><span style="color: #007700">= clone </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">;<br />    <br />    </span><span style="color: #FF8000">//This is the only thing required for deskewing.<br />    </span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">deskewImage</span><span style="color: #007700">(</span><span style="color: #0000BB">$threshold</span><span style="color: #007700">);<br /><br />    </span><span style="color: #FF8000">//The rest of this example is to make the result obvious - because<br />    //otherwise the result is not obvious.<br />    </span><span style="color: #0000BB">$trim </span><span style="color: #007700">= </span><span style="color: #0000BB">9</span><span style="color: #007700">;<br /><br />    </span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">cropImage</span><span style="color: #007700">(</span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageWidth</span><span style="color: #007700">() - </span><span style="color: #0000BB">$trim</span><span style="color: #007700">, </span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageHeight</span><span style="color: #007700">(), </span><span style="color: #0000BB">$trim</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">cropImage</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageWidth</span><span style="color: #007700">() - </span><span style="color: #0000BB">$trim</span><span style="color: #007700">, </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageHeight</span><span style="color: #007700">(), </span><span style="color: #0000BB">$trim</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">resizeimage</span><span style="color: #007700">(</span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageWidth</span><span style="color: #007700">() / </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageHeight</span><span style="color: #007700">() / </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">FILTER_LANCZOS</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">resizeimage</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageWidth</span><span style="color: #007700">() / </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageHeight</span><span style="color: #007700">() / </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">FILTER_LANCZOS</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$newCanvas </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">();<br />    </span><span style="color: #0000BB">$newCanvas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">newimage</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageWidth</span><span style="color: #007700">() + </span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageWidth</span><span style="color: #007700">() + </span><span style="color: #0000BB">20</span><span style="color: #007700">, </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageHeight</span><span style="color: #007700">(), </span><span style="color: #DD0000">'red'</span><span style="color: #007700">, </span><span style="color: #DD0000">'jpg'</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$newCanvas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">compositeimage</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagick</span><span style="color: #007700">, </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COMPOSITE_COPY</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$newCanvas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">compositeimage</span><span style="color: #007700">(</span><span style="color: #0000BB">$deskewImagick</span><span style="color: #007700">, </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COMPOSITE_COPY</span><span style="color: #007700">, </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageWidth</span><span style="color: #007700">() + </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #0000BB">0</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: image/jpg"</span><span style="color: #007700">);<br />    echo </span><span style="color: #0000BB">$newCanvas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageBlob</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

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


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