Imagick / imagick

🌈 The Imagick PHP extension 🌈
http://pecl.php.net/imagick
Other
540 stars 136 forks source link

a function for restoring the image back from steganoImage() #307

Open rahgurung opened 4 years ago

rahgurung commented 4 years ago

steganoImage() hides a water mark in a image. I need a function to get the water mark back, maybe it can accept offset as parameter.

Danack commented 4 years ago

Looking the example at: https://github.com/ImageMagick/ImageMagick/blob/306762972e7c7dd2158bf00d39ed2ebd87c49e65/PerlMagick/demo/steganography.pl

It seems the following code should work, but doesn't.

# Hide an image within an image
$watermark = new Imagick();
$watermark->readImage('smile.gif');
$width = $watermark->getImageWidth();
$height = $watermark->getImageHeight();

# Hide image in image.
$image = new Imagick();
$image->readImage('model.gif');
$image->steganoImage($watermark, 91);
$image->writeimage('output.png');

# Extract image from image.
$stegano = new Imagick();

$stegano->setSizeOffset($width, $height, 91);
$stegano->readImage('stegano:output.png');
$stegano->writeImage('recovered.gif');

echo "fin.\n";

It runs, but the recovered image is random garbage.

rahgurung commented 4 years ago

I wrote an article here.

Danack commented 4 years ago

Thanks....that works. I wonder why the example I gave doesn't...