Change language

PHP Imagick setProgressMonitor () function

Syntax:
bool Imagick::setProgressMonitor (callable $callback)
Parameters:This function takes one parameter $callback,which contains a callback function.Return value:This function returns TRUE on success.Exceptions:This function throws an ImagickException on error.The following programs illustrate the Imagick::setProgressMonitor() function in PHP:Program 1:  
// Create a new Imagick object $imagick = new Imagick();  
// Create image in Imagick $imagick -> newImage (640, 480, "blue" ); $status = ’ Not canceled’ ; $text =
;  
// callback function $callback = function ( $offset , $span ) use (& amp; $status , $text ) { $status = "Callback is called " . $text ; return false; };  
// Install progress monitor $imagick -> setProgressMonitor ( $callback ); try { // $x and $y are not defined, so call // callback is expected here $imagick -> charcoalImage ( $x , $y ); echo "Callback function wasn’ t called. " ; } catch (Exception $e ) { echo $status ; }
?>
Output:
Callback is called
Program 2:  
// Create a new Imagick object $imagick = new Imagick() ;  
// Create image in Imagick $imagick -> newImage (600, 400, "white" ); $status = ’ Not canceled’ ; $text =
;  
// callback function $callback = function ( $offset , $span ) use (& amp; $status , $text ) { $status = "Callback is called " . $text ; return true; };  
// Install progress monitor $imagick -> setProgressMonitor ( $callback ); try { // $x and $y are defined, thus calling // callback is expected here $x = 20; $y = 5; $imagick -> charcoalImage ( $x , $y ); echo "Callback function wasn’ t called. " ; } catch (Exception $e ) { echo $status ; }  
?>
Output:
Callback function wasn’t called.
Link: https://www.php.net/manual/en/imagick.setprogressmonitor.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method