<!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>sample389</title>
</head>
<body>
<?php
/* 上40ピクセルを切り落とし */
$im = new Imagick('sample4.jpg');
$im->chopImage(0,40,0,0);
$im->writeImage('sample389a.png');
/* $im->clear(); 2008/09/30追記:destroyと同様にClearMagicWandを呼ぶので必要なし */
$im->destroy();
/* 右10ピクセル下20ピクセルを切り落とし */
$im = new Imagick('sample4.jpg');
$im->chopImage(10,20,$im->getImageWidth()-10, $im->getImageHeight()-20);
$im->writeImage('sample389b.png');
/* $im->clear(); 2008/09/30追記:destroyと同様にClearMagicWandを呼ぶので必要なし */
$im->destroy();
?>
<img src="sample389a.png" />
<img src="sample389b.png" />
</body>
</html>
元画像(sample4.jpg)

出力画像(sample389a.png):上40ピクセル切り落とし

出力画像(sample389b.png):右10ピクセル下20ピクセルを切り落とし

環境
Apache 2.2.8/PHP5.2.5/ImageMagick6.4.0
関連項目
ImageMagickで画像の上下左右を切り落とす (Convertコマンド)
No comments:
Post a Comment