Results 1 to 6 of 6

Thread: Glowing text GD

  1. #1
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Glowing text GD

    Hello everyone!

    Can anyone create this: http://cbimg6.com/tutorials/08/02/11/1017ab.png

    effect using php and gd? The fonts must be customizable and the background transparent.

    Here's as far as I could get:

    PHP Code:
    <?
    function Blur(&$gdimg$radius=0.5) {
            
    // Taken from Torstein Hnsi's phpUnsharpMask (see phpthumb.unsharp.php)

            
    $radius round(max(0min($radius50)) * 2);
            if (!
    $radius) {
                return 
    false;
            }

            
    $w ImageSX($gdimg);
            
    $h ImageSY($gdimg);
            if (
    $imgBlur ImageCreateTrueColor($w$h)) {
                
    // Gaussian blur matrix:
                //    1    2    1
                //    2    4    2
                //    1    2    1

                // Move copies of the image around one pixel at the time and merge them with weight
                // according to the matrix. The same matrix is simply repeated for higher radii.
                
    for ($i 0$i $radius$i++){
                    
    ImageCopy     ($imgBlur$gdimg0011$w 1$h 1);            // up left
                    
    ImageCopyMerge($imgBlur$gdimg1100$w,     $h,     50.00000);  // down right
                    
    ImageCopyMerge($imgBlur$gdimg0110$w 1$h,     33.33333);  // down left
                    
    ImageCopyMerge($imgBlur$gdimg1001$w,     $h 125.00000);  // up right
                    
    ImageCopyMerge($imgBlur$gdimg0010$w 1$h,     33.33333);  // left
                    
    ImageCopyMerge($imgBlur$gdimg1000$w,     $h,     25.00000);  // right
                    
    ImageCopyMerge($imgBlur$gdimg0001$w,     $h 120.00000);  // up
                    
    ImageCopyMerge($imgBlur$gdimg0100$w,     $h,     16.666667); // down
                    
    ImageCopyMerge($imgBlur$gdimg0000$w,     $h,     50.000000); // center
                    
    ImageCopy     ($gdimg$imgBlur0000$w,     $h);
                }
    //        imagepng($imgBlur, "imgBlur.png");
    //        imagepng($gdimg, "gdimg.png");
                
    return true;
            }
            return 
    false;
        }

        
    $im imagecreatetruecolor(500500);
        
    imagealphablending($imfalse);
        
    $col imagecolorallocatealpha($im255255255127);
        
    imagefilledrectangle($im00500500$col);
        
    imagealphablending($imtrue);

        
    $font "AnkeCalligraph.TTF";
        
    $size 100;
        
    $textcolor imagecolorallocate($im000);
        
    imageTTFText($im$size0100300$textcolor$font"Test");
        
    Blur($im20);
        
    $textcolor imagecolorallocate($im255255255);
        
    imageTTFText($im$size0100300$textcolor$font"Test");

        
    header("Content-Type: image/png");
        
    imagealphablending($imfalse);
        
    imagesavealpha($imtrue);
        
    imagepng($im);
    ?>
    However this is extremely resource intensive and doesn't produce a transparent bg. Any help is greatly appreciated!

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    i don't believe there is a way to create transparentcy in php
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I bet there is because I did it on the same script. http://www.bl0g.co.uk/070327/Creatin..._Images_in_GD/

  4. #4
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Try looking here:
    http://www.php.net/imagecolortransparent
    http://www.php.net/imagesavealpha

    One thing you have to remember, though, is IE's limited support of transparency, especially in anything less than 5.5
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  5. #5
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    alexjewell: Been there, done that.

  6. #6
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    shachi,

    I was having the same issue and wrote a function called imagettftextblur to address it, I've released it as open source at https://github.com/andrewgjohnson/imagettftextblur
    Last edited by james438; 03-20-2013 at 08:40 AM. Reason: removed the hotlink

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •