Current Path : /usr/opt/php72/share/pear/test/imagick/tests/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/php72/share/pear/test/imagick/tests/049_Imagick_deskewImage_basic.phpt |
--TEST-- Test Imagick, deskewImage --SKIPIF-- <?php $imageMagickRequiredVersion=0x675; require_once(dirname(__FILE__) . '/skipif.inc'); checkFormatPresent('jpg'); ?> --FILE-- <?php $threshold = 0.5; function deskewImage($threshold) { $imagick = $imagick = new \Imagick(); $imagick->newPseudoImage(640, 480, "magick:logo"); $deskewImagick = clone $imagick; //This is the only thing required for deskewing. $deskewImagick->deskewImage($threshold); //The rest of this example is to make the result obvious - because //otherwise the result is not obvious. $trim = 9; $deskewImagick->cropImage($deskewImagick->getImageWidth() - $trim, $deskewImagick->getImageHeight(), $trim, 0); $imagick->cropImage($imagick->getImageWidth() - $trim, $imagick->getImageHeight(), $trim, 0); $deskewImagick->resizeimage($deskewImagick->getImageWidth() / 2, $deskewImagick->getImageHeight() / 2, \Imagick::FILTER_LANCZOS, 1); $imagick->resizeimage($imagick->getImageWidth() / 2, $imagick->getImageHeight() / 2, \Imagick::FILTER_LANCZOS, 1); $newCanvas = new \Imagick(); $newCanvas->newimage($imagick->getImageWidth() + $deskewImagick->getImageWidth() + 20, $imagick->getImageHeight(), 'red', 'jpg'); $newCanvas->compositeimage($imagick, \Imagick::COMPOSITE_COPY, 5, 0); $newCanvas->compositeimage($deskewImagick, \Imagick::COMPOSITE_COPY, $imagick->getImageWidth() + 10, 0); $bytes = $newCanvas->getImageBlob(); if (strlen($bytes) <= 0) { echo "Failed to generate image.";} } deskewImage($threshold) ; echo "Ok"; ?> --EXPECTF-- Ok