Page 1 of 1
mask problem
Posted: 2015-10-26T13:52:11-07:00
by Bonzo
I am trying to create a grunge type font without success.
I have some text on a transparent background:
Code: Select all
convert -pointsize 200 -background none -fill blue label:"Anthony" text.png
I have a texture and I want to add the texture to the text and end up with the text on a transparent background and the texture to add transparent holes in the text.
The texture I am using:
I am converting the texture to a monochrome and inverting it before using it.
The problems I am having with different codes are:
If the texture is not the same size as the text image I get a size error.
The white areas I want transparent are staying white.
The text is black instead of blue.
Amongst other things I have tried:
convert input -mask -mask output
convert input mask -alpha off -compose copy-opacity -composite output
Please can somebody point me in the right direction.
Re: mask problem
Posted: 2015-10-26T14:04:14-07:00
by fmw42
I am not following your request. Do you want the blue text to have the grunge modulation or do you want the transparency to be replace by this grunge texture? In either case, you may need to crop out a section of your texture of the size of your text file to merge them.
IM will use the size of the first image for the size of the output, which is why you may need to crop before doing any composite.
Nevertheless, you can do some using the Duff-Porter compose methods.
So Is this what you want?
Code: Select all
convert text.png grunge.gif -gravity center -compose atop -composite result.png
or perhaps this?
Code: Select all
convert text.png grunge.gif -compose dstatop -composite result.png
Do you have an example of what you want done or can you explain a bit further?
Re: mask problem
Posted: 2015-10-26T14:17:39-07:00
by Bonzo
I would like the effect of the text being a transfer and the transfer has been scratched and the background colour will show through both around the text and through the scratched areas.
This is one of my failures:
The text is now black and it should be blue and the "scratches" are white and they should be transparent. The background is transparent so I have one out of three things correct!
Re: mask problem
Posted: 2015-10-26T14:22:44-07:00
by fmw42
See my modified message above. I still do not know exactly what you want.
Re: mask problem
Posted: 2015-10-26T14:26:40-07:00
by fmw42
try this
Code: Select all
convert text.png grunge.gif -gravity center -compose atop -composite text.png -compose over -compose multiply -composite result.png
or
Code: Select all
convert text.png \
\( -clone 0 grunge.gif -gravity center -compose atop -composite \) \
+swap -compose over -compose multiply -composite result.png
or
Code: Select all
convert text.png \
\( -clone 0 grunge.gif -gravity center -compose atop -composite \) \
+swap -compose over -compose blend -composite show:
Re: mask problem
Posted: 2015-10-26T14:36:05-07:00
by Bonzo
Thanks for the info and the last is the closest but the "scratched" areas are still white.
So I now have the blue text and the transparent background but as I say the scratches are white and need to be transparent.
The bottom left still has a sort of "stroke/border" to the A which should not be there
Re: mask problem
Posted: 2015-10-26T14:37:35-07:00
by fmw42
try this:
Code: Select all
size=`convert text.png -format "%wx%h" info:`
convert text.png \
\( -clone 0 -alpha off \) \
\( -clone 0 -alpha extract \) \
\( grunge.gif -gravity center -crop $size+0+0 +repage \) \
\( -clone 2 -clone 3 -compose multiply -composite \) \
-delete 0,2,3 -compose over -compose copy_opacity -composite result.png
But you will need to convert my code to windows syntax.
Re: mask problem
Posted: 2015-10-26T14:45:24-07:00
by fmw42
This works without having to get the size first.
Code: Select all
convert text.png \
\( -clone 0 -alpha off \) \
\( -clone 0 -alpha extract \) \
\( -clone 2 grunge.gif -compose multiply -composite \) \
-delete 0,2 -compose over -compose copy_opacity -composite result.png
Re: mask problem
Posted: 2015-10-26T14:46:52-07:00
by fmw42
Here it is putting both commands together.
Code: Select all
convert -pointsize 200 -background none -fill blue label:"Anthony" \
\( -clone 0 -alpha off \) \
\( -clone 0 -alpha extract \) \
\( -clone 2 grunge.gif -compose multiply -composite \) \
-delete 0,2 -compose over -compose copy_opacity -composite result.png
Re: mask problem
Posted: 2015-10-26T14:57:23-07:00
by Bonzo
Thank you very much fmw42 it works.
I would never have worked that out; I had assumed it would be something a lot simpler.
Re: mask problem
Posted: 2015-10-26T15:01:28-07:00
by fmw42
Basically you need to merge the alpha channel with the grunge image to be the new alpha channel. Using the crop method has the advantage that you can use any part of the grunge image.
Re: mask problem
Posted: 2015-10-26T15:08:50-07:00
by fmw42
fmw42 wrote:Using the crop method has the advantage that you can use any part of the grunge image.
Actually you can use the latter method and get different parts of the grunge by adding -roll.
Code: Select all
convert -pointsize 200 -background none -fill blue label:"Anthony" \
\( -clone 0 -alpha off \) \
\( -clone 0 -alpha extract \) \
\( -clone 2 \( grunge.gif -roll -50-50 \) -compose multiply -composite \) \
-delete 0,2 -compose over -compose copy_opacity -composite result.png