PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Lukas Macura  >  phpimage  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example showing more images generated with single script
Class: phpimage
Generate images output and HTML to insert in pages
Author: By
Last change: Exxample simplified by using clone()
Date: 13 years ago
Size: 2,384 bytes


Class file image Download

// Example to show some image capabilities.
// More images in one script ! :)
// And you can use echo and html in your script.
// SVG output is disabled in example by default because
// you must have SVG class installed first.
// See
// You must replace SvgDocument in svg class package with
// file included in this bundle.


// Let's create some png image
$png = new PhpImage("png",320,200);
// This line must be here. This is called when browser want's to load raw image data
// Please leave it here to make example working. You need only ONE instance of this function
// in page even if you have more images generated. (doesn't matter what output type)

// Now we demonstrate that we are still in HTML context, we can put any html tags here.
echo "<table align=center border=1><tr><td>\n";

// Allocate some colors
$white = $png->ColorAllocate(255,255,255);
$red = $png->ColorAllocate(255,0,0);
$blue = $png->ColorAllocate(0,0,255);
$green = $png->ColorAllocate(0,255,0);
$black = $png->ColorAllocate(0,0,0);

// Let's make one white big box

// Filled arc..

// Filled rectangle
for ($i=1;$i<30;$i++) {

// Line
for ($i=1;$i<30;$i++) {

// Write some text
$png->String(1,20,20,"Test text 1",$red);
$png->String(2,20,40,"Test text 2",$white);
$png->StringUp(3,0,90,"Test text 3",$blue);
$png->String(5,70,100,"PHPImage sample output (png)",$black);



// And do same stuff again...
// But choose another output on same page

echo "<tr><td>";




// And SVG stuff..