Help - Outputting Thumbnails

Help - Outputting Thumbnails

am 28.06.2006 06:15:10 von nickwired

Hello PHP Pros -

A novice like myself has one question :

I have a few images users uploaded to a mySQL database. How can I out
them as thumbnails.

Any help would be appreciated.


Thanks !

-n

Re: Help - Outputting Thumbnails

am 06.07.2006 16:39:26 von aaron.reese

as far as i'm aware you can'. Thumbnails were originally designed for
previews on slow 14k dial up connections where you might not want to
wait for the full size image to download.

You can make the image show as a thumbnail by setting the height and
width properties of the tag.

frothpoker

Re: Help - Outputting Thumbnails

am 07.07.2006 15:06:44 von Rik

aaron.reese@tiscali.co.uk wrote:
> as far as i'm aware you can'. Thumbnails were originally designed for
> previews on slow 14k dial up connections where you might not want to
> wait for the full size image to download.

Even with a fast connection I don't think pages with >10 >300k images
charming.

> You can make the image show as a thumbnail by setting the height and
> width properties of the tag.

Which is very bad practise.
Make you images the sizes they should be.
Making them smaller in an HTML page by setting width & height:
- Makes you download an unneccesary large image.
- Makes an ugly image because browser resizing isn't what is could be.
- width & height are originally designed to hint to the browser what the
dimensions are, so the page is rendered correctly before downloading the
images, and doesn't change oncethe images are in.

Make a thumbnail on the fly (or store them) using imagecopyresampled().

Grtz,
--
Rik Wasmus

Re: Help - Outputting Thumbnails

am 07.07.2006 17:31:33 von nc

nickwired wrote:
>
> I have a few images users uploaded to a mySQL database.
> How can I out them as thumbnails.

Get the image from the database and use imagecopyresampled() to reduce
it.

http://www.php.net/imagecopyresampled

Additionally, consider storing thumbnails in the database along with
original images. Generating thumbnails dynamically is expensive in
terms of CPU usage. Many applications generate thumbnails as a part of
image upload procedure.

While you are in the considering mode, consider not storing images in
the database at all. Since not all browsers out there support data="*"> tag, you need a separate script (and, hence, a separate
database connection) to render each image. So a page with five images
on it would create six database connections, which could have dire
performance consequences for a high-traffic Web site.

Cheers,
NC