Page 1 of 1

how can we stroke text 1px outside it

Posted: 2011-02-03T07:09:38-07:00
by webad20
In photoshop we can stroke text by choosing stroke position as outside. But I can not find the option in IM. It is usefull when we stroke small text like 12px. We can do the job by writing the text in four directions in stroke color and then write the text in fill color, but that's not nice. With +antialias it is impossible :(

Mean while +antialias make charecters ugly, especailly chinese charecters, even cannot be read. That is far diffrent from photoshop by setting antialias as none. Also, it is usefull dealing with small texts. Is there any way to handle these problems? We have to use small texts in our project, Athony's examples are all big texts :shock: .

The image below shows,
1st line, using label:text with +antialias
2nd line, annotating text
3rd line, write text in photoshop setting antialias=none
last line, stroke text outside in photoshop, I'd like IM to do the same thing.

Image

Re: how can we stroke text 1px outside it

Posted: 2011-02-03T11:00:25-07:00
by fmw42
I don't think IM has that specific option. It stokes down the middle as far as I know. You would have to specify slightly different coordinates by half the strokewidth you want to get the effect you want.

Re: how can we stroke text 1px outside it

Posted: 2011-02-03T16:44:38-07:00
by anthony
For a one pixel outside stroke you need to use a compount font.

draw/annotate/label the text with a 2 pixel stroke of the color desired.
Then repeat with the stroke color set to none, so as to remove the internal half of the stroke.
DO NOT adjust stroke width, or the second text draw may not line up with the first.

See... IM examples, Compound Fonts, Thick Stroke
http://www.imagemagick.org/Usage/fonts/#thick_stroke

I find this compound font very useful and use it extensively for other compound font variants on the same examples section.

Re: how can we stroke text 1px outside it

Posted: 2011-02-04T02:43:18-07:00
by webad20
thanks to Anthony and others. unfortunately my fonts are not compound fonts. Again, today I tried under linux. -pointsize property does not work when used with label and my chinese fonts, each time they appear larger up to 20+ even I set pointsize to 6. I guess IM need more surpport to chinese fonts, while php gd2 works nice with my fonts.

I don't have time to read source code about fonts. I guess IM should be improved when convert vector fonts to bitmap show. Maybe using function 'floor' instead of 'round' is better when caculate a pixel should be filled or empty, pratically, adjusting the threshold is good. But that's not so simple, some more complecated codes are required to ensure the charecters are coutinuos.

Back to my project, I got a solution not so nice. First write text in php gd2, then add more effects like stroke in IM. It's suffering...

Re: how can we stroke text 1px outside it

Posted: 2011-02-04T19:11:07-07:00
by anthony
Compound fonts is a 'drawing method' It is not specifically a type of font.

That is you draw fonts multiple times or with some sort of extra processing to generate interesting effects.

No special fonts are used.

In this case a 1px external stroke, is done by drawing the draw twice.