Image watermarks when loading

I am creating a website that requires images in the gallery of the site to be watermarked. I would rather have the watermark added programmatically when the image is uploaded to the application (via its web interface) than manually adding it before uploading.

Are there any simple ways (maybe an image library?) That will allow me to do this?

I am building a site in Grails, so a Groovy or Java solution would be great.

+4
source share
5 answers

This is the code you want, I think ...

BufferedImage source = ...; BufferedImage watermark = ...; Graphics2D g = source.createGraphics(); g.drawImage(watermark, x, y, null); g.dispose(); 
+5
source

I'm not sure if copyright and your process are allowed, but an alternative suggestion is to visualize the watermark when displaying images, rather than changing the image when loading. This will allow you to change the watermark and access the raw image.

+3
source

I am working on a Grails application that does a lot of image manipulation, and we decided to turn to ImageMagick. There is an Image Tools plugin for Grails that may be suitable for a simple watermark, however we need the extra power provided by IM.

Groovy Process additions quite easily invoke IM and then parse err-out threads. If I had time, I would release the IM plugin, but I do not regret it!

amuses

Lee

+1
source

Create a BufferedImage. Draw the uploaded image in BufferedImage, and then draw the watermark on BufferedImage.

+1
source

If you use grails, I think the easiest way to add a watermark or resize an image is to use the burnimage plugin https://grails.org/plugin/burning-image

It is very easy to use and well documented. Find the documentation here: https://code.google.com/p/burningimage/

For the watermark you just have to do, follow

 burningImageService.doWith('path/to/my/file', 'path/to/output/dir') .execute { it.watermark('path/to/watermark', ['top':10, 'bottom': 10]) } 
0
source

All Articles