rejetto forum
May 25, 2012, 06:31:33 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: 1 2 [3]
  Print  
Author Topic: thumbnails on the fly  (Read 1527 times)
0 Members and 2 Guests are viewing this topic.
r][m
Insane poster
*****
Offline Offline

United States United States

Posts: 340


View Profile
« Reply #30 on: August 08, 2010, 11:31:58 AM »

@SamePaul
I also serve some images (some very high res) from time to time.
Actually I'd be interested to "see" your solution/method for images.
Anything to make the process quicker/more efficient.
Would you share it here on the forum?

Edit:
As additional info
Firefox, Opera, IE, & Safari (recent/new release) test to work with ~mysection
however, Ephipany on Linux, as one that comes to mind does not. Likely there are others.
All tested so far work with diff tpl.
« Last Edit: August 08, 2010, 11:50:33 AM by r][m » Logged
SamePaul
Experienced poster
***
Offline Offline

Posts: 70


View Profile
« Reply #31 on: August 08, 2010, 12:50:12 PM »

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:
Quote
...
[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.JPG

Advantages:
- 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 Smiley 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 Smiley  pipelined and more suitable for my specific task.
« Last Edit: August 08, 2010, 12:54:39 PM by SamePaul » Logged
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page April 28, 2012, 11:52:08 PM