

PHP | Imagick previousImage() Function
source link: https://www.geeksforgeeks.org/php-imagick-previousimage-function/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

- 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
// Create a new imagick object
$imagick
=
new
Imagick(
// Add a image to the imagick object.
$imagick
->addImage(
new
Imagick(
// Get the index
$index1
=
$imagick
->getIteratorIndex();
echo
'Before: '
.
$index1
.
'<br>'
;
// Move the cursor to first image
$imagick
->previousImage();
$imagick
->previousImage();
// Get the index
$index2
=
$imagick
->getIteratorIndex();
echo
'After: '
.
$index2
.
'<br>'
;
?>
Output:
Before: 1 After: 0
Program 2:
<?php
// Create a new imagick object
$imagick
=
new
Imagick(
// Add a image to the imagick object.
$imagick
->addImage(
new
Imagick(
// Move the cursor to first image
$imagick
->previousImage();
$imagick
->previousImage();
// Display the image
header(
"Content-Type: image/png"
);
echo
$imagick
->getImageBlob();
?>
Output:
Reference: https://www.php.net/manual/en/imagick.previousimage.php
Recommend
-
18
How to Crop Images with PHP GD and Imagick Submitted by NanoDano on Mon, 07/27/2015 - 17...
-
11
Freek Van der Herten's blog on PHP, Laravel and JavaScriptScout APM is PHP application performance monitoring designed for developers. With tracing logic that ties issues back to the line of code causing th...
-
10
xml_set_character_data_handler() Function Related Articles ...
-
8
DateTime modify() Function Related Articles ...
-
17
DateTime add() Function Related Articles ...
-
11
xml_parser_create_ns() Function Related Articles ...
-
5
Oh noes, imagick doesn’t work!Permalink That’s what I thought, pretty much, as I...
-
11
Install PHP’s imagick extension on Mac with Brew ...
-
3
如何解决WordPress ”可选的模组imagick未被安装或已被禁用” 解决 WordPress 5.x 站点健康( Site Health )检查提示"可选的模组imagick未被安装或已被禁用"问...
-
5
首页技术宅LinuxRHEL / CentOS 系统安装 ImageMagick , PHP安装Imagick扩展...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK