Page 1 of 1

How to dim or reduce opacity on annotation

Posted: 2018-11-01T03:13:41-07:00
by jfrm
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...

Re: How to dim or reduce opacity on annotation

Posted: 2018-11-01T06:14:35-07:00
by snibgo
jfrm wrote:I wonder if anyone is clever enough to rewrite this in V7 syntax?
Insert the word "magick" before "convert" and "composite". That works for IM v7.

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

Re: How to dim or reduce opacity on annotation

Posted: 2018-11-02T12:03:23-07:00
by jfrm
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

Re: How to dim or reduce opacity on annotation

Posted: 2018-11-13T03:01:32-07:00
by Kaitlyn225
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

Code: Select all

int alpha = getThreshold(); Color c(0,0,0,alpha); image.backgroundColor(c);
but it didnt change anything. I also set the opacity by mobdro

Code: Select all

int c = getThreshold(); image.opacity(c);
but it didnt help either..hope it is clear now, thanks for your interest.

Re: How to dim or reduce opacity on annotation

Posted: 2018-11-13T07:29:39-07:00
by snibgo
Kaitlyn225 wrote:I am using magick++ api, so command line processing is not the way I need.
IM operations at the command line correspond to functions in the C and C++ apis.

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_);
... does what you want.