caching for current theme and configuration

I deleted all cached images and then explored an album or two to see what cached images would be produced. Then I created a set of 'Image cache sizes' to match all that were produced on the fly as a result of my viewing. My goal, of course, was to rely on cached images to the greatest extent possible. And the disk consumption was not an issue, it was ok that many of the cached images would never be used (i.e. producing both portrait and landscape sizes when each image would actually only need one or the other).

That was great until I realized that photos in other albums may have been produced at different X*Y resolutions and would therefore result in additional 'Image cache sizes' needed.

It would be nice, and perhaps quite challenging, to be able to generate the image caches based on the theme and it's current image size settings. IOW, rather than create all possible sizes that might be needed, use the existing setup and the characteristics of each photo in the gallery (or maybe just by album) to predetermine what cache sizes would be needed and produce only those cache files.

This would be particularly useful for those that have many different photo sizes that would result in the need for many slightly different cache file characteristics.

If it is too difficult to predetermine cache file requirements from the perspective of the theme and current configuration, what about the use of a 'hints file' at the gallery or sub-album level that could contain hints for each photo X*Y size. Like:

[5432x3678]
# size,w,h,cw,ch,thumb
,580,387,,,
,40,27,,,thumb
100,,,,,,thumb

[3678x5432]
,387,580,,,
,27,40,,,thumb
100,,,,,,thumb

[2272x1704]
,580,435,,,
,40,30,,,thumb
100,,,,,,thumb

These files could be used in conjunction with each photos X*Y characteristics to determine which 'cached images' should be produced for each photo.

Comments

  • As you have noted, it is the theme which best knows what image sizes will be used and therefore cached. Which is exactly why the theme has the ability to register these cache sizes with the cache manager. If it does so, they will automatically be available for "pre-cache" the images.
  • Yes, but the theme doesn't know the image sizes it will need until it checks each photo. So to pre-cache for all possible X*Y sizes in a gallery, that can be a lot of extra work (I.e. building every possible size for every photo). I'm not concerned about the wasted disk space, but it's all the extra processing needed to gen the extra images and thumbnails that would never actually be used. (We've got 40k+ photos). I thought if we had a way to provide hints to the pre-caching process, we could eliminate a lot of needless processing. The pre-caching process could lookup the X*Y size for each photo and knowing its orientation (portrait/landscape), it would only need to generate those images that would be needed for that particular photo.

    If a gallery has 10 different X*Y sizes, for example, and the goal is to pre-cache for all, 20 'sets' (10 x the two possible orientations) of images would be produced currently. But 19 of those wouldn't be needed/wanted. Being able to provide the hints would eliminate 95% of the work in this case.
  • acrylian Administrator, Developer
    No, it doesn't. That is why your theme needs to register the sizes to the cacheManager on its theme options. See the official themes for examples.

    But since this is precaching it is really not possible to set what sizes to cache for what image. It is all or none then.

    Technically not necessary to precache anything as Zenphoto will create cached versions on request automatically. For uncached images that will cause a delay for the first visitor but that's it then.

    Please also see:
    http://www.zenphoto.org/news/caching/
  • Just curious:

    From your description it sounds like your theme is setting its display size based on the image size of the original. Normally this would not be the case, the display size would be a fixed size maybe based on the image orientation, but original size would not be a consideration.

    So for most themes, there might be an album thumbnail size, and image thumbnail size, and a image page size. With landscape and portrait orientations that amounts to six sizes of which three would be used.

    What code are you using for displaying the images?
  • sbillard: Yes, I'm seeing slight differences in the sizes of thumbnail and other photos that are cached. I think that may be due to difference in the _ratio_ of X to Y sizes (not necessarily the differences in photo sizes). So even for slight differences in ratios, it results in another set of cache sizes being needed if the goal is to pre-cache everything.

    I'm using the zenpage theme and it's untouched at this point. I'm just trying to get familiar with things before making mods. I did include several plugins, including a thumbnail slider, and that require yet another set of tinier thumbnails to pre-create.

    So for my simple setup it seems I need to pre-create at least 6 cached images for every unique X to Y ratio of the original photos. And finding that I do have more than a few different ratios means lots of needless processing to do the all or nothing pre-cache.

    So my feature request (or at this point just questioning) was that if I could pre-identify the cached image sizes needed for each unique X to Y ratio, then this info could be made available to the pre-caching process. And pre-caching would then use that plus each photos actual X*Y & orientation to produce only what would truly be needed for each photo.

    The above idea is far from perfect. You still need to first see what actual sizes are needed for a given theme and it's current settings. But that could be done with a tiny sample of files vs. a large photo set (again, with 40k files that would take a while).

    I'm using gd to do the rendering. And the zenpage theme doesn't let you predetermine all the sizes it will use. In some cases you can chose the horizontal or vertical but not both. And that's where the slight differences come in.

    acrylian: I went to the cacheManager plugin and defined my own group of sizes so that I could just check them off at once. (And I didn't want to mod the one's for the zenpage theme). But are you saying that if I add more cacheManager::addThemeCacheSize() calls to themeoptions.php, that would be the better way to go? I thought it looked liked it would have the same effect.

    I do like the fact that zp will cache what's needed when each page and photo is visited. But I'd prefer to have the 'user experience' be as fast as possible. Disk is cheap. But users' attention spans are a bit fickle.

    I think it's cool that we _can_ precache. I was just hoping that process could be improved a bit.
  • Have you actually determined that the cache sizes for the zenpage theme are not adequate? It requests two cache sizes: a pretty standard thumbnail and an image sized to fit in a 580x580 pixel frame.

    The images that are cached may well vary in size depending on their aspect ratios, but only one pre-cache request size is needed since it will apply the same computations as the actual image request would have.
  • Sorry for the delay. Actually, no, I didn't try to go with the original zenpage sizes because I looked at what was created by 'on the fly' caching to make the determination of what I should pre-create. Now that I've tried the predefined cache sizes, I see that the size for photos tagged 'MaxSpace' (580x580) _does_ do what I was hoping for above. That is, it caches whatever size suits the aspect ratio of each individual photo while keeping it with the 580px bounding box. That's great! No extra pre-cache done for orientation or slight difference in aspect ratio.

    I did find that I needed to add a size (100_thumb) for that zenpage theme. And I also found that it was pre-caching 95_cw94_ch94, but it later used w95_h95_cw95_ch95, instead. So I'm making that change (but I'm scratching my head there).

    Definitely the MaxSpace feature is very helpful for my use. (I see that it's not necessarily available/used by default in all themes).

    And this is off-topic, but since I switched from pre-caching a rather large number of sizes to accommodate all aspect ratios and am now just going with the defaults (+ 100_thumb), the pre-caching process results in the system powering down (!) after about 30 minutes of pre-caching. (I've repeated this 3 times now). But I've never had any similar power issues before. ... I have a Solaris 11 system with 10 drives attached to 2 SAS controllers plus mirrored boot disks, etc. I think I've reached the tipping point on my 600w power supply. Time to upgrade.

    I've still got a lot to learn re: zenphoto. Thanks for your help/guidance and patience.
  • acrylian Administrator, Developer
    Definitely the MaxSpace feature is very helpful for my use. (I see that it's not necessarily available/used by default in all themes).

    Yes, it is optional and depends on the theme layout and what the theme authors wishes to use.
    A lot is optional and can be done via the theme if required.

    Regarding the power issues it is most certainly not the power but the memory. Take a look here (but you possibly know that already):
    http://www.zenphoto.org/news/problems-with-albums-and-images/
Sign In or Register to comment.