(PECL imagick 2, PECL imagick 3)
ImagickPixelIterator::resetIterator — 重設像素迭代器
此函式目前沒有文件;僅提供其參數列表。
重設像素迭代器。將其與 ImagickPixelIterator::getNextIteratorRow() 搭配使用,以迭代像素容器中的所有像素。
成功時返回 true
。
範例 #1 ImagickPixelIterator::resetIterator()
<?php
function resetIterator($imagePath) {
$imagick = new \Imagick(realpath($imagePath));
$imageIterator = $imagick->getPixelIterator();
/* 迴圈處理像素列 */
foreach ($imageIterator as $pixels) {
/* 迴圈處理列中的像素(欄) */
foreach ($pixels as $column => $pixel) {
/** @var $pixel \ImagickPixel */
if ($column % 2) {
/* 將每兩個像素設置為 25% 紅色 */
$pixel->setColorValue(\Imagick::COLOR_RED, 64);
}
}
/* 同步迭代器,每次迭代都必須執行 */
$imageIterator->syncIterator();
}
$imageIterator->resetiterator();
/* 迴圈處理像素列 */
foreach ($imageIterator as $pixels) {
/* 迴圈處理列中的像素(欄) */
foreach ($pixels as $column => $pixel) {
/** @var $pixel \ImagickPixel */
if ($column % 3) {
$pixel->setColorValue(\Imagick::COLOR_BLUE, 64); /* 將每三個像素設置為略帶藍色 */
//$pixel->setColor("rgba(0, 0, 128, 0)"); /* 將每三個像素塗成黑色 */
}
}
$imageIterator->syncIterator(); /* 同步迭代器,每次迭代都必須執行 */
}
$imageIterator->clear();
header("Content-Type: image/jpg");
echo $imagick;
}
?>