Tạo text image load font

1 718 0
Tạo text image load font

Đang tải... (xem toàn văn)

Thông tin tài liệu

Tạo text image load font

Tạo text image load font Hướng dẫn và code mẫu làm một image chứa text load font.view plainprint? 1. <?php 2. 3. $text = "Hello! PHP "; 4. $width = 200; 5. $height = 30; 6. $font = "Tahoma.ttf"; // Font file, phai load đúng tên, trên nền *nix phân biệt chữ hoa và chữ thường 7. $font_size = 12; 8. $top = 20; 9. $html_font_color = "#000000"; 10. $html_bg_color = "#ffffff"; 11. header("Content-type: image/jpeg"); 12. 13. $im = imagecreate($width,$height); 14. 15. // Lay hex color cua Font 16. $red_font = hexdec(substr( $html_font_color, 1 , 2)); 17. $green_font = hexdec(substr( $html_font_color, 3 , 2)); 18. $blue_font = hexdec(substr( $html_font_color, 5 , 2)); 19. 20. // Lay hex color cua Background 21. $red_bg = hexdec(substr( $html_bg_color, 1 , 2)); 22. $green_bg = hexdec(substr( $html_bg_color, 3 , 2)); 23. $blue_bg = hexdec(substr( $html_bg_color, 5 , 2)); 24. 25. $bg_color = imagecolorallocate($im, $red_bg,$green_bg , $blue_bg); 26. $text_color = imagecolorallocate($im,$red_font,$green_font,$blue_font); 27. 28. imagettftext($im, $font_size, 0, 0, $top, $text_color,$font,$text); 29. imagepng($im); 30. imagedestroy($im); 31. ?> . Tạo text image load font Hướng dẫn và code mẫu làm một image chứa text load font. view plainprint? 1. <?php 2. 3. $text = "Hello!. imagecolorallocate($im,$red _font, $green _font, $blue _font) ; 27. 28. imagettftext($im, $font_ size, 0, 0, $top, $text_ color, $font, $text) ; 29. imagepng($im); 30. imagedestroy($im); 31.

Ngày đăng: 11/09/2012, 14:32

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan