Jump to content

Somthink Deficault . . . (I think) ? ? ? Plz Hlp


CorfuVBProgrammer

Recommended Posts

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 . . . :D

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.