Watermarking photos with ImageMagick, Vapor 3 and Swift on macOS and Linux

Watermarking photos with ImageMagick, Vapor 3 and Swift on macOS and Linux

7 years ago
Anonymous $L9wC17otzH

https://medium.com/@mike.mikina/watermarking-photos-with-imagemagick-vapor-3-and-swift-on-macos-and-linux-ae5a41f27e8b

Back in the days (you remember web 2.0? ?) I used to do a lot of programming around photos. Resizing, scaling, rotating and converting between formats. Recently, I had to create a web service that generates watermarked images using Vapor. It turns out that there are not very many libraries for image manipulation yet, so this simple task became an interesting problem to research.

There are two major image manipulation libraries: GD and ImageMagick. ImageMagick is a bit of an advanced library so I decided to go with this one first. There is an interesting Swift wrapper for ImageMagick called MagickWand. Unfortunately, it doesn’t support text manipulation at all so I had to dig deeper. I couldn’t find anything useful so I thought “why not to just use some ImageMagick C functions in Swift?” It turns out that this is quite easy to do!