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 1 1174
CorfuVBProgrammer wrote:
class image_manipulation
{
private $height;
private $width;
public $image;
public function __construct()
{
$this->width = 0;
$this->height = 0;
}
This is fairly useless.
public function __destruct()
{
$this->width = 0;
$this->height = 0;
}
This is entirely useless.
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);
}
Considering the main purpose of this function (i.e. to get a manipulated
copy of the image) the above function is bizarrely named.
<snip rest of class definition>
$query = "INSERT INTO " . TABLE_NAME . "(img_data) VALUES('" .
$image_object->setImageSize(FILE_LOCATION) . "')";
You need to escape the result of $image_object->setImageSize using, for
example, mysql_real_escape_string.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ben Hall |
last post by:
Hey guys,
I'm building a web application in php for the first time (I like php a
lot..) and have come across a litle stumbling block.
I want to access a passed url parameter with...
|
by: julio |
last post by:
Sorry but there is no another way, c# .net and mono are going to rip
python, not because python is a bad lenguage, but because is to darn old
and it refuses to innovate things, to fix wrong things,...
|
by: francisl |
last post by:
We have to build some script were I work to make a dynamic server inventory.
But, the project team, a windows crew, start it all in vbscript and on
mssql. Note, due to political reason, we can...
|
by: Boris Glawe |
last post by:
Hi,
I am going to write a client/server based application with for Linux in C++. I
am programming C++ on purpose.
There are many tutorials out there how to create a new socket, and receive and...
|
by: VB6 User |
last post by:
Hi all devies!
Many (.NUT, .NOT or whatever), APIs, VB6, Views & Questions
Your can not call APIs directly in .NET, only via P/Invoke. There are some
things that cannot be done in...
|
by: dnux67 |
last post by:
How could I affect the system function return value to a scalar?
Like if i do this
$folder="/home/user/data"
system "du -s $folder" # How could i get this return value into a scalar
Thank...
|
by: Alakhim Mohamad |
last post by:
I now have a client and a server accepted connection
Here is the code that server accept message from client after connect
try{
TcpClient client=new Tcpclient(add,port);
bytes by=new bytes;...
|
by: CorfuVBProgrammer |
last post by:
I have create a very simple program in my Visual Basic 2005 Pro.
I retrive some records from my database and then i have bind some text
fields to that data.
When the application starts then...
|
by: kopuk1234 |
last post by:
Hi, every one, this is the first time I am using this and any other form and I am also new in Web Design Technologies but usualy quite good in Designing a Web Page or Site if I really need to.
And...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |