Semi-transparent background

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
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Semi-transparent background

Post by robocop »

Hi all !

I'm using the following wood texture background and code to generate the image below.

I was wondering how to make the white rounded square background Semi-transparent so a bit of the wood texture shows through it?

I have the text fully transparent and would also like the white background to be about 50% transparent if possible.

Thank you for your help!

Code: Select all

convert \( -size 450x450 xc:white \) \
\( +clone  -alpha extract \
-draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite \
\( -size 400x400 -background none -fill white -gravity center \
-font arial label:"let's\nbe\nHAPPY"  \) \
-gravity center -compose dstout -composite -alpha on \
canvas.jpg +swap -compose over -composite sample.png
Image

Result:
Image
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Semi-transparent background

Post by snibgo »

Insert "-evaluate Multiply 0.3" (or whatever opacity you want) like this:

Code: Select all

convert \( -size 450x450 xc:white \) \
\( +clone  -alpha extract \
-draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
-evaluate Multiply 0.3 \
\) -alpha off -compose CopyOpacity -composite \
\( -size 400x400 -background none -fill white -gravity center \
-font arial label:"let's\nbe\nHAPPY"  \) \
-gravity center -compose dstout -composite -alpha on \
canvas.jpg +swap -compose over -composite out.png
snibgo's IM pages: im.snibgo.com
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Re: Semi-transparent background

Post by robocop »

Hi Snibgo,

Thank you so much. It was just what i needed and worked perfectly. Cheers :)

Image
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
Post Reply