fill transparent

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
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

fill transparent

Post by dognose »

I'm trying to make a transparent rectangle (ie. putting a hole in the image)

I've tried:
convert -size 100x60 xc:skyblue -fill transparent -draw "roundrectangle 20,10 80,50 20,15" draw_rrect.gif

However, that doesn't work. I guess it's just drawing a transparent rectangle, which makes sense. So, the question is, how do I make a real transparent rectangle?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

You may be able to get this all on one line but this should work:

Code: Select all

convert -size 100x60 xc:skyblue -fill red -draw "roundrectangle 20,10 80,50 20,15" draw_rrect.gif 

convert draw_rrect.gif  -fuzz 50% -transparent red transparent.gif
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

That will work, but work BADLY!

the correct solution is to use alpha composition.

Create a transparent canvas, draw your hole shape as normal, then use Alpha Composition
"Dst_Out" to punch that shape from the image.
See http://www.cit.gu.edu.au/~anthony/graph ... se/#dstout
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply