(PECL imagick 2, PECL imagick 3)
Imagick::getPixelRegionIterator — 取得影像區段的 ImagickPixelIterator
$x
,$y
,$columns
,$rows
取得影像區塊的 ImagickPixelIterator。
x
區域的 x 座標。
y
區域的 y 座標。
columns
區域的寬度。
rows
區域的高度。
回傳影像區塊的 ImagickPixelIterator。
發生錯誤時拋出 ImagickException。
範例 #1 Imagick::getPixelRegionIterator() 範例
迭代影像左上角的像素,將它們改為黑色。
<?php
$im = new Imagick(realpath("./testImage.png"));
$areaIterator = $im->getPixelRegionIterator(0, 0, 10, 10);
foreach ($areaIterator as $rowIterator) {
foreach ($rowIterator as $pixel) {
// 將每個像素塗成黑色
$pixel->setColor("rgba(0, 0, 0, 0)");
}
$areaIterator->syncIterator();
}
$im->writeImage("./output.png");
?>