CorfuVBProgrammer Posted March 28, 2007 Share Posted March 28, 2007 Hello all readers . . . I need your help . . . I have create a class that manipulate jpeg images the source code is the following : <------------------------------------------------------------------> class image_manipulation { private $height; private $width; public $image; public function __construct() { $this->width = 0; $this->height = 0; } public function __destruct() { $this->width = 0; $this->height = 0; } public function setImageSize($img_tmp) { $img_info = getimagesize($img_tmp); $filetype = $img_info['mime']; $this->width = $img_info[0]; $this->height = $img_info[1]; return $this->manipulate_jpeg($img_tmp); } private function manipulate_jpeg($img) { $tmp_img = imagecreatefromjpeg($img); if($this->height > $this->width) { $h = (IMG_LRG_HEIGHT * 100) / $this->height; $newHeight = ($this->height/100) * $h; $newWidth = ($this->width/100) * $h; } else { $h = (IMG_LRG_WIDTH * 100) / $this->width; $newHeight = ($this->height/100) * $h; $newWidth = ($this->width/100) * $h; } $img2 = ImageCreateTrueColor($newWidth, $newHeight); @imagecopyresampled($img2, $tmp_img,0,0,0,0,$newWidth,$newHeight,$this->width, $this->height); $xx = imagesx($img2); $yy = imagesy($img2); $fontSize = 30; $fntWidth = @imagefontwidth($fontSize) * strlen(APP_TITLE); $fntHeight = @imagefontheight($fontSize); $fx = ($xx - $fntWidth) - 10; $fh = ($yy - $fntHeight) - 10; $txtColor = @imagecolorallocate($img2, 255, 255, 255); @imagestring($img2, $fontSize, $fx, $fh, APP_TITLE, $txtColor); $this->image = imagejpeg($img2); return $this->image; } } <------------------------------------------------------------------> Now that i have create this class and test it, it work correctly. The problem is the following. I like to store the image data to MySQL database. I know how to store in the database but when i execute the code the Internet Explorer represent the image and in the database it store only one byte. Why ? ? ? Following the database code : <------------------------------------------------------------------> $image_object = new image_manipulation(); $cnn = @mysql_pconnect(IP, USER, PASSWORD); @mysql_select_db(DATABASE_NAME); $query = "INSERT INTO " . TABLE_NAME . "(img_data) VALUES('" . $image_object->setImageSize(FILE_LOCATION) . "')"; <------------------------------------------------------------------> Thanks a lot . . . Quote Link to comment Share on other sites More sharing options...
CorfuVBProgrammer Posted March 28, 2007 Author Share Posted March 28, 2007 Any answer PLZ . . .. ? ? ? Quote Link to comment Share on other sites More sharing options...
CorfuVBProgrammer Posted March 28, 2007 Author Share Posted March 28, 2007 Please i need help . . . Somebody to help ? ? ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.