Re: pictures stored in PostgreSQL DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2007-03-03 at 11:02 +0100, Alain Roger wrote:
> I know how to do that for 1 picture. But i want to display the pictures as
> thumbnail... so several pictures on the same PHP pages, with some texts.
> therefore, your solution does not correspond to what i need.

You need two scripts. One script that contains the <img> tags to your
thumbnails, and another script that creates the thumbnails (possiblies
caches them), sets the appropriate header (Content-Type: image/xxx --
where xx is png or jpeg or gif or ...) and then flushes the image binary
content to the browser. You will also need to make use of the image
functions in PHP to create your thumbnail. Here are some links:

    http://ca.php.net/manual/en/function.header.php
    http://ca.php.net/manual/en/function.imagecreatefromstring.php
    http://ca.php.net/manual/en/function.imagecopyresampled.php

Let say you create two scripts... gallery.php and showImage.php. Then
gallery.php will output content something like:

<html>
<head></head>
<body>
    <img
src="showImage.php?id=123&amp;width=60&amp;height=60&amp;hash=KJHDKJHDKJHKDJHDJKHDKJHDJK" />
    <img
src="showImage.php?id=124&amp;width=60&amp;height=60&amp;hash=KJHDKJHDKJHKDJHDJKHDKJHDJK" />
    <img
src="showImage.php?id=125&amp;width=60&amp;height=60&amp;hash=KJHDKJHDKJHKDJHDJKHDKJHDJK" />
    <img
src="showImage.php?id=126&amp;width=60&amp;height=60&amp;hash=KJHDKJHDKJHKDJHDJKHDKJHDJK" />
</body>
</html>

This way you can provide the dimension information to the showImage.php
script as width and height and it can create a thumbnail with those
constraints. I always ad a hash for that kind of script so that users
can't arbitrarily load images at any size they want. The hash is usually
an md5() hash of the id, width, height, and some private salt string.
This also makes it unlikely they could load an arbitrary image ID.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux