1--TEST--
2Test Imagick, deskewImage
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6require_once(dirname(__FILE__) . '/skipif.inc');
7checkFormatPresent('jpg');
8?>
9--FILE--
10<?php
11
12$threshold = 0.5;
13
14function deskewImage($threshold) {
15    $imagick = $imagick = new \Imagick();
16    $imagick->newPseudoImage(640, 480, "magick:logo");
17    $deskewImagick = clone $imagick;
18
19    //This is the only thing required for deskewing.
20    $deskewImagick->deskewImage($threshold);
21
22    //The rest of this example is to make the result obvious - because
23    //otherwise the result is not obvious.
24    $trim = 9;
25
26    $deskewImagick->cropImage($deskewImagick->getImageWidth() - $trim, $deskewImagick->getImageHeight(), $trim, 0);
27    $imagick->cropImage($imagick->getImageWidth() - $trim, $imagick->getImageHeight(), $trim, 0);
28    $deskewImagick->resizeimage($deskewImagick->getImageWidth() / 2, $deskewImagick->getImageHeight() / 2, \Imagick::FILTER_LANCZOS, 1);
29    $imagick->resizeimage(
30        (int)($imagick->getImageWidth() / 2),
31        (int)($imagick->getImageHeight() / 2),
32        \Imagick::FILTER_LANCZOS,
33        1
34    );
35    $newCanvas = new \Imagick();
36    $newCanvas->newimage($imagick->getImageWidth() + $deskewImagick->getImageWidth() + 20, $imagick->getImageHeight(), 'red', 'jpg');
37    $newCanvas->compositeimage($imagick, \Imagick::COMPOSITE_COPY, 5, 0);
38    $newCanvas->compositeimage($deskewImagick, \Imagick::COMPOSITE_COPY, $imagick->getImageWidth() + 10, 0);
39
40    $bytes = $newCanvas->getImageBlob();
41    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
42}
43
44deskewImage($threshold) ;
45echo "Ok";
46?>
47--EXPECTF--
48Ok