<!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>sample887(ImageMagick6.4.8)</title>
</head>
<body>
<?php
/* 立体的な角丸四角の枠をつける */
/* 余白 */
$padx = 10;
$pady = 10;
/* 角丸 */
$rx = 20;
$ry = 20;
/* 線の太さ */
$sw = 8;
$im = new Imagick("sf.jpg");
/* 枠部分を作成 */
$im2 = new Imagick();
$im2->newPseudoImage(
$im->getImageWidth(), $im->getImageHeight(), "xc:none");
$idraw = new ImagickDraw();
$idraw->setFillColor("none");
$idraw->setStrokeColor("white");
$idraw->setStrokeWidth($sw);
$idraw->roundrectangle($padx,$pady,
$im->getImageWidth()-$padx-1, $im->getImageHeight()-$pady-1,
$rx, $ry);
$im2->drawImage($idraw);
$im3 = $im2->clone();
$im3->blurImage(0,3,Imagick::CHANNEL_RED + Imagick::CHANNEL_GREEN
+ Imagick::CHANNEL_BLUE);
$im3->shadeImage(false, 135, 23);
$im2->compositeImage($im3, Imagick::COMPOSITE_HARDLIGHT, 0, 0);
/* 角丸四角で切り取り */
$im4 = new Imagick();
$im4->newPseudoImage(
$im->getImageWidth(), $im->getImageHeight(), "xc:none");
$idraw2 = new ImagickDraw();
$idraw2->setFillColor("white");
$idraw2->setStrokeColor("white");
$idraw2->setStrokeWidth($sw);
$idraw2->roundrectangle($padx,$pady,
$im->getImageWidth()-$padx-1, $im->getImageHeight()-$pady-1,
$rx, $ry);
$im4->drawImage($idraw2);
$im4->compositeImage($im, Imagick::COMPOSITE_IN, 0, 0,
Imagick::CHANNEL_ALL);
$im4->compositeImage($im2, Imagick::COMPOSITE_DEFAULT,
0, 0, Imagick::CHANNEL_ALL);
$im4->writeImage('sample887a.png');
$idraw2->destroy();
$idraw->destroy();
$im4->destroy();
$im3->destroy();
$im2->destroy();
$im->destroy();
?>
<img src="sample887a.png" /><br />
</body>
</html>
元画像(sf.jpg)
出力画像(sample887a.png)
関連項目
ImageMagickで画像に立体的な角丸四角の枠をつける
No comments:
Post a Comment