Welcome to WebmasterWorld Guest from 54.242.63.214

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Is it possible to create image thumbnails server-side?

Using PHP, either on the fly or on upload or ...?

     

louponne

3:02 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm working on a site that will include multiple images, jpegs of undoubtedly large file size, and we'd like to offer up thumbnails first. Is there any way to create the thumbnails server-side? Either on-the-fly but I'm thinking that might put a large load on the server if we start getting lots of hits, or when the image file is uploaded, or, say, as a batch job once a week? The site is PHP/MySQL.

Birdman

3:27 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is a great reference for PHP [php.net] image [php.net] functions. There is a thumbnail creation example in the user notes.

louponne

4:25 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the rapid response, Birdman! Yes, I had found that referenc in the PHP manual. I'm a *relative* newbie to PHP scripting (I've put up half-a-dozen simple db based sites thus far). This site is on an outside host so I don't control the server. Is the "GD library" mentioned in the manual something that has to be pre-installed in the configuration on the server, or can I install it within my "account" on this host to get this to work?

jatar_k

4:51 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



on the server, your host would have to set it up for you if it isn't already.

You could always try gd_info() [php.net] or phpinfo() [php.net]

Jocelyn

4:58 pm on Mar 21, 2003 (gmt 0)

10+ Year Member



louponne, if your hosting service doesn't have PH with GD installed, you cannot install install it yourself (unless you've admin access to the server).
the PHP functions using GD are very powerful and allow you to do lots of things once you manage to understand their use.
It's not always obvious at the begininning, but looking at the examples will help you.
I don't recommand you use on-the-fly image generation, especially with large files because it will put a high load on the server, and it is unnecessary to re-create thumbnails again all the time. Your jpeg files aren't going to change at every request!

I have a website with a photo album. After I've uploaded new pictures, I run a script that creates and saves to disk thumbnails for all new pictures. The same script is run once a day by night, in case I forgot to create some thumbnails.

Jocelyn

Romeo

5:04 pm on Mar 21, 2003 (gmt 0)

10+ Year Member



AFAIK the GD support has to be configured during PHP installation.
Just try a simple GD function -- if you get no error but a result, everything should work fine.
You may also try a <?php phpinfo();?> which will show you a long list of all features and parameters of the PHP on your server.
If you will find a '--with-gd=yes' in the 'Configure command' section, then you should be OK.

Regards,
R.

louponne

5:34 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks to all for your help thus far!
I just made a test.php with just gd_info(); in it and got
Fatal error: Call to undefined function: gd_info()...
So it looks like this host does not have this installed. :(

Jocelyn

6:51 pm on Mar 21, 2003 (gmt 0)

10+ Year Member



louponne, from the documentation of the gd_info() function, you can see that it only works with PHP 4.3.0 and better.
The error you got is a PHP error meaning that the function gd_info() is not defined. It doesn't tell whether GD is installed or not!
Run phpinfo(). It should work, and give you some info :
- PHP version
- if GD is installed or not
This is not as good as gd_info() but rather usefull anyway

Don't forget the documentation :
[php.net...]
[php.net...]
[php.net...]
[boutell.com...]

Jocelyn

louponne

8:03 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



oops - thanks for correcting me and many thanks for your patience with a relative newbie! Yes, I ran phpinfo() as you suggested. PHP 4.1.2 and gd is indeed "enabled". hurray. Now all I have to do is learn how to use it! Many thanks again for everyone's help!

Birdman

10:50 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



louponne,

I just posted a script in Bag-O-Tricks for PHP II [webmasterworld.com] that you may like to check out.

[edited by: coopster at 5:41 pm (utc) on Mar. 19, 2007]
[edit reason] fixed link [/edit]

 

Featured Threads

Hot Threads This Week

Hot Threads This Month