用户名作为水印

发布于 2024-10-01 19:37:05 字数 416 浏览 6 评论 0原文

好吧,我搜索了互联网和 stackoverflow,但我似乎找不到我的问题的答案。

我需要动态地为用户上传的图像添加水印,但我不想只在图像上应用文本。我需要一个像这样的真实水印: alt text

我实现这种效果的唯一方法是使用 Photoshop,添加阴影并将填充减少到 0%。但如果我的网站有 200 个上传图像的用户访问,我就无法为他们每个人制作一个带有他们的用户名的新 PNG 文件。这就是为什么我正在寻找这个问题的动态解决方案。

我已经找到了如何将 png 文件作为水印添加到图像中的课程,但就像我之前说过的,如果我的网站被很多用户访问,这将不起作用。

我希望有人知道如何解决这个问题并动态地在图像上获得相同的效果。

非常感谢。

Ok, I searched the internet and stackoverflow but I just can't seem to find an answer for my problem.

I need to watermark images uploaded by users dynamically, but I don't want just text applied on an image. I need a real watermark like this:
alt text

The only way I can achieve this effect is by using Photoshop, adding shadow and decreasing the filling to 0%. But if my site is visited by 200 users who upload their images, I just can't make for everyone of them a new PNG file with their user name. That's why I'm looking for a dynamic solution for this problem.

I already found classes how to add a png file as a watermark to images, but like I said before this won't work if my site is visited by a lot of users.

I hope someone knows a way how to solve this and get the same effect on images dynamically.

Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

¢蛋碎的人ぎ生 2024-10-08 19:37:05

ImageMagick图像处理库的文档包含这样一个透明水印示例。即使您想使用 GD 而不是 ImageMagick,它也可能会让您了解如何操作。

The documentation of the ImageMagick image processing library includes such a transparent watermark example. Even if you would like to use GD instead of ImageMagick, it might give you an idea of how to do it.

江南烟雨〆相思醉 2024-10-08 19:37:05

您可以使用 imageMagick 通过 PHP 来完成此操作。谷歌搜索一下 PHP imagemagick 水印,这个线程可能会帮助一些人:
http://www.imagemagick.org/discourse-server /viewtopic.php?f=1&t=17067

您本质上是想为水印制作一个 PNG 文件。 PNG 将允许 alpha 透明度,您可以获得投影效果等。

然后,这将应用于您的 JPG 图像,最终的带水印的 JPG 图像将在其上添加您的 PNG。

应该有效。

You can use imageMagick to do this with PHP. Do some Googling for PHP imagemagick watermarking, this thread may help some:
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=17067

You essentially want to make a PNG file of your watermark. The PNG will allow for alpha transparency and you can get your drop shadow effect etc.

This will then be applied to your JPG image, and a final watermarked JPG image will be made with your PNG added on top of it.

Should work.

飘逸的'云 2024-10-08 19:37:05

这里的其他答案都是很好的答案,但我想提出一个替代方案。

您可以为动态构建要执行的 GIMP,这为您提供了大量的灵活性。对于简单的水印来说,这有点过分了,但如果您需要进行一些更复杂的图像处理,它绝对是一个选择。 CoolText.com 就是执行此操作的网站示例。

同样的方法也应该适用于 Photoshop。事实上,您可能可以使用 PHP 实例化 Photoshop 的COM 接口

再次强调,我不建议将其用于基本水印...只是如果您需要比 ImageMagick/GD 提供的功能更多的功能。

The other answers here are great answers, but I wanted to throw in an alternative.

You can dynamically build scripts for the GIMP to execute, which gives you tons of flexibility. This is way overkill for a simple watermark, but if you needed to do some more complex image processing, it is definitely an option. CoolText.com is an example of a website that does this.

The same approach should work in Photoshop as well. In fact, you could probably instantiate Photoshop's COM interface with PHP.

Again, I don't recommend this for basic watermarking... just if you need more functions than what is provided with ImageMagick/GD.

时光与爱终年不遇 2024-10-08 19:37:05

对于其他答案,我将补充一点,您不应该即时生成图像。如果水印是按用户名设置的,请在用户注册您的网站(或更改用户名)时生成一次水印文件,然后使用该文件作为上传图像的覆盖层。这将节省大量的CPU时间。

To the other answers I will add that you should not be generating the image on the fly. If the watermark is by username, generate the watermark file once when the user registers for your site (or changes their username), then use that file as an overlay for the uploaded images. This will save a lot of CPU time.

我要还你自由 2024-10-08 19:37:05

使用以下命令:

magick convert input.jpg ( -size 960x640 xc:none -font microsoft-new-tai-lue -pointsize 90 -fill black -annotate +120+370 Watermark -blur 0x4 -fill none  -annotate +125+365 Watermark ) -flatten output.png

Use the following command:

magick convert input.jpg ( -size 960x640 xc:none -font microsoft-new-tai-lue -pointsize 90 -fill black -annotate +120+370 Watermark -blur 0x4 -fill none  -annotate +125+365 Watermark ) -flatten output.png

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文