Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $text = 'I feel dirty with those borders';
- $color = array( 255, 128, 0);
- $font = 'arial.ttf';
- $size = 44;
- // Create the image
- $testImg = imagecreatetruecolor(20, 20);
- $testCol = imagecolorallocate($testImg, $color[0], $color[1], $color[2]);
- $rect = imagettftext($testImg, $size, 0, 0, 0, $testCol, $font, $text);
- $width = $rect[4] - $rect[0] + 2;
- $height = $rect[1] - $rect[5];
- $yOffset = -$rect[5];
- imagedestroy($testImg);
- $img = imagecreatetruecolor( $width, $height);
- imageantialias ( $img, true);
- $black = imagecolorallocate($img, 0, 0, 0);
- imagecolortransparent($img, $black);
- $col = imagecolorallocate($img, $color[0], $color[1], $color[2]);
- $rect = imagettftext($img, $size, 0, -1, $yOffset, $col, $font, $text);
- imagepng($img, "test.png");
- imagedestroy($img);
- ?>
- <html>
- <body bgcolor="ffFFa0">
- <img src="test.png" />
- </body>
- </html>
Add Comment
Please, Sign In to add comment