上传图片时加水印
我正在创建一个网站,需要为网站图库中的图像添加水印。我更喜欢在图像上传到应用程序(通过其 Web 界面)时以编程方式添加水印,而不是在上传之前手动添加水印。
有没有任何简单的方法(也许是图像库?)可以让我做到这一点?
我正在使用 Grails 构建站点,因此 Groovy 或 Java 解决方案会很棒。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想这就是你想要的代码......
This is the code you want I think...
我不确定版权和您的流程是否允许,但另一种建议是在显示图像时呈现水印,而不是在上传时更改图像。这将允许您更改水印并访问原始图像。
I'm not sure if copyright and your process allows but an alternative suggestion is to render the watermark when the images are displayed rather than altering the image on upload. This would allow you to change the watermark and have access to the raw image.
我一直在开发一个 Grails 应用程序,该应用程序可以进行大量图像处理,我们选择调用 ImageMagick。 Grails 有一个图像工具插件,可能适合简单的水印,但是我们需要 IM 提供的额外功能。
Groovy 的 Process 附加功能使得调用 IM 然后解析 err/out 流变得非常容易。如果我有时间我会发布一个 IM 插件,但我不后悔!
干杯
李
I've been working on an Grails application that does a lot of image manipulation and we chose to call out to ImageMagick. There is an Image Tools plugin for Grails which might be suitable for simple watermarking, however we needed the extra power that IM provides.
Groovy's Process additions make it pretty easy to call out to IM and then parse the err/out streams. If I had time I'd release an IM plugin, but I don't sorry!
cheers
Lee
创建一个缓冲图像。将上传的图片绘制到BufferedImage中,然后将水印绘制到BufferedImage中。
Create a BufferedImage. Draw the uploaded image to the BufferedImage and then draw the watermark to the BufferedImage.
如果您使用grails,我认为添加水印或调整图像大小以使用burningimage插件的最简单方法
https://grails.org/plugin/burning-image
它非常易于使用且有详细记录。在这里找到文档:
https://code.google.com/p/burningimage/
前往您简单的水印必须执行以下操作
If you are using grails, I think the easiest way to add a watermark or resize the image to use the burningimage plugin
https://grails.org/plugin/burning-image
Its very easy to use and well documented. Find the documentation here:
https://code.google.com/p/burningimage/
To the the watermark you simple have to do the following