bear0053 has asked for the wisdom of the Perl Monks concerning the following question:

from what i understand this method will hide one image inside another image? Thats great but how can i run an image through a function and verify if it contains the hidden watermark? Is there any way to modify an image by hiding some sort of data or identification message in it that I would be able to check regardless of cropping and other modifications an individual may do to it? Below is the code i use to insert the stegano, which seems to work fine. The image prints out and looks unchanged by the addition of the hidden watermark which i expected but i have no way now of verifying that it is in there. Thanks for the help.
my $background=Image::Magick->new(magick=>"gif"); $background->BlobToImage($binary_data); my $foreground=Image::Magick->new; $foreground->Read($watermark_file); $background->Stegano(image=>$foreground, offset=> 1); $background->Write("gif-"); $binary_data = $background->ImageToBlob(); print "content-type: image/gif\n\n"; print $binary_data;

Replies are listed 'Best First'.
Re: Image::Magick stegano question
by blokhead (Monsignor) on Jun 24, 2004 at 19:33 UTC
    i have no way now of verifying that it is in there.
    You can only retrieve the hidden image if you know that it's there, and know its size and offset (that's the point of steganography). There's no way to "check" in general whether something is hidden if you don't know precisely how to retreive it.
    -stegano
    hide watermark within an image. Use an offset to start the image hiding some number of pixels from the beginning of the image. Note this offset and the image size. You will need this information to recover the steganographic image (e.g. display -size 320x256+35 stegano:image.png).

    http://docent.hogent.be/~pvt340/multimed/webpages/combine.html

    This probably translates into PerlMagick like this:

    my $img = Image::Magick->new; $img->Set(size=>'100x100+5'); $img->ReadImage('stegano:result.gif');
    If this produces an image that "makes sense", then you know the watermark was there. Otherwise, you'll probably get random pixels.

    blokhead

      yes that is exactly what i am looking for. I insert the hidden watermark myself as shown in the code in my original post. The problem is I do not know the syntax needed to read it back out and check. I tried to use your code suggestion but that only prints me out the original base image which doesn't verify anything. I can't seem to uncover the syntac needed to extract the stegano inserted.
      my $background=Image::Magick->new(magick=>"gif"); $background->BlobToImage($bin_data); $background->Set(size=>"100x100+1"); #size and offset of watermark + inserted $background->Read('stegano:result.gif'); $background->Write("gif-"); $bin_data = $background->ImageToBlob(); print "content-type: image/gif\n\n"; print $bin_data;
      this only prints the full sized original image. not the watermark and it doesn't even display an image of the correct size. It shuold be 100x100 but instead is the regular full size of 640x460? thanks
        $background->Read('stegano:result.gif');
        tries to read from result.gif, but you're also trying to read from a blob at the same time.

        As far as I can tell, the image needs to read from a file for this to work. I tried setting the magick to "stegano" and the correct size and offset before reading from a blob and didn't get any luck. Saving to a file and doing Read("stegano:filename") worked fine for me with the code from my first reply.

        Maybe someone with more PerlMagick experience can help out.. I only found one example of writing and reading a watermark using PerlMagick, but not from a blob.

        blokhead