Author Topic: Create image in runtime PHP: imagegif()  (Read 5437 times)

Offline admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 296
    • View Profile
Create image in runtime PHP: imagegif()
« on: January 24, 2011, 01:34:07 PM »
Sometimes we need to create an image in runtime without saving, just to display text or numbers that is usually used in the human verification.
it's very easy to use the following code and save it in a php file, say "image.php" then you can use this file as an image in your HTML code.

Code: [Select]
<?php

// Create a new image instance
$im imagecreatetruecolor(100100);

// Make the background white
imagefilledrectangle($im0099990xFFFFFF);

// Draw a text string on the image
imagestring($im34020'GD Library'0xFFBA00);

// Output the image to browser
header('Content-type: image/gif');

imagegif($im);
imagedestroy($im);

?>