PHP | Imagick __toString() Function Last Updated : 13 Dec, 2019 Comments Improve Suggest changes Like Article Like Report The Imagick::__toString() function is an inbuilt function in PHP which is used to return the image as a string. This function will only return a single image and should not be used for Imagick objects containing multiple images. Syntax: string Imagick::__toString( void ) Parameters:This function doesn’t accepts any parameter. Return Value: This function returns the current image as string. Exceptions: This function throws ImagickException on error. Below programs illustrate the Imagick::__toString() 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'); // Convert it into string $string = $imagick->__toString(); echo $string; ?> Output: This will display a large text which is the string form of image. Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Convert it into string $string = $imagick->__toString(); // Show the output from string header("Content-Type: image/png"); echo $string; ?> Output: Reference: https://www.php.net/manual/en/imagick.tostring.php Comment More infoAdvertise with us Next Article PHP | Imagick __toString() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick setOption() Function The Imagick::setOption() function is an inbuilt function in PHP which is used to set an option. Syntax: bool Imagick::setOption( string $key, string $value ) Parameters: This function accepts two parameters as mentioned above and described below: $key: It specifies the key for the option. $value: It 1 min read PHP | Imagick stripImage() Function The Imagick::stripImage() function is an inbuilt function in PHP which is used to strip all profiles and comments from an image. Syntax: bool Imagick::stripImage( void ) Parameters:This function doesnât accepts any parameter. Return Value: This function returns TRUE on success. Exceptions: This func 1 min read PHP | Imagick setSize() Function The Imagick::setSize() function is an inbuilt function in PHP which is used to set the size associated with an imagick object. Syntax: bool Imagick::setSize( int $columns, int $rows ) Parameters: This function accepts two parameters as mentioned above and described below: $columns: It specifies the 1 min read PHP | Imagick setRegistry() Function The Imagick::setRegistry() function is an inbuilt function in PHP which is used to set the ImageMagick registry entry with named key to value. This function is useful to set the "temporary-path" which is used to control where ImageMagick creates temporary images. Syntax: bool Imagick::setRegistry( 1 min read PHP | Imagick setFormat() Function The Imagick::setFormat() function is an inbuilt function in PHP which is used to set the format of the Imagick object. Syntax: bool Imagick::setFormat( string $format ) Parameters: This function accepts a single parameter $format which holds an string value. Return Value: This function returns TRUE 1 min read Like