HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Imagick::setIteratorIndex

← setImageTicksPerSecond   setOption →
Set the iterator to the position in the image list specified with the index parameter. This method is available if Imagick has been compiled against ImageMagick version 6.2.9 or newer.
Selecting layers from source PSD:

Example

function setIteratorIndex($firstLayer)
{
    $imagick = new \Imagick(realpath("images/LayerTest.psd"));
    $output = new \Imagick();
    $imagick->setIteratorIndex($firstLayer);

    do {
        $output->addImage($imagick->getimage());
    } while ($imagick->nextImage());

    $merged = $output->mergeImageLayers(\Imagick::LAYERMETHOD_MERGE);

    $merged->setImageFormat('png');
    header("Content-Type: image/png");
    echo $merged->getImageBlob();
}