PHP | Imagick steganoImage() Function
Last Updated :
19 Dec, 2019
The ImagickDraw::steganoImage() function is an inbuilt function in PHP which is used to hide a digital watermark within the image. Watermark can be a simple text or image too. Usually, colorful images get distorted with this. The hidden watermark can be recovered later to prove the authenticity of an image. Offset defines the start position within the image to hide the watermark. While recovering the image offset is required.
Syntax:
Imagick ImagickDraw::steganoImage( Imagick $watermark_wand, int $offset )
Parameters: This function accepts two parameters as mentioned above and described below:
- $watermark_wand: It specifies the secret watermark wand.
- $offset: It specifies the secret offset to be used to recover watermark band.
Return Value: This function returns an Imagick object containing the watermarked image.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the ImagickDraw::steganoImage() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$watermark = new Imagick( 'label:This is my secret.' );
$imagick = $imagick ->steganoImage( $watermark , 64);
$imagick ->writeImage( 'output.png' );
$imagick ->setSizeOffset( $watermark ->getImageWidth(),
$watermark ->getImageHeight(), 64);
$imagick ->readImage( 'STEGANO:output.png' );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Program 2:
<?php
$imagick = new Imagick(
$watermark = new Imagick(
$imagick = $imagick ->steganoImage( $watermark , 10);
$imagick ->writeImage( 'output.png' );
$imagick ->setSizeOffset( $watermark ->getImageWidth(),
$watermark ->getImageHeight(), 10);
$imagick ->readImage( 'STEGANO:output.png' );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagick.steganoimage.php
Share your thoughts in the comments
Please Login to comment...