Open In App

PHP | Imagick encipherImage() Function

Last Updated : 23 Jul, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The Imagick::encipherImage() function is an inbuilt function in PHP which is used to convert plain pixels image into enciphered pixels. This function simply converts the pixels to enciphered pixels and then the image can be readable only if decipher the image with the same string with which it was enciphered.

Syntax:

bool Imagick::encipherImage( $passphrase )

Parameters: This function accepts single parameter $passphrase which holds the passphrase value.

Return Value: It returns True on success or False on failure.

Below program illustrates the Imagick::encipherImage() function in PHP:

Program:




<?php
  
// Creating new Imagick object
$image = new Imagick(
  
// Creating the passphrase
$passphrase = "GeeksforGeeks";
  
// Calling the function
$image->encipherImage($passphrase);
  
// $image is now enciphered with string
// "GeeksforGeeks"
// $image can only be made readable by 
// decipherImage() method
// with the same passphrase as parameter
  
header("Content-Type: image/jpg"); 
  
// Showing the deciphered image which is
// same as our sampleimage.jpeg
echo $image;
  
?>


Output:
Deciphered image if the passphrase is incorrect :

Reference: https://php.net/manual/en/imagick.encipherimage.php


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads