Warren Vick
Warren Vick

Reputation: 81

ImageMagick convert - Label text over alpha background

I'm trying to place a copyright message on a large batch of PNG images. I'd like to place the message in the bottom-right corner in black text on a semi-transparent white background. Here's my Windows command line script which loops through the images and runs a ImageMagick convert & composite pipeline:

for %%f in (*.png) do (
  convert -background "#FFFFFF80" -font verdana -fill black ^
           label:" (c) 2015 My Company "  miff:-            ^
  | composite -compress zip -gravity SouthEast              ^
              -geometry +0+0 - "%%f" "credited\%%f.png" )

The white background with 50% (0x80) opacity is working well, but when the label text renders into the image, there's a horrible grey in the background of the characters. Here is an example by just running the initial convert into a PNG.

enter image description here

Is this a bug or am I missing something important in IM alpha channel management?

Upvotes: 4

Views: 1731

Answers (1)

Kurt Pfeifle
Kurt Pfeifle

Reputation: 90263

Running these commands on OSX with version 6.9.0-0 Q16 x86_64 2014-12-06:

convert -background '#ffffff80' -font verdana \
        -size 360 -fill black label:"Hello World" hw1.png

convert -background '#00000080' -font verdana \
        -size 360 -fill black label:"Hello World" hw2.png

convert -background '#ff000080' -font verdana \
        -size 360 -fill black label:"Hello World" hw3.png

composite hw1.png -geometry +100+10 hw2.png comp12.png
composite hw1.png -geometry +100+10 hw3.png comp13.png

produces the following images:

"Hello World"-image 1

"Hello World"-image 2

"Hello World"-image 3

hw1 + hw2 composite

hw2 + hw3 composite

Upvotes: 2

Related Questions