Example #1
0
<?php

include 'php52-fix.php';
include 'imagettftextblur.php';
// Your image link
$image = imagecreatefrompng('images/bg.png');
$phoneNumberVariables = array('size' => 32, 'aOBngle' => 0, 'x-offset' => 392, 'y-offset' => 390, 'file' => __DIR__ . DIRECTORY_SEPARATOR . 'helvetica.otf', 'color' => imagecolorallocate($image, 255, 255, 255), 'blurColor' => imagecolorallocate($image, 0, 0, 0), 'blur' => 10);
$emailAddressVariables = array('size' => 32, 'aOBngle' => 0, 'x-offset' => 392, 'y-offset' => 450, 'file' => __DIR__ . DIRECTORY_SEPARATOR . 'helvetica.otf', 'color' => imagecolorallocate($image, 255, 255, 255), 'blurColor' => imagecolorallocate($image, 0, 0, 0), 'blur' => 10);
// Open the first source image and add the text.
$image = imagecreatefrompng('images/bg.png');
$phoneNumber = $_GET['number'];
$emailAddress = $_GET['email'];
imagettftextblur($image, $phoneNumberVariables['size'], $phoneNumberVariables['angle'], $phoneNumberVariables['x-offset'], $phoneNumberVariables['y-offset'], $phoneNumberVariables['blurColor'], $phoneNumberVariables['file'], $phoneNumber, $phoneNumberVariables['blur']);
imagettftextblur($image, $phoneNumberVariables['size'], $phoneNumberVariables['angle'], $phoneNumberVariables['x-offset'], $phoneNumberVariables['y-offset'], $phoneNumberVariables['color'], $phoneNumberVariables['file'], $phoneNumber);
imagettftextblur($image, $emailAddressVariables['size'], $emailAddressVariables['angle'], $emailAddressVariables['x-offset'], $emailAddressVariables['y-offset'], $emailAddressVariables['blurColor'], $emailAddressVariables['file'], $emailAddress, $emailAddressVariables['blur']);
imagettftextblur($image, $emailAddressVariables['size'], $emailAddressVariables['angle'], $emailAddressVariables['x-offset'], $emailAddressVariables['y-offset'], $emailAddressVariables['color'], $emailAddressVariables['file'], $emailAddress);
ob_start();
imagepng($image);
$imagedata = ob_get_contents();
ob_end_clean();
//expire this image instantly
//header('Content-Type: image/png');
//$png = $image;
print '<html><head></head><body><p><img src="data:image/png;base64,' . base64_encode($imagedata) . '" alt="Facebook Cover Photo" width="100%" /></p></body></html>';
<?php

if (file_exists('../source/imagettftextblur.php')) {
    require_once '../source/imagettftextblur.php';
} else {
    die('imagettftextblur.php not found');
}
$height = 300;
$width = 600;
$size = 20;
$font = 'arial.ttf';
$string = 'This is an example that is blurry';
$text_dimensions = imagettfbbox($size, 0, $font, $string);
$x_offset = $width / 2 - (min($text_dimensions[2], $text_dimensions[4]) - max($text_dimensions[0], $text_dimensions[6])) / 2;
$y_offset = $height / 2 - (min($text_dimensions[5], $text_dimensions[7]) - max($text_dimensions[1], $text_dimensions[3])) / 2;
$image = imagecreatetruecolor($width, $height);
$background_color = imagecolorallocate($image, 0xee, 0xee, 0xee);
$text_color = imagecolorallocate($image, 0x0, 0x0, 0x0);
imagefill($image, 0, 0, $background_color);
imagettftextblur($image, $size, 0, $x_offset, $y_offset, $text_color, $font, $string, 10);
header('Content-Type:image/png');
imagepng($image);
imagedestroy($image);