%PDF- %PDF-
Direktori : /opt/cpanel/ea-php80/root/usr/share/tests/pecl/imagick/tests/ |
Current File : //opt/cpanel/ea-php80/root/usr/share/tests/pecl/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( (int)($imagick->getImageWidth() / 2), (int)($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