PHP | Gmagick readimage() Function
Last Updated :
14 Jan, 2020
The Gmagick::readimage() function is an inbuilt function in PHP which is used to read an image from your local folder and add it to the Gmagick object. This is an alternative to read() function.
Syntax:
Gmagick Gmagick::readimage( string $filename )
Parameters: This function accepts a single parameter $filename which holds the name of the file.
Return Value: This function returns a Gmagick object containing the image.
Exceptions: This function throws GmagickException on error.
Below given programs illustrate the Gmagick::readimage() function in PHP:
Used Image:
Program 1 (Reading image from folder):
<?php
$gmagick = new Gmagick();
$gmagick ->readimage( 'geeksforgeeks.png' );
header( 'Content-type: image/png' );
echo $gmagick ;
?>
|
Output:
Program 2 (Editing image after reading):
<?php
$gmagick = new Gmagick();
$gmagick ->readimage( 'geeksforgeeks.png' );
$gmagick ->charcoalimage(0.1, 10);
header( 'Content-type: image/png' );
echo $gmagick ;
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagick.readimage.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...