add a watermark but not on transparent pixels

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
webshaker
Posts: 16
Joined: 2007-07-25T15:42:25-07:00

add a watermark but not on transparent pixels

Post by webshaker »

Hi.
I'm looking to add a watermark but kipping the alpha of the bitmap.

I'm currently use this command
composite -dissolve 50% -gravity SouthEast watermark.png airship.png airship1.png

It give me this result.
http://www.webshaker.net/airship1.png

But what I'd like to have is
http://www.webshaker.net/airship2.png

i.e. not have the watermark on transparent pixels.

That must not be difficult for someone who know how to use imagemagick, but for me...

Thank's
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: add a watermark but not on transparent pixels

Post by fmw42 »

what does your watermark image look like -- does it have the text all over it? If so create a mask from the other image and use that to limit the text for the watermark image before compositing or white compositing.

If you post your two input image, we can try to give you the commands.
webshaker
Posts: 16
Joined: 2007-07-25T15:42:25-07:00

Re: add a watermark but not on transparent pixels

Post by webshaker »

oups sorry.
I was not clear...

my watermark image is
http://www.webshaker.net/watermark.png

my image source is
http://www.webshaker.net/airship.png

what I want is
http://www.webshaker.net/airship2.png

Thx
Etienne
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: add a watermark but not on transparent pixels

Post by fmw42 »

try this



# read airship
# read watermark and crop to southeast corner
# extract the alpha channel of the airship image as a mask
# dissolve the airship and the cropped watermark using the mask to limit the watermark
convert airship.png \
\( watermark.png -gravity southeast -crop 256x256+0+0 +repage \) \
\( -clone 0 -alpha extract \) \
-compose dissolve -define compose:args=50,100 -composite \
airship3.png



see
http://www.imagemagick.org/script/compose.php
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/compose/#dissolve
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/basics/#clone


This is unix. If on windows, see difference such as no \ escape on parens and end of line escape change from \ to ^. see http://www.imagemagick.org/Usage/windows/
Post Reply