Creating image from text is one of the basic skill for PHP developers. It is very easy task. To do this we need to use a True Type Font (TTF) and PHP GD library installed in system. Here I am going to show you a simple imagettftext example.
The PHP Code:

The PHP Code:
function text_to_image($text){ // Set ttf font path $font = 'path/to/font.ttf'; // Font size in px $size = 70; // Set Content Type header("Content-Type: image/png"); // Create true color virtual image 200x50 px $image = imagecreatetruecolor(500, 200); // True type background Color $white = imagecolorallocate($image, 255, 255, 255); // True type text Color $black = imagecolorallocate($image, 0, 0, 0); // Set background color imagefilledrectangle($image, 0, 0, 499, 199, $white); // Write text over image imagettftext($image, $size, 0, 22, 75, $black, $font, $text); // Create png image imagepng($image); // Clean memory imagedestroy($image); }Usage
text_to_image("Hello World!");
Doesn't work
ReplyDeleteI take that back, it works
ReplyDeletedich vu ke toan thue dich vu lam bao cao tai chinh tín
ReplyDeletekhóa học kế toán thực hành re
cong ty dich vu ke toan
dich vu ke toan tai bac ninh
dịch vụ kế toán trọn gói giá rẻ
dịch vụ kế toán tại tp.hcm
dịch vụ báo cáo thuế
dịch vụ quyết toán thuế uy
học kế toán tại tphcm
học kế toán tại cầu giấy tín
học kế toán tại long biên
học kế toán tại hà đông re
học kế toán tại thanh xuân
học kế toán tại bắc ninh
học kế toán tại bình dương
học kế toán tại hải phòng
dịch vụ thành lập doanh nghiệp công ty trọn gói
dịch vụ thành lập doanh nghiệp công ty tại bắc ninh
dịch vụ quyết toán thuế tại quận 5
dịch vụ quyết toán thuế tại quận 3
dịch vụ quyết toán thuế tại tphcm
dịch vụ quyết toán thuế tại quận cầu giấy
dịch vụ quyết toán thuế tại quận long biên
dịch vụ quyết toán thuế tại quận hà đông
dịch vụ quyết toán thuế tại quận thanh xuân
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeletePHP Training in chennai | PHP Training Course
PHP Training in chennai | Online PHP Course