FW: [PHP] Imagick morphImages

[email protected] ("Jen Rasmussen")
Newsgroups php.general
Organization Cetacea Sound Corp
Message-ID <003d01ce1e87$b6b58250$242086f0$@com>
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:[email protected]] 
Sent: Monday, March 11, 2013 1:26 PM
To: [email protected]
Subject: [PHP] 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
[email protected]

"The prolonged evacuation would have dramatically affected the survivability
of the occupants."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.