Text with gradient stroke?

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?".
froesi

Re: Text with gradient stroke?

Post by froesi »

Thanks rmabry,

that was what I thought too, but its not working, do you've another idea? :)

cheers
froesi
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Text with gradient stroke?

Post by rmabry »

froesi wrote: that was what I thought too, but its not working, do you've another idea? :)
Not without the exact command and error message.

But I cannot even run the command you posted without escaping the parentheses AND putting spaces around them.

On the other hand, the Linux system I am using is way out of date for ImageMagick (6.3.2), so mine fails (with no error message) for other reasons.

Rick
froesi

Re: Text with gradient stroke?

Post by froesi »

Hi,

I've version (6.4.0.4) and mine fails too. (with no error message).

thats the code.

Code: Select all

convert -size 1024x768 xc:white -font Helvetica -pointsize 80 \( -size 20x80 gradient:#FFFF00-#ff0000 -write mpr:grad  -fill mpr:grad \) -strokewidth 5 -draw "text 20,80  'GRADSTROKE'" -delete 1 wallpaper_test.jpg


thanks
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Text with gradient stroke?

Post by rmabry »

froesi wrote:mine fails too. (with no error message).

Code: Select all

convert -size 1024x768 xc:white -font Helvetica -pointsize 80 \( -size 20x80 gradient:#FFFF00-#ff0000 -write mpr:grad  -fill mpr:grad \) -strokewidth 5 -draw "text 20,80  'GRADSTROKE'" -delete 1 wallpaper_test.jpg
Hmm, this works (except that I gave it a different font):

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  \( -size 20x20 gradient:#FFFF00-#ff0000 -write mpr:grad \) -fill mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 gradstroke.png
Ach -- you've got your -fill in the wrong spot.

Rick
froesi

Re: Text with gradient stroke?

Post by froesi »

Damn, nope, that was a stupid copy& paste error. I've

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  \( -size 20x20 gradient:#FFFF00-#ff0000 -write mpr:grad \) -fill #FFD505 -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 gradstroke.png
I forgot the -fill, the point is, that I want the gradient at the stroke.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Text with gradient stroke?

Post by rmabry »

froesi wrote:Damn, nope, that was a stupid copy& paste error. I've

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  \( -size 20x20 gradient:#FFFF00-#ff0000 -write mpr:grad \) -fill #FFD505 -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 gradstroke.png
I forgot the -fill, the point is, that I want the gradient at the stroke.
You don't tell us what is wrong. But I get an error (convert: no encode delegate for this image format `-fill'.) unless I put the color in quotes (-fill "#FFD505") or escape the # symbol (-fill \#FFD505).

Rick
froesi

Re: Text with gradient stroke?

Post by froesi »

Thanks Rick, now I got the gradient, but I've my old problem, that the whole gradient won't be created as a single new image, and that the script starts at point y:0 to start for the gradient.

Now I have this line:

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  \( -size 20x20 gradient:#FFFF00-#ff0000 -write mpr:grad \) -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 -fill \#FFFF00 -stroke none -draw "text 20,80  GRADSTROKE" gradstroke.png
I want the text as a stroke -> the stroke should have the gradient.
Over the stroke I put the Text again.
froesi

Re: Text with gradient stroke?

Post by froesi »

[edit] Sorry for the second post, but the server was down


Thanks Rick, now I got the gradient, but I've my old problem, that the whole gradient won't be created as a single new image, and that the script starts at point y:0 to start for the gradient.

Now I have this line:

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  \( -size 20x20 gradient:#FFFF00-#ff0000 -write mpr:grad \) -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 -fill \#FFFF00 -stroke none -draw "text 20,80  GRADSTROKE" gradstroke.png
I want the text as a stroke -> the stroke should have the gradient.
Over the stroke I put the Text again.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Text with gradient stroke?

Post by rmabry »

froesi wrote:Thanks Rick, now I got the gradient, but I've my old problem, that the whole gradient won't be created as a single new image, and that the script starts at point y:0 to start for the gradient.
I'm not too clear on what you mean here about a "single new image". The gradient below is indeed a new image.

And I don't understand "the script starts at point y:0".

I wonder if you mean that you want to change the point at where the tiling starts. If so, try adding "-tile-offset +x+y" (where you choose x and y) to effectively roll the tile. (You can also use -roll in place of -tile-offset to change the intermediate file itself; -tile-offset just causes an offset to be added, so that the pixels are read from a different spot. In this situation, I think -roll -x-y and -tile-offset +x+y are equivalent, with -tile-offset being generally more efficient.)
Now I have this line:

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  \( -size 20x20 gradient:#FFFF00-#ff0000 -write mpr:grad \) -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 -fill \#FFFF00 -stroke none -draw "text 20,80  GRADSTROKE" gradstroke.png
I want the text as a stroke -> the stroke should have the gradient.
Over the stroke I put the Text again.
Okay. And with the above, the stroke DOES have the gradient, doesn't it? Sorry to seem dense. If possible, maybe you can attach a "hand-drawn" version of what you want.

Anyway, play with the parameter in -tile-offset below to see if that can be used to get what you want.

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  \( -size 20x20 gradient:#FFFF00-#ff0000 -tile-offset +0+10 -write mpr:grad \) -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 -fill \#FFFF00 -stroke none -draw "text 20,80  GRADSTROKE" gradstroke.png
Rick
froesi

Re: Text with gradient stroke?

Post by froesi »

Thank you Rick for your help,

I tried this, but i won't work. It seems like the gradient is put over the whole image, not only over the text.

Here again the code I use.

Code: Select all

convert -size 1024x768 xc:white -draw 'affine 1,0,0,1,6,77 image Over 0,0 0,0 "bg.jpg"'  -font FontName -pointsize 26 \( -size 20x60.359415458679 gradient:#FFFF00-#ff0000 -tile-offset +212.910275+123.908375 -write mpr:grad \) -stroke mpr:grad -strokewidth 8 -draw 'affine 2.2777137908936,0,0,2.2777137908936,212.910275,123.908375 text 5,26.52 "GRADSTROKE" ' -delete 1 -fill #FFFF00 -stroke none -draw 'affine 2.2777137908936,0,0,2.2777137908936,212.910275,123.908375 text 5,26.52 "GRADSTROKE" ' -draw 'affine 1,0,0,1,0,0 image Over 0,0 0,0 "mask.png"'  image.jpg 2>&1
that's how it should look like:
Image

And here are some test where the text has a different position:
Image

Image

I hope now you'll know what I mean :)
thanks
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Text with gradient stroke?

Post by rmabry »

froesi wrote: I tried this, but i won't work. It seems like the gradient is put over the whole image, not only over the text.
I'm confused by that statement because the code I posted above gives the following.
The gradient is indeed only over the text. (I believe our terminology is clashing.) Here it is for Windows, so you'd need to escape the (, #, ),:

Code: Select all

-size 600x100 xc:white -font Helvetica -pointsize 80  ( -size 20x20 gradient:#FFFF00-#ff0000 -tile-offset +0+10 -write mpr:grad ) -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 -fill #FFFF00 -stroke none -draw "text 20,80  GRADSTROKE" gradstroke.png
Image

Of course I realize you want the period of the gradient to match the height of the text. You could adjust the size of the period: (I've used a slightly different method that doesn't affect the discussion. Notice that the size of the text is 63 pixels; this is a problem with this method --- you have to measure it.)

Code: Select all

convert -size 600x100 xc:white -font Helvetica -pointsize 80  -fill #ffff00 ( -size 1x63 gradient:#FFFF00-#ff0000 -tile-offset +0-20 -write mpr:grad ) -stroke mpr:grad -strokewidth 5 -draw "text 20,80  GRADSTROKE" -delete 1 gradstroke2.png
Image

You can move the text if you adjust the offset: (I moved the text down 15 pixels and did llikewise for the offset.)

Code: Select all

-size 600x100 xc:white -font Helvetica -pointsize 80  -fill #ffff00 ( -size 1x63 gradient:#FFFF00-#ff0000 -tile-offset +0-35 -write mpr:grad ) -stroke mpr:grad -strokewidth 5 -draw "text 20,95  GRADSTROKE" -delete 1 gradstroke3.png
Image
Here again the code I use.
But I cannot test that, as I don't have your images "bg.jpg" or "mask.png". But no matter...
I hope now you'll know what I mean :)
You tell me! Maybe I'm getting warm.

Rick
froesi

Re: Text with gradient stroke?

Post by froesi »

Thank you Rick for your answer,

it's not working:

Why do I cant say, write the gradient, then write again an internal image, where the text lies at point 0,0 --> put there the gradient into the stroke und all these image together put back into the big one at a certain position?

the problem is, if the text moves somewhere else in the image, you have to change the offset value too, I cant do that dynamicly in an easy way. The size of the textfont is changing too.

like you wrote, when you change the y value of your text you need to change the offset again.

cheers froesi
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Text with gradient stroke?

Post by rmabry »

froesi wrote:Why do I cant say, write the gradient, then write again an internal image, where the text lies at point 0,0 --> put there the gradient into the stroke und all these image together put back into the big one at a certain position?

the problem is, if the text moves somewhere else in the image, you have to change the offset value too, I cant do that dynamicly in an easy way. The size of the textfont is changing too.

like you wrote, when you change the y value of your text you need to change the offset again.
Right you are. That's what scripts are for. If you can manage Perl/PerlMagick or some other scripting language, you can probably do anything you wish. Otherwise, fonts are royal pain. Having to mess with pointsize makes it difficult to know the image sizes. You can avoid pointsize using the label: pseudotype bu then you can't use tiles! Maybe that will change one day.

I hope you've looked at Anthony's advice on all this:

http://www.imagemagick.org/Usage/text/#size

One of the best bits of advice he gives is this: "Basically you can't really win, in all situations, just try your best."

If I think of anything else (that probably won't work), I'll let you know! :-)

Rick
Post Reply