Jeg har nu lavet en ændring i koden også vil jeg også gerne have teksten $name til at være centeret.
http://coderdk.fuckingloveyou.com<?php
// Set the content-type
header("Content-type: image/png");
// Create the image
$im = imagecreatefromjpeg("heart.jpg");
// Create some colors
$grey = imagecolorallocate($im, 128, 128, 128);
$white = imagecolorallocate($im, 250, 250, 250);
// The text to draw
if(!empty($_GET['name'])) {
$name = $_GET['name'];
}
$text = 'I fucking love you,';
// Replace path by your own font path
$font = 'AGENCYR.TTF';
$sw = imagesx( $im );
$box = imagettfbbox( 30, 0, $font, $text );
$bw = abs( $box[4] - $box[0] );
$bh = abs( $box[5] - $box[1] );
// Add some shadow to the text
$posX = ( $sw - $bw ) / 2;
imagettftext($im, 30, 0, $posX+1, 171, $grey, $font, $text);
// Add the text
imagettftext($im, 30, 0, $posX, 170, $white, $font, $text);
// Add some shadow to the text
$posX = ( $sw - $bw ) / 2;
imagettftext($im, 60, 0, $posX+1, 271, $grey, $font, $name);
// Add the text
imagettftext($im, 60, 0, $posX, 270, $white, $font, $name);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>