PHP | Imagick __toString() Function
Last Updated :
13 Dec, 2019
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
$imagick = new Imagick(
$string = $imagick ->__toString();
echo $string ;
?>
|
Output:
This will display a large text which is the string form of image.
Program 2:
<?php
$imagick = new Imagick(
$string = $imagick ->__toString();
header( "Content-Type: image/png" );
echo $string ;
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.tostring.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...