[dba-Tech] So how do you automate imaging?

Stuart McLachlan stuart at lexacorp.com.pg
Fri Sep 10 23:32:28 CDT 2010


On 11 Sep 2010 at 14:06, Stuart McLachlan wrote:

> A quick look at  http://www.php.net/manual/en/ref.image.php shows that
> it doesn't just manipulate existing images, it lets you create images
> with text, line, arc etc functions so you could use it to create
> graphs/charts on the fly in your web page from various data sources.
> 

Just tried one of the examples, it's really neat.  
  
The entire contents of the file
http://www.lexacorp.com.pg/imagetest.php  follows, take a look at the result.

-- 
Stuart


<?php
// create image
$image = imagecreatetruecolor(100, 100);
// allocate some colors
$white    = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$gray     = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
$darkgray = imagecolorallocate($image, 0x90, 0x90, 0x90);
$navy     = imagecolorallocate($image, 0x00, 0x00, 0x80);
$darknavy = imagecolorallocate($image, 0x00, 0x00, 0x50);
$red      = imagecolorallocate($image, 0xFF, 0x00, 0x00);
$darkred  = imagecolorallocate($image, 0x90, 0x00, 0x00);
// make the 3D effect
for ($i = 60; $i > 50; $i--) {
   imagefilledarc($image, 50, $i, 100, 50, 0, 45, $darknavy, IMG_ARC_PIE);
   imagefilledarc($image, 50, $i, 100, 50, 45, 75 , $darkgray, IMG_ARC_PIE);
   imagefilledarc($image, 50, $i, 100, 50, 75, 360 , $darkred, IMG_ARC_PIE);
}
imagefilledarc($image, 50, 50, 100, 50, 0, 45, $navy, IMG_ARC_PIE);
imagefilledarc($image, 50, 50, 100, 50, 45, 75 , $gray, IMG_ARC_PIE);
imagefilledarc($image, 50, 50, 100, 50, 75, 360 , $red, IMG_ARC_PIE);
// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>






More information about the dba-Tech mailing list