How to generate image from php script

php scripts anvar in

You can simply use the below code to generate the images in php. PHP isn’t limited to just generating HTML. It can also be used to create and manipulate image files in a variety of formats

It’s extremely easy to do with PHP. Admittedly the demo I’ve put together for this tutorial is rather extravagant! but it serves the purpose to explain how to use the PHP GD image library

<?php
$img = imagecreate( 300, 80 );
$bg = imagecolorallocate( $img, 255, 255, 255 );
$color = imagecolorallocate( $img, 0, 0, 0 );

imagestring( $img, 8, 40, 10, "NAME : ANVAR", $color );
imagestring( $img, 8, 40, 30, "WEBSITE: anvar.in", $color );
imagestring( $img, 8, 40, 50, "EMAIL: contact@anvar.in", $color );

header( "Content-type: image/png" );
imagepng( $img );
imagecolordeallocate( $color );
imagecolordeallocate( $bg );
imagedestroy( $img );
?>