Adding an invisible image watermark in C#?

梦想的初衷 提交于 2019-11-30 09:29:29

there is a port of image magick library to c# , and it can easily perform that operation for you...

Storing "invisible" data in pictures is known as "steganography". A Google-search for "steganography .net" yields this article as its top hit - might prove useful.

What is the purpose of this? Is it to enable you to identify JPGs that have been taken from your site?

Response in comments: "Yes, I want to protect my pictures by using some robust and invisible watermark. Semi-visible site logo is not an option... "

The problem is precisely the one described in discussion of Steganography above, to do with the robustness of the image.

Any watermark like the one you describe can be used to identify a direct copy of the whole image, but with a jpg it seems to me that if it is even opened and saved again in an editor there is a chance of a change in compression affecting the watermark. Also if someone was to steal your image and do something more extensive with it- tinker with the colour balance, crop it a little and so on it seems unlikely that any invisible watermarking would be robust enough to survive and stay recogniseable.

Unfortunately I don't have a solution here, but the problem itself is far from trivial. It may be worth looking for other approaches to it, that you can perhaps use in parallel with watermarking ( custom metadata perhaps? preventing images being easily saved? ) to make it harder for your images to be stolen or to make them less valuable if they are...

This article on devx.com contains a library (Stego) with source code you could use:

Keeping Secrets Secret: Steganography with .NET

After implementing that API, it's trivial to hide a message inside a .bmp file:

   ICoverFile cover = new BMPCoverFile("cover.bmp");
   cover.CreateStegoFile("stego.bmp","Hello","MyPwd");   

Likewise, you can extract the message just as easily:

   IStegoFile stego = new 
      BMPStegoFile("stego.bmp","MyPwd");
   Console.WriteLine(stego.HiddenMessage);

UPDATE: Oh, sorry. Matt linked to the same article... didn't see that while writing this answer.

If it is a important application that you are working on, why not trying a paid service?

Digimarc and Signumtech can give you that kind of support using their SDK.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!