PHP 8.3.4 Released!

Imagick::getPixelRegionIterator

(PECL imagick 2, PECL imagick 3)

Imagick::getPixelRegionIterator画像セクションの ImagickPixelIterator を取得する

説明

public Imagick::getPixelRegionIterator(
    int $x,
    int $y,
    int $columns,
    int $rows
): ImagickPixelIterator

画像セクションの 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");
?>

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top