Thursday, October 23, 2025
HomeLanguagesPHP | Imagick encipherImage() Function

PHP | Imagick encipherImage() Function

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 = "neveropen";
  
// Calling the function
$image->encipherImage($passphrase);
  
// $image is now enciphered with string
// "neveropen"
// $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

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS