The progress monitor allows you to be notified of progress during image processing. It also allows you to abort the image processing, for example if it's taking too long, or it is detected the image is no longer needed.

In the example below, the progress is monitored and then the image operation is cancelled when the progress passed 20%.

Please note the offset and span values are approximate and do not reflect an accurate measure of the image progress.
Progress: 0 / 400 
Progress: 5 / 400
Progress: 10 / 400
Progress: 15 / 400
Progress: 20 / 400
Progress: 25 / 400
Progress: 30 / 400
Progress: 35 / 400
Progress: 40 / 400
Progress: 45 / 400
Progress: 50 / 400
Progress: 55 / 400
Progress: 60 / 400
Progress: 65 / 400
Progress: 70 / 400
Progress: 75 / 400
Progress: 80 / 400
Image processing was aborted: Processing reached 20%
The progress monitor allows you to be notified of progress during image processing. It also allows you to abort the image processing, for example if it's taking too long, or it is detected the image is no longer needed.

In the example below, the progress is monitored and then the image operation is cancelled when the progress passed 20%.

Please note the offset and span values are approximate and do not reflect an accurate measure of the image progress.
        $abortReason = null;

        try {
            $imagick = new \Imagick(realpath($this->control->getImagePath()));
            $startTime = time();

            $callback = function ($offset, $span) use ($startTime, &$abortReason) {
                if (((100 * $offset) / $span) > 20) {
                    $abortReason = "Processing reached 20%";
                    return false;
                }

                $nowTime = time();

                if ($nowTime - $startTime > 5) {
                    $abortReason = "Image processing took more than 5 seconds";
                    return false;
                }
                if (($offset % 5) == 0) {
                    echo "Progress: $offset / $span 
"; } return true; }; $imagick->setProgressMonitor($callback); $imagick->waveImage(2, 15); echo "Data len is: " . strlen($imagick->getImageBlob()); } catch (\ImagickException $e) { if ($abortReason != null) { echo "Image processing was aborted: " . $abortReason . "
"; } else { echo "ImagickException caught: " . $e->getMessage() . " Exception type is " . get_class($e); } }