I'm trying to embed a sort of digital signature, either in the form of text or a composite image into an existing image (JPEG at present, possibly others in the futere), such that the origin of the original image can be determined at a later time based on the content of the message.
Now, the main requirement of this is that it has to be done using an existing Golang library or through ImageMagick, which itself is well supported in Golang.
Thus far, the options I've considered are:
- Through metadata, e.g. XMP, IPTC, EXIF, etc.
- Through steganography
Unfortunately, none of these methods seem well supported in Go or ImageMagick. For example, I've come across some libraries which allow you to read metadata, but not write them. Others rely on the use of exiftool by executing a command in the shell, which also isn't a viable approach. And with regard to steganography, I've seen some libraries which allow you to embed messages, but only in PNG images or ones which are lacking in other regards.
In the end the only viable approach I've got left is to use ImageMagick, but that also doesn't seem to work, or, I'm overlooking something. I've tried it using the command line tools, but the only result was a garbage image. What I did was (following the documentation):
- Given an existing JPEG
Create a new watermark image:
convert -gravity center -size 50x40 label:"SECRET" message.gif
Composite the image with the existing image, making sure to note the offset and dimensions, as described:
composite message.gif input.jpg -stegano +0+0 output.png
This yields a new image containing the embedded data, which I can verify through a difference metric. Then, taking this new image, again following the documenation:
convert -size 50x40+0+0 stegano:output.png message_recovered.gif
- And hey presto, garbage...
Now, given all the above, my questions are:
- Are there native Golang libraries out there which allow me to either use metadata or steganography for this purpose?
- Are there perhaps other avenues to doing this which are more viable?
- What am I missing in the ImageMagick example I followed?
Thanks!