Anvar Logo
01 / 01
Anvar Logo +91 808 999 0405

How to generate image from php script

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 );
?>

 

by anvar
Published : Oct , 13

Post a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.