Hello,
I created a nice (and simple for now) GD class.
The problem is , it works great on wamp, but not in my hostgator acount ( Linux )i tried it on byethost
and it didnt worked as well.
I am posting the class :
Code: <?php
/*
* Created by Eliad Moshe.
* Oranit 5,
* Israel.
*
* email: eliad154@Gmail.com
*
*/
class GD
{ // start of class GD
public $image_pointer , $color_pointer ;
function __construct ( $image_width, $image_height )
{ // start of function __construct ()
$this->image_pointer = imagecreatetruecolor ($image_width, $image_height);
} // end of function __construct ()
function set_color ( $color )
{ // start of function set_color ()
$color = substr( $color, 1 , 6 ); // get rid of "#"
$color = str_split( $color , 2 ); // make 3 chanks of 2 chars.
/* Red Green Blue */
$this->color_pointer = imagecolorallocate ( $this->image_pointer , "0x".$color[0] , "0x".$color[1] , "0x".$color[2] ) ;
} // end offunction set_color ()
function fill ($fill_x = 0 , $fill_y = 0)
{
imagefill ( $this->image_pointer , $fill_x, $fill_y , $this->color_pointer );
}
function add_string ( $text , $font_type , $location_x = 0 , $location_y = 0 , $method = 'h' )
{ // start of function function add_string ( )
if ($method == 'h')
{
imagestring ($this->image_pointer , $font_type, $location_x , $location_y, $text, $this->color_pointer );
}
else if ($method == 'v' )
{
imagestringup ($this->image_pointer , $font_type, $location_x , $location_y, $text, $this->color_pointer );
}
} // end offunction function add_string ( )
function add_ttstring ()
{ // start of function add_tstring ()
} // end of function add_tstring ()
// first and last
function set_line( $f_x , $f_y , $l_x , $l_y )
{ // start of function set_line()
imageline($this->image_pointer ,$f_x , $f_y , $l_x , $l_y , $this->color_pointer );
} // end of function set_line()
// first and last
function rect( $x , $y , $width , $height , $type = "fill" )
{ // start of function rect()
if ( $type == "fill" )
{
imagefilledrectangle($this->image_pointer ,$x , $y , $x + $width , $y + $height , $this->color_pointer );
}
else if ( $type == "border" )
{
imagerectangle($this->image_pointer ,$x , $y , $x + $width , $y + $height , $this->color_pointer );
}
} // end of function rect()
function create_image ($method = 'jpeg' , $create_file = NULL , $quality = 100 )
{ // start of function create_image ()
if ( $create_file != NULL )
{ // set the file name
$create_file = $create_file.".".$method ;
}
if ( $method == 'png' )
{
header ('Content-type: image/png');
header ('Content-Disposition: inline; filename = "myfile.png"');
imagepng ($this->image_pointer , $create_file , $quality );
}
else if ( $method == 'jpeg' )
{
header ('Content-type: image/jpeg');
header ('Content-Disposition: inline; filename = "myfile.jpeg"');
imagejpeg ($this->image_pointer , $create_file , $quality );
}
imagedestroy ($this->image_pointer);
} // end of function create_image ()
} // end of class GD
?>
example of use:
Code: <?php
// /public_html/emp/
include ('GD.php');
$object = new GD (400,400);
$object->set_color ("#976686");
$object->fill ();
$object->set_color ("#999999");
$object->add_string('hello',5,50,50);
$object->create_image('jpeg');
?>
In wamp the picture is ok how ever on the remote servers it is black.
Thanks for the help
Array disappearing in foreach loop
Okay, I have this problem where an array will become undefined in a foreach loop.Here is the function plus a couple comments:Code: [Select]function mineResources($nation) {global $db;$resources =
onClick='location.href=index.htm'> not working
Below is my code:echo "<input type='button' value='redirect' onClick='location.href=index.htm'>";what is wrong with the code?? it's not working
How to assign a textbox value to PHP variable??
Hi ! Can any one help me out as quickly as possible. As I m new to PHP.Plz tell me how to assign a textbox value to PHP variable on a same PHP page with out POSTING data to other page e.g:$tbVal =
PHP & Java
Hello,can PHP code be used inside java code?Code: [Select]<SCRIPT LANGUAGE="JavaScript">OpenWindow.document.write("<?php echo NotWorking;
Custom CMS
This is a big custom CMS script I'd like to develop and would like some help atleast figuring out where the best place to start would be.Website PagesBackstage 2 provides website pages for the
Date help - fetch dates for Mondays between xxx and yyy?
Does anyone know the best way to do this? I have two dates, say:2010-01-26 and 2010-05-30and I want to return the dates of all the Mondays between them:2010-02-012010-02-082010-02-15....etc.Thanks
How to return to a previous page after running a PHP script
I'm having a bit of a melt down here because I think this should be really easy but can't work it out...!My page lists the records in my database and next to each record is a 'Delete' button. What I
Creating web pages by php
Hello again,I was just wondering us there a way to use a php script to create a new web page. I guess the best example is something like YouTube where when a video is uploaded, it's assigned a new
PHP - HTML
Could anyone give me some GOOD sample links for php - html email tutorial.Thanks!
turning an array into a string then poping it into a db
Hi im just wondering how you get a requested array into a single string then pop it into the db so far i gotprint_r($_REQUEST['choice_name']);whch echosArray ( => Colour=Blue [1] =>