Making a simple transparent rectangle.

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
The Transporter
Posts: 14
Joined: 2007-01-15T13:54:49-07:00

Making a simple transparent rectangle.

Post by The Transporter »

Hello,

I'm trying to make a simple transparent square using:

Code: Select all

convert -size 200x200 xc:none -fill '#0008' square.png
But if doesn't work.

I've read on the forum that I need to use dstOut but I don't find any example.

Can you provide a simple example who draws a square or a rectangle filled with a color and where we can set a transparency ?

Thanks alot!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Making a simple transparent rectangle.

Post by Bonzo »

Not sure what you mean as you want a transparent rectange filled with colour - that is what you created with your code.

Do you want a rectangle that is colored but you can set the opacity ?
Try this using the RGB alpha setting.

Code: Select all

convert -size 200x200 xc:rgba(255, 0, 0, 0.4) square.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Making a simple transparent rectangle.

Post by fmw42 »

convert -size 200x200 xc:rgba(255, 0, 0, 0.4) square.png
This might need quotes so that the spaces are not interpretted

convert -size 200x200 xc:"rgba(255, 0, 0, 0.4)" square.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Making a simple transparent rectangle.

Post by anthony »

You did not mention your IM version number.

Some of the recent IM releases had PNG problems
use png32:square.png if the direct to png approach is not working (you get opaque or fully-transparent).
Upgrade if you are not sure.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply