Quantcast
Channel: omnioo lab. record » PHP/MySQL
Viewing all articles
Browse latest Browse all 59

imagemagickで四角を描画する(塗りつぶす)

$
0
0

文法的には簡単でこんな感じになります。
rectangle([x],[y],[width],[height]);
rectangleは描画なのでDrawします。Sample

<?php
$imagefile = “./images/sample.jpg”;
# 画像の読み込み
$base = new Imagick($imagefile);

# 四角形を描画
$idraw = new ImagickDraw();

$idraw->setFillColor(“#ffffff”); # 描画色
$idraw->setFillOpacity(0.3); # 透明度

$x = rand(0,1280);
$y = rand(0,980);
$width = rand(0,1280);
$height = rand(0,980);

$idraw->rectangle($x,$y,$width,$height); # 四角形座標
$base->drawImage($idraw); # 四角形を描画
ob_clean();

header(“Content-Type: image/jpeg”); //表示する画像ヘッダー
echo $base;
$base->clear();



Viewing all articles
Browse latest Browse all 59

Trending Articles