Member
Member
scorch   2007-02-01, 07:25
#1
i'd like to be able to trigger thumbnail creation via script, after adding a large number of files, to save generating them on the fly. with over 10GB of images & adding about 1GB per month, it makes sense to be able to do this in advance, to keep load down
Developer
Developer
trisweb   2007-02-02, 00:23
#2
Quite easy. This will load a page of all thumbnails and default-sized images in your gallery:

`<html>

<?php

require_once("zen/template-functions.php");

$count = 0;

echo 'Loading...
';

while (next_album()):

while (next_image()):

echo '[img]'.getImageThumb().'[/img] / [img]'.getDefaultSizedImage().'[/img]<br/>';

$count++;

endwhile;

endwhile;

echo "Finished: Total of $count images.

";

?>

</html>`
Member
Member
scorch   2007-02-03, 09:01
#3
thanks!

I dropped this in zen/* with all the other bits as rebuild.php, stripped out the zen/ path header & ran it, with a ."\n" at the end of the echo line for readability:

php rebuild.php
<.../

Finished: Total of 459 images.

-- in about 10 seconds. i'm a little suspicious as i know i have 9000 images online so far... and only 530 thumbnails in cache/

the first folder it picks up has about 350 images in it, but ZP only gets to the first 30 before heading off to the next ones. this is a pattern - if the album has > 30 images, ZP skips to the next before finishing.

i'd guess there needs to be something like a "next page" in between the next_album and next_image loops...

i can provide debug output or any other info if you let me know what is needed.

you can grab the log from this run as:

http://muse.net.nz/zenphoto/cache/rebuild.log

thanks, scorch

PS i still haven't figured out how/where i can rotate images yet ... is there a how-to somewhere i missed?
Developer
Developer
trisweb   2007-02-03, 21:16
#4
Oh right, that may help.... heh. Try this (Improved in other ways as well):

`<html><body>

<?php

require_once("zen/template-functions.php");

$count = 0;

echo 'Loading...
';

$_zp_page = 0;

while (next_album()) {

while (next_image()) {

echo '[img]'.getImageThumb().'[/img][img]'.getDefaultSizedImage().'[/img]'."n";

$count++;

if ($count % 20 == 0) echo "
n";

}

}

echo "n
Finished: Total of $count images.

";

?>

</body></html>`
Member
Member
scorch   2007-02-13, 01:40
#5
that works nicely thanks - but only if it's under zenphoto/rebuild.php

is it possible to change to run from zephoto/zen/ & then leave it in SVN? that would be a useful addition.

e.g. as http://muse.net.nz/zenphoto/zen/rebuild.php
Developer
Developer
trisweb   2007-02-13, 05:21
#6
To change it for that, just take the `zen/` out of the require_once path string. I don't think I'll check it in to SVN just yet, perhaps a similar functionality will be in the 1.1 admin though.
Member
Member
scorch   2007-02-23, 03:49
#7
thanks! just a point - this takes hours to run through. if you ever move it into svn, it would be a good move to add it as a button to a folder level "regenerate" for example.
Member
Member
permesso   2007-07-09, 02:27
#8
Sorry to revive an old thread but I am really looking for this functionality but I heavily use sub-albums and this script is not decending into the sub-albums. Is there a quick change to the script that would help? Thanks in advance.
Member
Member
edasque   2007-08-27, 19:11
#9
same here, any hope for a recursive version of this ?
Member
Member
aitf311   2007-08-30, 22:16
#10
Anyone figure out a way to get this working for subalbums yet? This would be a very useful script to have in the admin page.
Member
Member
sbillard   2007-09-02, 01:01
#11
Here is a routine which will do what you want. Copy it into your zen folder with the rest of the php files. Then point your browser to it.

`<html>

<?php

require_once("template-functions.php");

global $_zp_gallery;

$count = 0;

function loadAlbum($album) {

global $_zp_current_album;

echo "<br/>Processing " . $album->name . "n";

$subalbums = $album->getSubAlbums();

foreach ($subalbums as $folder) {

$subalbum = new Album($album, $folder);

$count = $count + loadAlbum($subalbum);

}

$_zp_current_album = $album;

if (getNumImages() > 0) {

echo "<br/>n";

while (next_image()):

echo '[img]'.getImageThumb().'[/img] | [img]'.getDefaultSizedImage().'[/img]' . "n";

$count++;

endwhile;

}

echo "<br/>Finished with " .$album->name . "n";

return $count;

}

if (isset($_GET['album'])) {

$folder = strip($_GET['album']);

$album = new Album($album, $folder);

$count = loadAlbum($album);

} else {

echo "Processing Galleryn";

$albums = $_zp_gallery->getAlbums();

foreach ($albums as $folder) {

$album = new Album($album, $folder);

$count = $count + loadAlbum($album);

}

}

echo "<br/>Finished: Total of $count images.";

?>

<html>`

If you don't want to do your whole gallery, just pass the file an album parameter with the name of the album you wish to process.

e.g. http://myalbum.zenphoto.com/zenphoto/zen/loadAlbums.php?album=newalbum
Member
Member
grantonstar   2009-01-15, 09:30
#12
I'm using the latest script from sbillard on zenphoto 1.2.2. getNumImages() returns the count of images for each album but next_image() doesn't seem to be returning any images.

Any ideas why? Does anyone have an updated cache script? (I need it for my gallery migration)

Thanks,

grantonstar
Member
Member
sbillard   2009-01-15, 19:47
#13
1.1.2 has the pre-cache images utility, why don't you use that.
Member
Member
grantonstar   2009-01-16, 03:20
#14
THe main reason why is because it is unable to cache 17k images at once. Either it times out or the browser crashes.

The reason I want to pre-cache is to run the Gallery migration utility.
Member
Member
sbillard   2009-01-16, 04:13
#15
Pre-cache by album/subalbum. What makes you think the above script will not also time out? It is, after all, basically the same code as the pre-cache utility.
Junior Member
Junior Member
nonzero   2013-04-19, 07:23
#16
Are there any includes or bootstrapping code I need to add to the script to run it from the command line of the web server rather than through a browser? I'm working with images that are hundreds of MB, and I'm not allowed to change the web server's memory limits, but I can override the PHP memory limit on the command line.
Administrator
Administrator
acrylian   2013-04-19, 07:59
#17
This topic is really old. Zenphoto features a cache_manager plugin that took over the older precache functionality.
Administrator
Administrator
acrylian   2013-04-19, 07:59
#18
This topic is really old. Zenphoto features a cache_manager plugin that took over the older precache functionality.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.