eliad Posted November 7, 2009 Share Posted November 7, 2009 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 : <?php /* * Created by Eliad Moshe. * Oranit 5, * Israel. * * email: [email protected] * */ 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: <?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 Link to comment https://forums.phpfreaks.com/topic/180701-a-problem-with-my-gd-class/ Share on other sites More sharing options...
Cardale Posted November 7, 2009 Share Posted November 7, 2009 Not sure if you checked, but was it enabled and what were the version numbers? Link to comment https://forums.phpfreaks.com/topic/180701-a-problem-with-my-gd-class/#findComment-953375 Share on other sites More sharing options...
eliad Posted November 7, 2009 Author Share Posted November 7, 2009 this is my wamp-gd details - apache server ver- 2.2.11 , php ver 5.3.0 gd GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.3.9 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version 6b PNG Support enabled libPNG Version 1.2.37 WBMP Support enabled XBM Support enabled Directive Local Value Master Value gd.jpeg_ignore_warning 0 0 and this is the hostgator-gd details , apache server 2.2.11 , php - 5.24 gd GD Support enabled GD Version bundled (2.0.34 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.2.1 GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XPM Support enabled XBM Support enabled Link to comment https://forums.phpfreaks.com/topic/180701-a-problem-with-my-gd-class/#findComment-953379 Share on other sites More sharing options...
eliad Posted November 9, 2009 Author Share Posted November 9, 2009 Can someone help? Link to comment https://forums.phpfreaks.com/topic/180701-a-problem-with-my-gd-class/#findComment-954018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.