Diff tpl applies to subfolders here, at least where all are real.
Maybe you are right and I just misinterpret the way diff template works.
The main idea originally was to execute some console tool, which resizes image to specified size and the dumps JPEG data to stdout. Then HFS takes this output and send it to client.
So I build template:
...
[file.jpg=file.png=file.gif=file.bmp|private]
...
<a href="%item-name%"><img src="%item-folder%/~thumbnail?file=%item-name%" /> %item-name%</a>
...
[thumbnail]
{.add header|Content-Type: image/jpeg.}
{.exec|resize.exe "%item-resource%{.?file.} -scale 50x50"|out=x.}{.^x}
So basically if everithing works as expected, URL
http://mysite.com/photos/july2010/~thumbnail?file=IMG_200.JPG would open as thumbnail version of file
http://mysite.com/photos/july2010/IMG_200.JPGAdvantages:
- works on the fly with any picture you have on your server, including newly uploaded
- doesn't use diskspace
- works on any VFS
Disadvantages:
-relatively slow if you have lots of files in folder (thus not suitable if you have high hit rate)
-it doesn't work
when I attempt to open the mentioned URL I get error 404 Not Found.
Another solution (proposed by rejetto) was to create thumbnail cache on disk and in template create thumbnails on the fly only when absent in cache. Finally template would look like this
<a href="%item-name%"><img src="/cache/%item-name%" /> %item-name%</a>
Of course it needs some polish (my is more complex), but it's just example to introduce principle.
Advantages:
-works on the fly
-it actually works(!!)
-consequent requests are pretty fast, as HFS takes thumbnails from cache
-spares disk reads
Disadvantages:
-takes diskspace (not a much however)
-in case of name conflicts there is no automatic way to resolve it
-requires additional hidden VFS share (which is not really a problem)
For image scaling I use ImageMagic tool set, which is pretty fast. However I'm going to write my own tool, because I need it to be even faster
pipelined and more suitable for my specific task.