There are plenty of tutorials about overlaying watermarks on images in PHP (most of them using GD, not imagemagik, fwiw) online. Be forewarned that that's a really intensive process for PHP to be doing, so you'd definitely want to cache any changed images for a very long time.
I'm not sure what you'd roll into Habari to go with it, that really depends on what you're going for. Adding a new plugin that uses shorttags to insert an image in the post with a given watermark would probably be the easiest. You could probably also hook into the Habari Silo and add a new "insert with watermark" option.