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
can i optmize image to 50% quality before uploading 2 server
Hi therei have jus written a php program to upload and display images but when i try to upload them it takes a long time to upload if the file is big. But the big problem is when i try to display
reading xml faster than DB call?
I am trying to optimize a high traffic website, and I enabled a feature where there are three photos selected from the most recently submitted ones, and displayed at the top of the page. I figured
Preloading images
Posting this question here because I am not sure where this should belong.I am building an asp.net ajax web site with lots of media elements and I would like to make my image loading work smoother. I
If a form submits back to same page do you need to use $get
IM trying to pass page number and year that was selected back to the same page.i have this code Code: echo '<form action="archivedBookings.php" method="get">';
firefox wouldnt stream mp3 files completely from my php page
hi everyone,I have a php file trying to read and stream mp3 files. It works fine in IE but my problem is Firefox streams only 3 seconds of them.$direction =
PEAR in appliactiond development
When I was picking up PHP I went from procedural programming, fairly quickly into OOP, then after writing a bunch of custom libraries and applications I discovered CodeIgniter. I pretty much
checkbox update
I am having a brain fart right now and i cant remember how to do this. if anyone could help that would be great. I have search google and this forum but have not found what i am looking for.thankswhen
Form always sends to error page...
Hello,Any help will be greatly appreciated. I am having trouble getting multiple fields to be required, and with the if multiple errors section. I think that's where the problem is. When I click
Strange Oracle Query problem
Ok So I have this PHP class that talks to a Javascript class that basically creates a table of information from a database query and puts it in a sortable, filterable table. This all works fine and
getAlexaRank($url) function not working
I have made a function to get alexa rankthe site is here: http://mytestsite.rack111.com/1but the Alexa rank is showing up blank and I dont know why can someone please tell me if there is something