Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watermarking images on upload

I'm creating a website which requires the images in the site's Gallery to be watermarked. I'd prefer the watermark to get added programatically when the image gets uploaded to the application (via it's web interface) than to manually add it before we do the upload.

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

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

like image 531
Benny Hallett Avatar asked Dec 29 '22 13:12

Benny Hallett


1 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();
like image 141
Martijn Courteaux Avatar answered Jan 10 '23 18:01

Martijn Courteaux