Jump to content


Photo

creating heaps of thumbs in a go


  • Please log in to reply
11 replies to this topic

#1 jmag

jmag
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationSweden

Posted 29 March 2006 - 08:19 PM

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!

#2 jmag

jmag
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationSweden

Posted 01 April 2006 - 09:38 AM

*bump*

anyone?

#3 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 01 April 2006 - 10:06 AM

[!--quoteo(post=359795:date=Mar 29 2006, 09:19 PM:name=jmag)--][div class=\'quotetop\']QUOTE(jmag @ Mar 29 2006, 09:19 PM) View Post[/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.

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 01 April 2006 - 03:37 PM

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

#5 bqallover

bqallover
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • LocationLeeds, UK

Posted 01 April 2006 - 04:13 PM

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.

#6 jmag

jmag
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationSweden

Posted 04 April 2006 - 05:18 AM

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.

#7 cssmatt

cssmatt
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 04 April 2006 - 08:35 AM

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]

#8 jmag

jmag
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationSweden

Posted 04 April 2006 - 05:20 PM

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?

#9 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 04 April 2006 - 06:56 PM

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

#10 cssmatt

cssmatt
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 04 April 2006 - 09:11 PM

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

#11 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 05 April 2006 - 12:07 AM

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

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#12 jmag

jmag
  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationSweden

Posted 07 April 2006 - 10:12 PM

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users