You are here: Litle Problem . . . . Help Plz . . . :D « PHP Programming Language « IT news, forums, messages
Litle Problem . . . . Help Plz . . . :D

Posted by CorfuVBProgrammer on 03/28/07 07:18

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация