transparency

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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Use xc:black rather than xc:none.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Post by glennrp »

nor wrote:
magick wrote:Use xc:black rather than xc:none.

This is not what I need!.. This just creates a black background and still it puts an opaque image on it. I need the transparent bg (wich I can get with xc:none or xc:transparent) and the drawn image (bg.png) should have 60% opacity...

Can this be done? Thanks.

  • composite -dissolve 60% fg.png bg.png combined.png
Maybe omitting the "%"; I forget.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Refering to your original attempt using rgba(0,0,0,124), you can do it using a
'matte' color fill. matte uses the transparency valur of the -fill colro seeting to
seth the alpha channel of the filled area.

Note however that, as per SVG standards the alpha component of rgba() is a decimal number. EG: rgba(0,0,0, 0.6 )

convert rose: -fill "rgba(0,0,0,0.6)" -draw 'matte 0,0 reset' semi-trans-rose.png

If you want a black border around a semi-transparent black 'window', as you original example is impling, then just create such a rectangle, and add a black border
(you must use a "-compose Copy" setting to preserve the semi-transparency).

convert -size 64x64 xc:"rgba(0,0,0,0.6)" \
-bordercolor black -compose Copy -border 18x18 \
black_window.png

As with anything with IM, you can do just about anything. You just need to describe what you want exactly, rather than how you are attempting to do it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply