Semi transparent text watermark w shadow

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Tacakas
Posts: 3
Joined: 2011-06-21T13:27:21-07:00
Authentication code: 8675308

Semi transparent text watermark w shadow

Post by Tacakas »

Hello.

I'm trying use this, but without success

Code: Select all

convert -channel rgba -pointsize 30 -strokewidth 2 "in.jpg" ^( -background transparent -stroke #000b -fill #000a label:"mark" -blur 3x3 -stroke none  -fill #ffff label:"mark" ^) -compose dissolve -define compose:args=50 -composite -quality 100 "out.jpg"
flatten works well, but I need a semi transparent text

Code: Select all

convert -channel rgba -pointsize 30 -strokewidth 2 "in.jpg" ^( -background transparent -stroke #000b -fill #000a label:"mark" -blur 3x3 -stroke none  -fill #ffff label:"mark" ^) -flatten -quality 100 "out.jpg"
Version: ImageMagick 6.6.8-9 2011-03-25 Q16
OS: Win
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Semi transparent text watermark w shadow

Post by fmw42 »

In windows, you do not escape the parenthesis.

see http://www.imagemagick.org/Usage/windows/
Tacakas
Posts: 3
Joined: 2011-06-21T13:27:21-07:00
Authentication code: 8675308

Re: Semi transparent text watermark w shadow

Post by Tacakas »

Thanks, but it's not what I asked about.

Code: Select all

convert -channel rgba -pointsize 100 -strokewidth 2 logo: ( -background transparent -stroke #000b -fill #000a label:"mark" -blur 3x3 -stroke none  -fill #ffff label:"mark" ) -compose dissolve -define compose:args=50 -composite -quality 100 out.jpg
What I want:
Image

What I get:
Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Semi transparent text watermark w shadow

Post by anthony »

NOTE the fill color "#000a" is a semi-transparent black! You then use a fill color of "#ffff" which is fully-transparent white.
You can NOT draw transparency!!! It is like painting a wall with water -- does nothing what so ever!

Also -blur 3x3 should probably be 0x3!

In your 'good' example you have a 'white' color (dissolve) for the watermark fill, but that is not what you seem to want.

My suggestion to you is... FORGET drawing with transparencies! Just draw the transparency in greyscale (no color), typically so that black = fully transparent (the background and final text fill) and white is transparent (the shadow). Yes that seems inverted, but go with it. Also set the 'dissolve' transparency now by making the whole image darker, bu the disolve amount, that way you can just overlay it like a normal image!

When you have the transparency you want, then use -alpha shape to convert the greyscale image to a colored transparency shape (black or grey) or merge it with a separate drawn colors image.
http://www.imagemagick.org/Usage/masking/#alpha_shape

As an example see compound fonts, using a mask image to generate fonts...
http://www.imagemagick.org/Usage/fonts/#mask
It creates separate color and mask images which are merged to form the final font image. It may not be a blurred image but it is the same technqiue.

When you have your watermark, save it, so you can then overlay it on multiple images. Unless the text is different for each image being watermarked. Here are examples of applying text watermark images.
http://www.imagemagick.org/Usage/annotating/#wmark_text
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Tacakas
Posts: 3
Joined: 2011-06-21T13:27:21-07:00
Authentication code: 8675308

Re: Semi transparent text watermark w shadow

Post by Tacakas »

This is what I was looking for:

Code: Select all

convert -channel rgba -pointsize 100 -strokewidth 2 logo: ( -background transparent -stroke #000b -fill #000a label:"mark" -blur 3x3 -stroke none  -fill #ffff label:"mark" -flatten ) -compose dissolve -define compose:args=50 -composite -quality 100 out.jpg
After several test I find out, than multiple `label:` represents as layer and I try to `-flatten` them.
You then use a fill color of "#ffff" which is fully-transparent white.
Here you are wrong, last `f` mean fully solid colour http://www.imagemagick.org/Usage/color_ ... _semitrans

Sorry for my writing mistakes, english is not my native language and thanks for great tool.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Semi transparent text watermark w shadow

Post by anthony »

Applogies for the color mistake. Typically fully-opaque colors don't specify transparency at all.

From that I gather that you actually want a white center.

However after the flatten consider my suggestion of multiplying alpha by the dissolve amount before saving.
-channel A -evaluate multiply 0.5 +channel
This way you can apply the saved watermark to multiple images simply by composing over them.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply