FW: Imagick morphImages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I found the following code here: https://gist.github.com/mywebpower/1035026
It appears 2 years old though ...

<?php
/**
 * GD+Imagick = morphing
 * 
 * @param string  $fromPath
 * @param string  $toPath
 * @param string  $outPath
 * @param integer $frame OPTIONAL
 * @param integer $delay OPTIONAL
 */
function morph($fromPath, $toPath, $outPath, $frame=10, $delay=1) {
  $im = new Imagick();

  $gf = imagecreatefromjpeg($fromPath);  
  $gt = imagecreatefromjpeg($toPath);
  $sz = getimagesize($toPath);
  
  $wkImg = '__work__.jpg';
  
  for($i=1; $i<=$frame; $i++) {
    
    imagecopymerge($gf, $gt, 0,0, 0,0, $sz[0],$sz[1], (100/$frame)*$i);
    imagejpeg($gf, $wkImg);
    
    $tmp = new Imagick($wkImg);
    $tmp->setFormat('gif');
    $tmp->setImageDelay($delay*100);
    $im->addImage($tmp);
    
    $tmp->destroy();
    unlink($wkImg);
  }
  
  $im->writeImages($outPath, true);
  $im->destroy();
  imagedestroy($gf);
  imagedestroy($gt);
}

// ex
morph('a.jpg', 'b.jpg', 'out.gif', 10, 0.1);
?>

Hope it helps,
Jen


-----Original Message-----
From: Leonard Burton [mailto:leonardburton@xxxxxxxxx] 
Sent: Monday, March 11, 2013 1:26 PM
To: php-general@xxxxxxxxxxxxx
Subject:  Imagick morphImages

HI,

*Imagick::morphImages* ( int $number_frames )

http://php.net/manual/en/imagick.morphimages.php


Would someone please reply with how to add the two images for this?

None of the search results come back with anything other than the
auto-generated info on the imagick class.

Many Thanks!



--
Leonard Burton, N9URK
leonardburton@xxxxxxxxx

"The prolonged evacuation would have dramatically affected the survivability
of the occupants."


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux