1

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!

fvm
  • 143
  • 2
  • 10
  • A couple of things to remember with -stegeno is if the image is cropped or resized you will not be able to retrieve the image. From memory jpg can be a problem as when it is saved it is compressed again and that may be why you are getting garbage. To test you could try with a ping output and see if that is the problem. You could look at -comment https://www.imagemagick.org/script/command-line-options.php#comment although I have not tried it and I am not sure how to read it back easily. – Bonzo Dec 16 '16 at 10:45
  • How about [modifying the JPEG encoding process](https://stackoverflow.com/questions/35396977/lsb-dct-based-image-steganography/35398127#35398127) with a [Golang library](https://golang.org/pkg/image/jpeg/)? – Reti43 Dec 16 '16 at 12:43

0 Answers0