Trying to create a straightforward watermark, I've worked through the excellent examples section https://imagemagick.org/Usage/annotating/ but unfortunately all the syntax is for V6 whereas I have 7.0.8-14 Q16 x64 on Win10 and the syntax seems to have got a helluva lot more complicated.
Ideally, I would reproduce the final example which under V6 is: Here we create a simple label on a semi-transparent background, and overlay it.
convert -background '#00000080' -fill white label:'Faerie Dragon' miff:- |\
composite -gravity south -geometry +0+3 \
- dragon.gif anno_composite.jpg
but I've got nowwhere trying to convert that to V7 syntax. I wonder if anyone is clever enough to rewrite this in V7 syntax?
I could live with the prior example, however which is: ...get ImageMagick to use an 'undercolor' on a text box:
convert dragon.gif -fill white -undercolor '#00000080' -gravity South \
-annotate +0+5 ' Faerie Dragon ' anno_undercolor.jpg
and I've got somewhere with this - the following works:
magick bt.jpg -resize 800 -gravity center -pointsize 50 -fill white -undercolor lightgray -stroke white -strokewidth 2 -draw "text 0,120 ' © gamesboard.org.uk '" btannotated.jpg
except for the fact that the boxed text is not semi-transparent. It needs to have an opacity of 50% or whatever so that the image underneath is not completely obscured. All efforts to achieve that have failed dismally. Probably because I just don't understand what part of the old example is doing the dimming. I can't see anything in the syntax relating to opacity and if it's something about the code of '#00000080' in the undercolor that's doing it, the syntax doesn't work for the magick command. Can anyone advise how to render the text box with some transparency?
many thanks for any pointers...
How to dim or reduce opacity on annotation
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to dim or reduce opacity on annotation
Insert the word "magick" before "convert" and "composite". That works for IM v7.jfrm wrote:I wonder if anyone is clever enough to rewrite this in V7 syntax?
However, the documention is very old. These days, we would use a single "magick" command:
Code: Select all
magick dragon.gif -background #00000080 -fill white label:"Faerie Dragon" -gravity south -geometry +0+3 -composite b.jpg
snibgo's IM pages: im.snibgo.com
Re: How to dim or reduce opacity on annotation
Thank you. This was useful and gave me enough of a kick to get it working. I needed to read about how to specify a colour to understand the transparency part which was baffling me. Here is the final result that works quite well.
magick bt.jpg -resize 1024 -background "graya(40%, 0.4)" -pointsize 50 -fill "graya(90%, 0.4)" label:" copyright text " -gravity center -geometry +0+160 -composite btannotated.jpg
magick bt.jpg -resize 1024 -background "graya(40%, 0.4)" -pointsize 50 -fill "graya(90%, 0.4)" label:" copyright text " -gravity center -geometry +0+160 -composite btannotated.jpg
-
- Posts: 1
- Joined: 2018-11-13T02:54:14-07:00
- Authentication code: 1152
Re: How to dim or reduce opacity on annotation
I am developing an image processing tool that allows users to read/manipulate different image formats and set/change the attributes of them. I am using magick++ api, so command line processing is not the way I need. Basically, I want to enable the user to change the transparency of a png file. I tried setting the background attribute by
but it didnt change anything. I also set the opacity by mobdro
but it didnt help either..hope it is clear now, thanks for your interest.
Code: Select all
int alpha = getThreshold(); Color c(0,0,0,alpha); image.backgroundColor(c);
Code: Select all
int c = getThreshold(); image.opacity(c);
Last edited by Kaitlyn225 on 2018-12-26T02:41:08-07:00, edited 2 times in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to dim or reduce opacity on annotation
IM operations at the command line correspond to functions in the C and C++ apis.Kaitlyn225 wrote:I am using magick++ api, so command line processing is not the way I need.
Setting the background won't change individual pixels that already have values. You want to change the alpha values in an image. I expect ...
Code: Select all
void alpha(const unsigned int alpha_);
snibgo's IM pages: im.snibgo.com