PHP | Imagick previousImage() Function
Last Updated :
04 Dec, 2019
The Imagick::previousImage() function is an inbuilt function in PHP which is used to move to the previous image within the Imagick instance. An Imagick instance may consist of a list of images within it and Imagick previousImage() moves the pointer/cursor to the previous image in the image list within an Imagick instance.
Syntax:
bool Imagick::previousImage( void )
Parameters: This function doesn’t accepts any parameter.
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the Imagick::previousImage() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$imagick ->addImage( new Imagick(
$index1 = $imagick ->getIteratorIndex();
echo 'Before: ' . $index1 . '<br>' ;
$imagick ->previousImage();
$imagick ->previousImage();
$index2 = $imagick ->getIteratorIndex();
echo 'After: ' . $index2 . '<br>' ;
?>
|
Output:
Before: 1
After: 0
Program 2:
<?php
$imagick = new Imagick(
$imagick ->addImage( new Imagick(
$imagick ->previousImage();
$imagick ->previousImage();
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.previousimage.php
Share your thoughts in the comments
Please Login to comment...