Jump to content


Photo

Easy question


  • Please log in to reply
4 replies to this topic

#1 philaphi

philaphi
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 12 August 2006 - 10:21 AM

I've following php code. It creates an image and saves in the filesystem. Now I want to show on browser.
Do I need to write an html code for this or how can i do ?.
thanks,

<?php

header("Content-type: image/png"); 
require_once("GraphicsEnvironment.php5");

$ge = new GraphicsEnvironment( 400, 400 );

$ge->addColor( "black", 0, 0, 0 );
$ge->addColor( "red", 255, 0, 0 );
$ge->addColor( "green", 0, 255, 0 );
$ge->addColor( "blue", 0, 0, 255 );

$gobjs = array();
$gobjs []= new Line( "black", 10, 5, 100, 200 );
$gobjs []= new Line( "blue", 200, 150, 390, 380 );
$gobjs []= new Line( "red", 60, 40, 10, 300 );
$gobjs []= new Line( "green", 5, 390, 390, 10 );

foreach( $gobjs as $gobj ) { $gobj->render( $ge ); }

$ge->saveAsPng( "test.png" );

?> 

#2 Guest_huey4657_*

Guest_huey4657_*
  • Guests

Posted 12 August 2006 - 10:40 AM

I think the basic framework goes like this.

<?php your php ?><html><head><title>title goes here</title></head><body><p><img src="Test.png" alt = "test image" width = "400" height = "400"></p></body></html>

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 12 August 2006 - 12:02 PM

@huey- that's wrong.

You need to save the code above in a file, let's pic.php.
Then when you want to show, add to the html:
<img src="pic.php">

Orio.
Think you're smarty?

(Gone until 20 to November)

#4 Guest_huey4657_*

Guest_huey4657_*
  • Guests

Posted 12 August 2006 - 12:07 PM

Sorry, I thought php code created an image file called test.png

#5 Chetan

Chetan
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts
  • LocationIndia

Posted 12 August 2006 - 02:53 PM

It does
I am a PHP Guru, ask me questions if you want to




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users