PHP | Imagick getImageSignature() Function
Last Updated :
26 Aug, 2019
The Imagick::getImageSignature() function is an inbuilt function in PHP which is used to generate an SHA-256 message digest for an image.
Syntax:
string Imagick::getImageSignature( void )
Parameters: This function does not accept any parameter.
Return Value: This function returns a string of SHA-256 hash of the file.
Below programs illustrate the Imagick::getImageSignature() function in PHP:
Program 1:
Original Image:
<?php
$image = new Imagick(
$pixels = $image ->getImageSignature();
print ( $pixels );
?>
|
Output:
f64054f5bcb4cfb82c6126eff6d3d4e6be7d0e72d5620033442cecb4b9feabbd
Program 2:
Original Image:
<?php
$string = "Computer Science portal for Geeks!" ;
$im = new Imagick();
$draw = new ImagickDraw();
$draw ->setFillColor( new ImagickPixel( 'green' ));
$draw ->setFontSize(50);
$metrix = $im ->queryFontMetrics( $draw , $string );
$draw ->annotation(0, 40, $string );
$im ->newImage( $metrix [ 'textWidth' ], $metrix [ 'textHeight' ],
new ImagickPixel( 'white' ));
$im ->drawImage( $draw );
$im ->setImageFormat( 'jpeg' );
$pixels = $im ->getImageSignature();
print ( $pixels );
?>
|
Output:
ed79035e13153385c344d19586e98941dd336165a3ca486200097c0bd2f4188c
Reference: http://php.net/manual/en/imagick.getimagesignature.php
Share your thoughts in the comments
Please Login to comment...