PHP Codes for drawings

As i previously typed on my iPhone, i was working on PHP drawings

Let’s start with the php tag and change the output

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

Then we’ll draw the canvas!

$im = imagecreatetruecolor(500,500);
$white = imagecolorallocate($im, 255, 255, 255);

Due to the fact that most of the following codes are for my client’s site, i’ll continue using codes from NGPriest.com

$image = imagecreatefromjpeg('file.jpg');

Then we set up 4 strings

$string1 = $time_span['Days'].' Days, '.$time_span['Hours'].' Hours, ';
$string2 = $time_span['Minutes'].' Minutes, '.$time_span['Seconds'].' Seconds.';
$string3 = 'JoeyLau.com';
$string4 = 'NGPriest.com';

Let’s finish by chucking everything on the canvas and letting PHP publish the image

$black = imagecolorallocate($im, 181, 213, 239);
imagefttext($im, 24, 0, 244, 25, $black, $font_file, $string1);
imagefttext($im, 24, 0, 244, 75, $black, $font_file, $string2);
imagefttext($im, 24, 0, 350, 125, $black, $font_file, $string3);
imagefttext($im, 24, 0, 350, 165, $black, $font_file, $string4);
imagepng($im);imagedestroy($im);
?>

Leave a Reply