Reputation: 745
I've been trying to blur some text for a while now using the following code in PHP:
$image = imagecreate(150,25);
$background = ImageColorAllocate($image, 255, 255, 255);
$foreground = ImageColorAllocate($image, 0, 0, 0);
ImageColorTransparent($image, $background);
ImageInterlace($image, false);
ImageTTFText($image, 20, 0, 0, 20, $foreground, "font.ttf", "some text");
$gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
imageconvolution($image, $gaussian, 16, 0);
imagePNG($image)
However the image does not blur, it only decreases in resolution, becoming grainy... Demo here..
Upvotes: 0
Views: 1493
Reputation: 95121
Remove ImageColorTransparent($image, $background);
to see the effect
Example
$image = imagecreate(150,25);
$background = ImageColorAllocate($image, 255, 255, 255);
$foreground = ImageColorAllocate($image, 0, 0, 0);
ImageInterlace($image, false);
ImageTTFText($image, 20, 0, 0, 20, $foreground, "verdana.ttf", "some text");
$gaussian = array(array(1.0,2.0,1.0),array(2.0,4.0,2.0),array(1.0,2.0,1.0));
imageconvolution($image, $gaussian, 16, 0);
header('Content-Type: image/png');
imagepng($image, null, 9);
Output
^ Before ^ ^ After ^
Upvotes: 2