User name as Watermark
Asked Answered
B

5

6

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.

Bolide answered 14/11, 2010 at 2:1 Comment(0)
C
11

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.

Contrasty answered 14/11, 2010 at 2:10 Comment(2)
Thanks for the reply. As I mentioned before, I already know how to add watermarks dynamically to an image. I want to take it a step further and dynamically create a PNG with the transparency and shadow effects as you see here above for each registered user.Bolide
Sorry, didn't see what you meant the first time. Thanks a lot, i'll give this a shot!Bolide
S
2

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.

Stuffing answered 14/11, 2010 at 2:12 Comment(1)
Thank you for your reply. As I mentioned before I already know how to this. I need now to dynamically create the "watermark" PNG file for each user with PHP. :)Bolide
I
0

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.

Indocile answered 14/11, 2010 at 3:2 Comment(1)
Thanks for the alternatives. I'll take a look at them.Bolide
F
0

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.

Fullrigged answered 14/11, 2010 at 4:54 Comment(1)
That's the whole idea. I don't know how to generate a PNG file with transparency and shadow effect. The image is created once when the user is registered (they can't change their user name)Bolide
R
0

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
Runaway answered 3/7, 2022 at 16:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.