What is Gd PHP?

devquora
devquora

Posted On: Feb 22, 2018

 

GD is an open source library for creating dynamic images.

  • PHP uses GD library to create PNG, JPEG and GIF images.
  • It is also used for creating charts and graphics on the fly.
  • GD library requires an ANSI C compiler to run.

Sample code to generate an image in PHP

<?php
	header("Content-type: image/png");

	$string = $_GET['text'];
	$im = imagecreatefrompng("images/button1.png");
	$mongo = imagecolorallocate($im, 220, 210, 60);
	$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
	imagestring($im, 3, $px, 9, $string, $mongo);
imagepng($im); imagedestroy($im); ?>

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    PHP Interview Questions

    What is T_PAAMAYIM_NEKUDOTAYIM in PHP?

    T_PAAMAYIM_NEKUDOTAYIM is scope resolution operator used as :: (double colon) .Basically, it used to call static methods/variables of a Class...

    PHP Interview Questions

    What is the difference between == and === operator in PHP ?

    In PHP == is equal operator and returns TRUE if $a is equal to $b after type juggling and === is Identical operator and return TRUE if $a is equal to $b, and they are of the same data type...