Jump to content

creating heaps of thumbs in a go


jmag

Recommended Posts

Hello,

I've got a small script that when a folder is entered it looks for thumbnails, if there aren't any they are created. so for each folder it's only being done once. However, sometimes a folder can contain up to a hundred highres photos, and my development can't quite handle that amount of data since the PHP engine seems to be sending a new pic for resizing and writing to the disc faster than the computer can do each image.

Now my Q is this: is there any way to tell the phpscript to send an image, wait till it's done, then do next? just to make sure the server can handle everything without crashing/rebooting even if there are lots of images. I got a strong guess that this also would increase the perfomance of the script since it won't try to do everything and then choke.

the script can be viewed here if necessary: [a href=\"http://www.rafb.net/paste/results/62AqLi91.html\" target=\"_blank\"]http://www.rafb.net/paste/results/62AqLi91.html[/a]

Thanx in advance for any help!
Link to comment
Share on other sites

[!--quoteo(post=359795:date=Mar 29 2006, 09:19 PM:name=jmag)--][div class=\'quotetop\']QUOTE(jmag @ Mar 29 2006, 09:19 PM) [snapback]359795[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hello,

I've got a small script that when a folder is entered it looks for thumbnails, if there aren't any they are created. so for each folder it's only being done once. However, sometimes a folder can contain up to a hundred highres photos, and my development can't quite handle that amount of data since the PHP engine seems to be sending a new pic for resizing and writing to the disc faster than the computer can do each image.

Now my Q is this: is there any way to tell the phpscript to send an image, wait till it's done, then do next? just to make sure the server can handle everything without crashing/rebooting even if there are lots of images. I got a strong guess that this also would increase the perfomance of the script since it won't try to do everything and then choke.

the script can be viewed here if necessary: [a href=\"http://www.rafb.net/paste/results/62AqLi91.html\" target=\"_blank\"]http://www.rafb.net/paste/results/62AqLi91.html[/a]

Thanx in advance for any help!
[/quote]

as far as i know, you don't need to wait. problems with the images being written would indicate a problem with your script further than than (eg file formats and using the right imagejpeg/imagegif/imagepng, etc).

might be worth checking this. also note that if, as you're creating the thumbnails you're putting them straight out on the screen, that a script can only send the headers and output one image at a time.
Link to comment
Share on other sites

Your script may be taking more than the default 30 seconds to run, just increase the amount of time by calling the function [a href=\"http://www.php.net/set_time_limit\" target=\"_blank\"]set_time_limit[/a]().

Ken
Link to comment
Share on other sites

I'm working on a (messy!) gallery script at the moment and I've found that generating the thumbnails dynamically each time someone views the page is far too time-consuming. I'm using imagecopyresample, no imagecopyresize, so that explains the time-taking. My solution was to create a 'thumbs' directory in the gallery directory and when a file is uploaded, create the thumbnail then and put it in the thumbs directory. Then just 'img src' images in that directory with links to the high-res images. This is working well for me.
Link to comment
Share on other sites

Thanx for all tips and answers. However, the files are written to the disc, so a thumb is only created once and then just shown with <img src... />

My problem isn't when they are just supposed to be shown, the problem is that first time someone enters a directory and thums are created and written to the disc. I know my server isn't very powerful (amd1800+, 256mb ram), but being a development server it's just some old stuff put together. But even still there should be some way to make it que all thumbs to be created so it doesn't sort of choke. Or perhaps it's a server config I should make?

I guess that depending on the size of the files, the limit is somewhere around 20-30 pics in one dir. More than that it crashes and reboots.

Here's a new link to the code since the old one expired: [a href=\"http://www.rafb.net/paste/results/ah7NdK82.html\" target=\"_blank\"]http://www.rafb.net/paste/results/ah7NdK82.html[/a]

thanx alot.
Link to comment
Share on other sites

I think i am having the same problem, in that i create a thumbnail of a larger picture by calling a thumbnail generator script, by passing a path to it. And then it outputs the picture to screen. This process is looped untill all thumbs are displayed.

Although only the first 9 or 10 are ever all displayed correctly. After that the odd one or two are broekn links.

Would i benefit from extending the set_time_limit() or is my problem related to the server not being fast enough??

More detail here: [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=90020\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=90020[/a]
Link to comment
Share on other sites

this is pretty much exactly the same as I do and same problem, although it never displays incorrectly after what I've noticed.

The thing is I'm not exatly sure that my server is the problem, it's just a guess...

but still, anyone? any more hints/tips?
Link to comment
Share on other sites

Have you tried to extend the execution time like I mentioned a few posts back? If you use a zero for the argument, it gives you unlimitied execution time. I have made similar thumbnail scripts and I have to increase the execution time if I want them to complete.

Ken
Link to comment
Share on other sites

Ive tried using set_time_limit() by setting it to 0, also by leaving it blank, but it doesnt seem to have an effect?!

Ive also tried max_execution_time(), which also doesnt have any effect?!

I notice on pp.net that it says, set_time_limit only has an effect on the script itself, and not external activites, would loading an image class as an external activity, as i notice that database queries are?!?!

Could this be the problem, if so, any work arounds?!
Link to comment
Share on other sites

Just out of curiosity (frequently paraphrased by S. Holmes and Lt Columbo)....

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]I've got a small script that when a folder is entered it looks for thumbnails, if there aren't any they are created. so for each folder it's only being done once. However, sometimes a folder can contain up to a hundred highres photos[/quote]

In what manner/fashion/method are the pictures originally being placed into the folders?

Lite...
Link to comment
Share on other sites

sry for the late reply, been away for a couple of days...

anyhoot, the files are just copied over via windowsexplorer or whatever other may be suitable. It isn't an upload script or anything, it just scans a folder for pictures and, if there are, it looks for the same filename with the prefix "tn_", if that doesn't exist it creates the thumbnail and write it to the disc.
this is where there problem occurs, depending on the size of the pictures it may vary how many it can handle before it crashes. it's just a loop, and it seems like it chokes on all pictures being sent for resizing...

just tell me if you want to take a look at the code, I'll post it again at nopaste... easier to read the code there and the post here won't be as long.

cheers!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.