如何使用Imagick

时间:2018-03-15 09:58:50

标签: php imagemagick imagick

enter image description here

这是我的第一个演示,代码如下所示。

<?php

     $overlay = new \Imagick( realpath ("c:/wamp64/www/photo_effect/photos/3809.jpg" ) );
     $imagick = new \Imagick( realpath ( "c:/wamp64/www/photo_effect/photos/overly.png" ) );

     $overlay->setImageVirtualPixelMethod ( \Imagick::VIRTUALPIXELMETHOD_TRANSPARENT );

     $width = $overlay->getImageWidth ();
     $height = $overlay->getImageHeight ();

     $offset = 332.9;

     $points = array (
           0 ,0 ,364,51 ,
           $width ,0 ,473.4 ,23 ,
           0 ,$height ,433.5  ,182 ,
           $width ,$height ,523  ,119.4
      );

     //$overlay->modulateImage (97,100,0);
     $overlay->distortImage ( \Imagick::DISTORTION_PERSPECTIVE ,$points ,true );

     $imagick->compositeImage ( $overlay ,\Imagick::COMPOSITE_OVER ,364.5 - $offset ,23.5 );

     $imagick->writeImage ( "c:/wamp64/www/photo_effect/uploads/real.jpg" );

?>
  

当我使用其他图像时,它不适合此帧背景图像。

enter image description here

  

这是我的演示

enter image description here

<?php

    $overlay = new \Imagick( realpath ( "c:/wamp64/www/photo_effect/photos/3809.jpg" ) );
    $imagick = new \Imagick( realpath ( "c:/wamp64/www/photo_effect/photos/Frame.png" ) );

    $overlay->setImageVirtualPixelMethod ( \Imagick::VIRTUALPIXELMETHOD_TRANSPARENT );

    $width = $overlay->getImageWidth ();
    $height = $overlay->getImageHeight ();

    //$offset = 100.9;

    $points = array (
         0 ,0 ,364,51 ,
         $width ,0 ,473.4 ,23 ,
         0 ,$height ,200,349 ,
         $width ,$height ,714,349
    );

   //$overlay->modulateImage (97,100,0);
   $overlay->distortImage ( \Imagick::DISTORTION_PERSPECTIVE ,$points ,true );

   $imagick->compositeImage ( $overlay ,\Imagick::COMPOSITE_OVER ,364.5 ,23.5 );

   $imagick->writeImage ("c:/wamp64/www/photo_effect/uploads/success.jpg" );

 ?>
  

那么,我如何在两幅图像中找到合适的像素坐标。我如何合成两个图像。另外如何在PHP-Imagick中旋转图像

0 个答案:

没有答案