|
Posted by burgermeister01@gmail.com on 08/17/07 18:13
> I have a list of links which point to e.g.
> thescript.php?album=somePictures1
> thescript.php?album=somePictures2
>
> This list is about 3000 links. Each album may have 500 or more pictures in it.
> the script looks in the specified dir, and creates thumbnails if they are not
> present. So, displaying a particular album often takes quite a while. I've set
> the proper php.ini stuff to accomodate the long script_execution's. Thats all
> working fine.
>
> Now, I dont want the end user to have to wait for the thumbs if they land on an
> album that has not yet had thumbnails created.
>
> So the question is, what is the best way to run all those links automatically,
> thereby creating all the thumbs?
>
> Thanks for your time,
As you suggested in your subject line, probably the best route to go
would be to set up a command line script to process the file, and use
cron to do it regularly if new files are being added all the time (or
just process files at the time of introduction in the system).
Just remember, in command-line scripts for PHP, you have to first give
a path to the interpreter like so:
#!/usr/bin/php
Just replace "/usr/bin/php" with the path to your interpreter.
You will also of course, have to go through all directories not just
one, so this is a brief recursive function to iterate a directory
structure. It takes the root directory containing images and their
directories as its parameter. Just replace the comment with the
appropriate means of processing your images and making thumbnails:
//(not tested)
function iterateDir($dir){
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != ".."){
if(is_dir($file)){
iterateDir($file);
}else{
//...process file...
}
}
}
closedir($dh);
}
}
}
Navigation:
[Reply to this message]
|