daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $text = 'I feel dirty with those borders';
  3. $color = array( 255, 128, 0);
  4. $font = 'arial.ttf';
  5. $size = 44;
  6.  
  7. // Create the image
  8. $testImg = imagecreatetruecolor(20, 20);
  9. $testCol = imagecolorallocate($testImg, $color[0], $color[1], $color[2]);
  10. $rect = imagettftext($testImg, $size, 0, 0, 0, $testCol, $font, $text);
  11. $width = $rect[4] - $rect[0] + 2;
  12. $height = $rect[1] - $rect[5];
  13. $yOffset = -$rect[5];
  14.  
  15. imagedestroy($testImg);
  16.  
  17. $img = imagecreatetruecolor( $width, $height);
  18. imageantialias ( $img, true);
  19. $black = imagecolorallocate($img, 0, 0, 0);
  20. imagecolortransparent($img, $black);
  21. $col = imagecolorallocate($img, $color[0], $color[1], $color[2]);
  22. $rect = imagettftext($img, $size, 0, -1, $yOffset, $col, $font, $text);
  23. imagepng($img, "test.png");
  24. imagedestroy($img);
  25.  
  26. ?>
  27. <html>
  28. <body bgcolor="ffFFa0">
  29. <img src="test.png" />
  30. </body>
  31. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top