PHP | Imagick setImageIterations() Function
Last Updated :
21 Nov, 2019
The Imagick::setImageIterations() function is an inbuilt function in PHP which is used to set the image iterations. The iteration here actually means for how many times the frames should repeat themselves.
Syntax:
bool Imagick::setImageIterations( int $iterations )
Parameters: This function accepts a single parameter $iterations which holds the number of iterations. Set to 0 to make it loop forever.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::setImageIterations() function in PHP:
Program 1:
<?php
$imagickAnimation = new Imagick(
foreach ( $imagickAnimation as $frame ) {
$frame ->setImageDelay(300);
}
$imagickAnimation = $imagickAnimation ->coalesceImages();
$imagickAnimation ->setImageIterations(1);
header( "Content-Type: image/gif" );
echo $imagickAnimation ->getImagesBlob();
?>
|
Output:
Program 2:
<?php
$imagickAnimation = new Imagick(
$imagickAnimation = $imagickAnimation ->coalesceImages();
$imagickAnimation ->setImageIterations(0);
header( "Content-Type: image/gif" );
echo $imagickAnimation ->getImagesBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.setimageiterations.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...