homepage Welcome to WebmasterWorld Guest from 54.167.185.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Is it possible to create image thumbnails server-side?
Using PHP, either on the fly or on upload or ...?
louponne




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

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




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

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

louponne




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

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




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

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




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

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




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

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




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

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




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

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




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

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




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

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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved