How I deal with images and resizing is by uploading the image to the server,
and at that time creating a thumbnail. I have the /images folder with a
/thumbs folder inside it for the thumbnails.

The database simply refers to the name of the image and it's ID and other
associations.

This is optimal for most web uses for many reason:

* Shorter DB access time
* Not processing expensive GD functions on every image load
* Don't have to worry about passing the proper content header

As for "printing the HTML size of the image", if you pass "width=300" to
your script, simply create your print statement similar to:

print "<img src='image.php?id=1' width='$width'>";

Though if image ID 1 is a LARGE image, then you'll still load the entire
image, even though it's being resized to 300px wide. It's not overly
bandwidth friendly if you have large images that are still being sent from
your server (another reason that keeping local thumbnails are a good idea).

Disk space is relatively cheap. Bandwidth is still more of a commodity.

-Mike

-----Original Message-----
From: Sebastian [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 29, 2003 12:58 AM
To: php list
Subject: [PHP] possible?


hello,

I have some images in mysql, currently the images aren't resize, and this
displays the image, like: image.php?id=1

But i'd like to resize the image with html tags: e.g. width="300" and
print/echo it.

since Content-type is for image is it even possible? If not then how about
dynamically resizing them such as:
image.php?id=1&width=300   is that possible? If so, please let me know how.

Thanks in advanced.

cheers,
Sebastian

<?php
$conn = mysql_connect("host", "root", "pass") OR DIE (mysql_error());
        @mysql_select_db("images", $conn) OR DIE (mysql_error());

$sql = ("SELECT * FROM images WHERE id = '$_GET[id]'");
$result = mysql_query($sql, $conn);

if (mysql_num_rows ($result ) > 0)
 {
 $row = @mysql_fetch_array($result);
 $image_type = $row['type'];
 $image = $row["image"];
 header ("Content-type: $image_type");
 print $image;
}
?>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to