This post will guide you to convert the text into image.
Requirement: You need to ensure, that the hosting has enabled GD library (in a new php file, execute phpinfo(); and in output see/find if GD library is enabled) .
The GD library offers tons of cools way to dynamically create PNG, JPEG or GIF files and output them directly to your browser,
You can check to see if the GD library available on your server by placing the code:
1 |
<?php phpinfo(); ?> |
The below code is to generate png image from text.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?php // Set the content-type header('Content-Type: image/png'); // Create the image $im = imagecreatetruecolor(400, 200); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 400, 200, $white); // The text to draw $text = 'Tangle SKills'; // Replace path by your own font path $font = 'Arial.ttf'; // Add the text imagettftext($im, 10, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> |
That’s it, now you can convert the text into image.
If you are satisfied, please like and share our website and posts. In case any suggestion/question, please contact us using contact form.
Thank you