FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP MySQL Image loading





danway60
Is there a way to load an image from the database using the URL stored in the database?
I also need to resize the image once it's loaded.


Thanks, Dan.
rvec
for resizing:
http://icant.co.uk/articles/phpthumbnails/

as for loading the image, is the image or the url stored in the database?
danway60
The URL of the image:
Code:
http://gamecity.frihost.net/Games/Driving/adren/adren.jpg
rvec
use a select and then put the url in html like you'd normaly do.
Code:
$ query = 'SELECT URL FROM images WHERE id='.$id;
...
echo '<img src="'.$row[0]['URL'].'" alt="image" />';

Something like that probably
albuferque
Also you can resize the image on the fly with:


echo "<img src=' ". $row['URL'] . " ' width='200' height='150'>";

The size attributes define the width and height of the image. Resizing is a good idea since it helps the browser arrange the page more quickly.
rvec
resizing that way would use the same amount of bandwidth as using the full image would.
kv
albuferque wrote:
Also you can resize the image on the fly with:


echo "<img src=' ". $row['URL'] . " ' width='200' height='150'>";

The size attributes define the width and height of the image. Resizing is a good idea since it helps the browser arrange the page more quickly.


The above does not resize the image, it just resizes the display of image in the browser. The browser would have downloaded the full size image. It does NOT help browser render page faster.

It is always a good idea to create resized images and store it in the server.
albuferque
You are right , he's got to resize images. Use some thumbnail creator.
sonam
albuferque wrote:
Also you can resize the image on the fly with:


echo "<img src=' ". $row['URL'] . " ' width='200' height='150'>";

The size attributes define the width and height of the image. Resizing is a good idea since it helps the browser arrange the page more quickly.


I don't care about bandwitch because it is quite cheap now and creating of thumbs, storing it, handle it, etc. is unnecessary job if is images good optimised for web. Only if your images are heavy (more then 500kb), and you want to keep this Kb-s, then is good to create thumbs.

But albuferque resizing is not correct because this code will display all images absolutely same instead of using calculation of original width and height and then independent what is bigger create correct preview.

Sonam
rockacola
sonam wrote:
albuferque wrote:
Also you can resize the image on the fly with:


echo "<img src=' ". $row['URL'] . " ' width='200' height='150'>";

The size attributes define the width and height of the image. Resizing is a good idea since it helps the browser arrange the page more quickly.


I don't care about bandwitch because it is quite cheap now and creating of thumbs, storing it, handle it, etc. is unnecessary job if is images good optimised for web. Only if your images are heavy (more then 500kb), and you want to keep this Kb-s, then is good to create thumbs.

But albuferque resizing is not correct because this code will display all images absolutely same instead of using calculation of original width and height and then independent what is bigger create correct preview.

Sonam


Besides bandwidth, quality of your displayed image will also be poor when rendered in browser (especially IE). You also need to have a mechanism to resize your image in ratio.

If you are a code digger, I'll recommand have a look on how WordPress store your images in database.
sonam
Quote:
Besides bandwidth, quality of your displayed image will also be poor when rendered in browser (especially IE). You also need to have a mechanism to resize your image in ratio.

That is exact what I mean. I am not talking about direct rendering using height and width in browser. Good optimised image can simple php script to resize in nice thumb without saving it in some folder.

Sonam
BlueVD
Depending on where the images are stored, you can resize them using the GD library functions. If I'm not mistaking you can open directly a non local image if fopen wrappers have been enabled in the php.ini config file.
Just use imagecreatefromjpeg or other gd functions... Afterward, the resizing is easily achieved through GD functions.
Related topics
PHP, MySQL...
ASP +PHP+MySQL Tutorials
what is your php mysql apache installer package
Need some php/mysql dlls
The Basics (php, mysql etc)
What is useful way in this php+mysql problem?
PHP/Mysql - beginner!
A very good PHP MySQL Tutorial
Setup php,mysql and others...
php, mysql and iis5
 EASY 40 frih$ IF YOU KNOW PHP+MySQL 
Php Mysql security testing
Project to join - php,mysql??
Way to make money? php/mysql
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.