:-)
Here's a patch I just put in that adds minor borders to the signwriter.
Includes update path, mildly tested, I think I got it right.

Uses a simple algorithm that underlays the text 4x in a different color, offset in different directions.
Inspiration arose from a feature request on imagecache actions http://drupal.org/node/328605
I suggested that signwriter is a better place for this sort of development. If we can find a way to integrate imagecache/imageapi/signwriter to a more common way of adding effects, it may be cool. Maybe.

Before:
Only local images are allowed. http://drupal.org/files/issues/phpuser-noborder-signwriter.png" >
After:
Only local images are allowed. http://drupal.org/files/issues/phpuser-border-signwriter.png" >

This particular example is used for a pretty subtle effect, but is the improvement I needed today.
Extra work on the redrawing may be added to support thicker borders. The algorithm will cause ghosting if the radius is larger than a few pixels, compared with the text. Best if it's just 1 or two pixels.

Looks like fun?

Comments

dman’s picture

Forgot the HTML code for the illustrations :)
Before:

After:

catorghans’s picture

Great!,

Works for me in my current project. Did not look at the code yet, so I won't change the status, but if it's up to me this functionality becomes part of the code asap.

agileware’s picture

Thanks for the patch dman, it looks good. I will look at rolling it in in the next few days.

smbotans’s picture

can someone explain how to install the patch pls ... i really like signwriter and would love the patch installed

thanks in advance

serge

agileware’s picture

You can find the information here - http://drupal.org/patch/apply

Except where they say the root of the drupal directory you will need to be in the root of the signwriter module.

agileware’s picture

Status: Needs review » Fixed

This is in the new 6.x-1.0-dev version that should be available today.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dman’s picture

I'm doing a CVS update to 6-2 after a long period of inactivity and found a local patch I'd made but hadn't given back.
This is an improvement on the patch I gave above, providing softer corners and the ability to set borders greater that 1px that don't get chunky immediately. It's a better algorithm - suitable for bigger text.
Is much more processor-intensive as it does multiple redraws to do proper border radiuses.

posting raw code here for posterity and reference only - I'll see if it's worth patching in to the current release after I do a clean update, my local code has branched far.



/**
 * Slightly less crude way of getting a bordered effect
 */
function signwriter_bordered_text($im, $fontsize, $angle, $x, $y, $text_color, $fontfile, $line, $border_radius = 0, $border_color = 0) {
  if ($border_radius) {
    // Write a copy of the text - in all directions - including diagonals - and all pixels in between.
    // This method is scale-safe. You can add thick borders to thin text.
    // It scales exponentially however. radius 5 =~ 13 redraws
    // starting from zero creates overwrites - but I can't start from 1 or border=1 cannot render.
    for($xrad = 0 ; $xrad <= $border_radius; $xrad ++ ){
      for($yrad = 0 ; $yrad <= $border_radius; $yrad ++ ){
        // Attempt to ROUND the corners a little (using pythagoras). This check will avoid the worst of the blocky corners
        if ( ($xrad + $yrad > 0) &&  (pow($xrad, 2) + pow($yrad, 2)) <= pow($border_radius, 2)) {
          foreach(array(1, -1) as $xdir){
            foreach(array(1, -1) as $ydir){
              imagettftext($im, $fontsize, $angle, $x + ($xdir * $xrad), $y + ($ydir * $yrad), $border_color, $fontfile, $line); 
            }
          }
        }
      }
    }
  }

  // Actual Text
  imagettftext($im, $fontsize, $angle, $x, $y, $text_color, $fontfile, $line); // Text
}