<?php
/* 建立新的 Imagick 物件 */
$im = new Imagick();
/* 建立紅色、綠色和藍色影像 */
$im->newImage(100, 50, "red");
$im->newImage(100, 50, "green");
$im->newImage(100, 50, "blue");
/* 將影像附加到一個 */
$im->resetIterator();
$combined = $im->appendImages(true);
/* 儲存用於比較的中間影像 */
$combined->writeImage("floodfillpaint_intermediate.png");
/* 要繪製的目標像素 */
$x = 1;
$y = 1;
/* 取得我們要繪製的顏色 */
$target = $combined->getImagePixelColor($x, $y);
/* 將位置 1,1 中的像素繪製為黑色,並繪製所有符合目標顏色的相鄰像素 */
$combined->floodfillPaintImage("black", 1, $target, $x, $y, false);
/* 儲存結果 */
$combined->writeImage("floodfillpaint_result.png");
?>