Re: create multiple jpg thumbnails and use in a page

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

 



Kevin Coyner wrote:
From php.net, I've found plenty of examples of how to create thumbnails
from files and have done a couple successfully.  My objective, however,
is to have a page dynamically create multiple thumbnails from full sized
images.  I don't want to be creating and saving thumbnails to be used
later.

Possible?  If so, then please just a pointer in the right direction.

Thanks, Kevin

Without going into too much detail, you just need to use one of the examples you found on PHP.net to create the thumbnail, and then rather than calling something like:


imagejpeg('filename.jpg');

once you've created the thumbnail, call this instead:

header('Content-Type: image/jpeg');
imagejpeg();

That will output the jpeg image to the browser. Obviously this would be in a separate file called from the main script in an img tag, like:

<img src="thumbnail.php?file=some_file_name.jpg" />

A couple of pointers:

1. You'd want to do input checking on the file GET variable to ensure no-one could get hold of stuff they shouldn't.

2. Make sure you don't output anything else in the file that outputs the thumbnail, or it won't work.

HTH -- if you need more specifics let me know.

--
Jasper Bryant-Greene
Cabbage Promotions
www:	www.cabbage.co.nz
email:	jasper@xxxxxxxxxxxxx
phone:	021 232 3303

Public Key: Jasper Bryant-Greene <jasper@xxxxxxxxxxxxx> keyID 0E6CDFC5
Fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5

--
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