<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja" dir="ltr">
<head>
<title>sample538(ImageMagick6.4.2)</title>
</head>
<body>
<?php
/* 画像を円形に切り取って、点線が回転するアニメーションGIFを作成する */
$images = new Imagick();
for($ii=0;$ii<8;$ii++){
 $im = new Imagick('sample3b.jpg');
 $im2 = new Imagick();
 $im2->newImage($im->getImageWidth(), $im->getImageHeight(), "none");
 $idraw = new ImagickDraw();
 $idraw->setFillColor('#ffffff');
 $idraw->ellipse(
   $im->getImageWidth()/2, $im->getImageHeight()/2,
   $im->getImageWidth()/2-2, $im->getImageHeight()/2-2,0,360);
 $im2->drawImage($idraw);
 $idraw->clear();
 $idraw->destroy();
 /* マスクを使用して切り取り */
 $im2->compositeImage($im, Imagick::COMPOSITE_IN, 0, 0, Imagick::CHANNEL_ALL);
 $idraw = new ImagickDraw();
 $idraw->setFillColor("none");
 $idraw->setStrokeColor('#c0b49d');
 /* 点線のスタイル */
 $idraw->setStrokeDashArray(array(4,4));
 /* 点線のオフセット */
 $idraw->setStrokeDashOffset($ii);
 /* 線の太さ */
 $idraw->setStrokeWidth(2);
 $idraw->ellipse(
   $im->getImageWidth()/2, $im->getImageHeight()/2,
   $im->getImageWidth()/2-3, $im->getImageHeight()/2-3,0,360);
 $im2->drawImage($idraw);
 $images->addImage($im2);
/* $idraw->clear(); 2008/09/30追記:destroyと同様にClearDrawingWandを呼ぶので必要なし */
 $idraw->destroy();
/* $im2->clear();  2008/09/30追記:destroyと同様にClearMagicWandを呼ぶので必要なし */
 $im2->destroy();
/* $im->clear();  2008/09/30追記:destroyと同様にClearMagicWandを呼ぶので必要なし */
 $im->destroy();
}
$images->setImageDelay(10);
$images->writeImages('sample538a.gif', true);
/* $images->clear();  2008/09/30追記:destroyと同様にClearMagicWandを呼ぶので必要なし */
$images->destroy();
?>
<img src="sample538a.gif" />
</body>
</html>
元画像(sample3b.jpg)

出力画像(sample538a.gif)
 
 
No comments:
Post a Comment