Skip to content
Related Articles

Related Articles

PHP | Imagick current() Function
  • Last Updated : 25 Jul, 2019
GeeksforGeeks - Summer Carnival Banner

The Imagick::current() function is an inbuilt function in PHP which is used to return the reference of current Imagick object. This function does not create any copy but returns the same instance of Imagick.

Syntax:

Imagick Imagick::current( void )

Parameters: This function does not accepts any parameters.

Return Value: It returns the instance of Imagick object.

Program 1: This program is regarding the simple functioning of the current() method. It will create a variable with a new name pointing to the same instance and show the content of the old one with the help of the new.






<?php
  
// Create new Imagick object
$im = new Imagick(
  
// Use Imagick::current() function and
// initialized with Image 
$im1 = $im->current();
  
// Imagick instance returned in a new variable $im1
header("Content-type: image/png");
  
// Display image as output
echo $im1;
  
?>

Output:
Output

Program 2: It performs the blur operation on the image using the 2nd variable and the change will be reflected on the first one as both of them are pointing to the same instance.




<?php
   
// Create new Imagick object
$im = new Imagick(
   
// Use Imagick::current() function
$im1 = $im->current();
   
// Use Imagick::blurImage() function to blur the image
$im1->blurImage(5, 3);
  
header("Content-type: image/png");
   
// Display the image as
echo $im;
   
?>

Output:
Output 2

Reference: https://www.php.net/manual/en/imagick.current.php

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :