transparency problem.

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
boggen

transparency problem.

Post by boggen »

version info
using version 6.3.3-6
using command line
using xp pro

--------
i want to place some text on an image. this image will become alapha channel. call it A.gif
i then want to take B.gif (premade image). and make A.gif, alapha channel for this image. call this C.gif
i then want to take D.gif (premade image). load it up for a background. and then overlay C.gif. call this E.gif

---------------
cuting it down to the basics
convert -size 470x41 xc:white -fill black -font Tahoma-Bold -pointsize 33 -draw "text 5,30 'this is my test text'" A.gif
convert -size 470x41 xc:blue B.gif ((premade gif ))

((unknown command line)) to set A.gif, as alpha channel for B.gif ((will create C.gif))

convert -size 470x41 xc:green D.gif

((unknown command line)) to load up D.gif and then overlay C.gif. ((will create E.gif))


---------------
changing above code around i have tried varitions of below in so many ways that i am now lost of what i have not tried
convert D.gif B.gif -channel A -fill black -font Tahoma-Bold -pointsize 33 -draw "text 5,30 'this is my test text'" E.gif

thought i could load up D.gif ((background image that shows inside the text ))
load up B.gif ((background image that shows outside the text))
apply text to alpha channel of of B.gif as black or transparent
then send output to E.bmp or E.jpg or E.gif or any other format.

i don't know if i have my commands wrong or right or if i should be using something else. or if i am missing some sort of comma, forward slash or what....help plz.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: transparency problem.

Post by Bonzo »

I am not exactly sure what you mean. As I read it you want to have some text with an image in the text and overlay this text over another image.

Image

This is creating the gradiant and overlaying the text; you could replace the gradiant step and use your image which would give you some text made up of the image then composite it over the second image.

I am currently at work and so can not test this but you should get the idea.

Code: Select all

// Create the text to use as a mask
convert -size 460x65 xc:none -font action.ttf -pointsize 60 -draw \"gravity center fill black text 0,0 'Anthony' \" text_mask.png
// Lay the mask over the first image
composite -compose Dst_In text_mask.png -gravity center first_image.gif -matte text.png 
// Lay the text image over the second image
composite text.png  second_image.gif final_image.gif
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: transparency problem.

Post by Bonzo »

Image

Code: Select all

convert -size 460x65 xc:none -font action.ttf -pointsize 70 -draw \"gravity center fill black text 0,0 'Albir' \" text_mask.png
composite -compose Dst_In text_mask.png -gravity center sunflower_border.jpg -matte text_gradiant.png
composite -gravity center text_gradiant.png albir1.jpg composte.jpg  
boggen

Re: transparency problem.

Post by boggen »

thanks Bonzo! exact commands i was needing! the first example through me through a loop. not until i saw the second example did it sink in. thanks again!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: transparency problem.

Post by anthony »

You can also use -compose and -composite in the "convert" command
that way you only need the one command to generate the image.

Note however that destination is first then source image in "convert".

Hmmm simpler way.. A three image convert (use the latest IM you can due to bug fixes in masked composition...

Code: Select all

  convert image_background.png  -size 460x65 gradient:red-orange \
              -background black -fill white  -font ComicSans -gravity center label:MASK \
              +gravity -composite    masked_overlay_image.png
The Lable has no pointsize, do the it is sized according to -size, whch should be the same size as the first image. Note masking only works properly with all images the same size.
See http://www.imagemagick.org/Usage/compose/#mask
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: transparency problem.

Post by Bonzo »

Thats good boggen as I was not 100% sure what you wanted.
Post Reply