PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 19, 2022

[FIXED] how to restore the watermark set with Imagick::steganoImage()

 September 19, 2022     image-processing, imagemagick, imagick, php     No comments   

Issue

So I used this Imagemagick library wrapper written in PHP and came to know about this function called steganoImage() which simply says that it will hide a watermark inside the image. But problem is documentation doesn't state how to restore that image back. I checked all the other functions too, didn't find anything. I would like to have an Imagick solution for this.


Solution

The answer provided by Bonzo is correct. An example in PHP's Imagick would look very similar.

$image = new Imagick('rose:');
$watermark = new Imagick('label:Hello World!');

// The decoding process must "know" about the watermarks size, and starting
// pixel offset.
define('STEGANO_OFFSET', 64); // Secret offset
define('STEGANO_WIDTH', $watermark->getImageWidth());
define('STEGANO_HEIGHT', $watermark->getImageHeight());

$stegano = $image->steganoImage($watermark, STEGANO_OFFSET);
$stegano->writeImage('output.png');

output.png

To decode the original watermark, define the width, height, and offset of the hidden image before reading the file.

$decoded = new Imagick();
$decoded->setSizeOffset(STEGANO_WIDTH, STEGANO_HEIGHT, STEGANO_OFFSET);
$decoded->readImage('STEGANO:output.png');
$decoded->writeImage('decoded.png');

decoded.png



Answered By - emcconville
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,207,661

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing