PHP | Imagick setImageIndex() Function Last Updated : 28 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Imagick::setImageIndex() function is an inbuilt function in PHP which is used to set the iterator position. Syntax: bool Imagick::setImageIndex( int $index ) Parameters: This function accepts a single parameter $index which holds the index. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the Imagick::setImageIndex() function in PHP: Program 1: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Add two more images in the same imagick object $imagick->addImage( new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png')); $imagick->addImage( new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png')); // Currently Cursor is at 2 // Set the Index to 0 $imagick->setImageIndex(0); // Get the Index $index = $imagick->getImageIndex(); echo $index; ?> Output: 0 Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Add two more images in the same imagick object $imagick->addImage( new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/20190918234528/colorize1.png')); // Currently Cursor is at 1 // Set the Index to 0 $imagick->setImageIndex(0); // getImageBlob() should show last added image but // cursor is set to 0 thus it shows first image header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagick.setimageindex.php Comment More infoAdvertise with us Next Article PHP | Imagick setImageDepth() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick setImageScene() Function The Imagick::setImageScene() function is an inbuilt function in PHP which is used to set the image scene. The value of scene contains an integer value. Syntax: bool Imagick::setImageScene( int $scene ) Parameters: This function accepts a single parameter $scene which holds the scene. Return Value: T 1 min read PHP | Imagick setImageDepth() Function The Imagick::setImageDepth() function is an inbuilt function in PHP which is used to set the depth of a particular image.Syntax:Â Â bool Imagick::setImageDepth( $depth ) Parameters: This function accepts a single parameter $depth which is an integer value and used to set the depth of image.Return Val 2 min read PHP | Imagick setImageFilename() Function The Imagick::setImageFilename() function is an inbuilt function in PHP which is used to set the filename of a particular image. Syntax: bool Imagick::setImageFilename( string $filename ) Parameters: This function accepts single parameter $filename which holds a string that represent the filename. Re 1 min read PHP | Imagick setImagePage() Function The Imagick::setImagePage() function is an inbuilt function in PHP which is used to set the image page geometry. Syntax: bool Imagick::setImagePage(int $width, int $height, int $x, int $y ) Parameters: This function accepts four parameters as mentioned above and described below: $width: It specifies 1 min read PHP | Imagick setImageType() Function The Imagick::setImageType() function is an inbuilt function in PHP which is used to set the image type.Syntax:Â Â bool Imagick::setImageType( int $image_type ) Parameters: This function accepts a single parameter $image_type which contains an integer value corresponding to one of IMGTYPE constants. W 1 min read PHP | Imagick setImageExtent() Function The Imagick::setImageExtent() function is an inbuilt function in PHP which is used to set the image size. This function doesn't scales the image but crops the unwanted parts. Syntax: bool Imagick::setImageExtent( int $columns, int $rows ) Parameters: This function accepts two parameters as mentioned 1 min read Like