Hello, I am making a dynamic script in php and gd and I would like to know if there is a way to put a border on text like the stroke feature in GIMP. I looked in the phpmanual but couldn't find what i was looking for, then I tried making 2 identical texts but making one larger then the other and having it behind the other but I couldn't get it to line up properly. Any help would be greatly appreciated, I am using PHP 5.2.0 and GD 2.0.28 with everything. JRD
next add 1px border to the text. it has better look with small font size. ... // Add some shadow to the text imagettftext($im, 12, 0, 9, 13, $white, $font, $text); imagettftext($im, 12, 0, 10, 13, $white, $font, $text); imagettftext($im, 12, 0, 11, 13, $white, $font, $text); imagettftext($im, 12, 0, 9, 15, $white, $font, $text); imagettftext($im, 12, 0, 11, 15, $white, $font, $text); imagettftext($im, 12, 0, 10, 15, $white, $font, $text); imagettftext($im, 12, 0, 9, 14, $white, $font, $text); imagettftext($im, 12, 0, 11, 14, $white, $font, $text); // Add the text imagettftext($im, 12, 0, 10, 14, $black, $font, $text); ...
Hi! @ Jrdgames petrucco's idea was right! If you want, you can use my function here: http://www.programmierer-forum.de/texteffekte-mit-php-imagettftext-mit-umrandung-rand-t80510.htm The given example works with two borders to make it more plastically. @ petrucco Thank you! Your idea was the base for this function. regards, Marc http://www.maxrev.de
Thanks mgutt that does exactly what I needed. I just wasn't able to get petrucco's code to work for me but with your function it is simple.
Yes it is simpel now, but it took me a long time to test which pixel area's need to be covered Although I don't think the results are perfect. Especially the "N", "W", etc. with hard lines seem ugly with a bold border in the corners. Maybe there is need to add some round corners with an antialiasing effect. P.S.: At the moment I'm working on filling fonts with a color gradient and I'm searching for a solution to have multicolored chars in a word. If you know some other effects please let me know. I want to generate logo's on-the-fly so every effect in combination with imagettftext is welcome. regards
I'm sure it did take a while, and I'm glad you were able to figure it out. You are correct, it could use some more fading on some of the edges, but it works fine for now. It would also be nice if it had an option of whether to give it a hard edge or not. If I find or develop any imagettftext functions then I'll try to remember to let you know.