Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. if(!isset($_GET['text'])) {
  4.         echo 'Error';
  5.         exit;
  6.     }
  7.     $pic_name = $_GET['text'];
  8.     $img = imagecreatefrompng ("../imgsource/trikotblank.png");
  9.     $text_color = imagecolorallocate($img, 255, 255, 255);                  //  Schriftfarbe
  10.     $font_file = "../fonts/masque.TTF";                          // Schriftart
  11.     $font_size = 12;                                                         // Schriftgröße
  12.     $text_x = 10;                                                           //  Pos X
  13.     $text_y = 117;                                                          //  Pos Y
  14.     imagettftext($img, $font_size, 0, ImageTTFCenter($img,$_POST['text'],$font_file,$font_size), $text_y, $text_color, $font_file, $_POST['text']);
  15.     imagepng($img, '../images/user/'.$pic_name.'.png');
  16.     //imagedestroy($img);
  17.     //echo "https://$_SERVER[HTTP_HOST]trikotprinter/images/user/$pic_name.png";
  18.     function ImageTTFCenter($image, $text, $font, $size, $angle = 0)
  19.     {
  20.         $xi = imagesx($image);
  21.         $box = imagettfbbox($size, $angle, $font, $text);
  22.         $xr = abs(max($box[2], $box[4]));
  23.         $x = intval(($xi - $xr) / 2);
  24.         return $x;
  25.     }  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement