Changed lines at line 1
1: 1 General
2: The Image Server is a CGI-script that provides pictures in various dimensions.
3: 1 Features
4: 1.1 initial version
5: - request with arbitrary bounding box
6: - original picture ratio is maintained
7: - delivering and caching of pictures in dimensions of a certain raster
8: - picture fits into the requested bounding box and configured raster
9: - picture is just scaled down, never up
10: - serving scaled images per HTTP redirect to the location of an static image file
11: 1.1 future versions
12: - support extern storage of scaled images to allow mirroring. (redirection map)
13: - support explicit precaching (to be copied to a mirror)
14: 1 Design Decisions
15: 1.1 Raster
16: We introduced a raster in which the images are scaled. This prevends the cache of get filled up with various fine grain scaled versions of the same image. The raster width is a configuration option which belongs to the caching group.
17: 1 Specification
18: 1.1 Behaviour
19: 1.1.1 Request
20: A picture is requested with an picture name and a bounding box. The bounding box specifies the maximal size of the image. The Image Server has a configured raster in which it provides pictures. Lets assume the raster is set to 50 pixel. The picture size is scaled down to fit in the bounding box and then the width is rounded down multiple of 50. (The height is obviously scaled down as well) The needed version of the picture is looked up in the cache and is generated if needed. The file name contains the dimensions and the request is answered using redirection to that file. That allows browser side caching even for slightly different bounding boxes.
21: 1.1.1 Raster
22: The raster with must be fixed over an reasonable lifetime of the server. The client shouldn't get different scaled images for the same requested dimension. In particular, the server is not allowed to serve a "good matching" version of an images which is a cache hit.
23: 1.1.1 Cache
24: The cache is an important part of the Image Server since it can reduce the server side load and the latency time. The cache has a space limit and the caching stategy is LRU (least recently used).
25: 1.1.1 Mirrors
26: A mirror should keep pictures in various sizes to save bandwidth or to gain faster access. It is also handy to be able to store the pictures on cheap webspace without CGI support. The Image Server has a mirror map where every mirror has a list of files it has. Furthermore there could be some information about the bandwith of the mirror. If a file is mirrored on more than one mirror is redirected with a probability ratio that correspond to the bandwith ratio.
27: 1.1 Interface
28: 1.1.1 CGI
29: The request URL is:
30: {code:none}
31: \http://<host>/<path>/imgserv.cgi?src=<image src>&width=<width>&height=<height>
32: {code}
33: Where __<image src>__ is a complete URL or relative path identifier of the image to request. If the normal request URL of an image would be "images/1.jpg" than the __<image src>__ is "images/1.jpg" too. __<width>__ and __<height>__ are integers greater zero and denote the dimension of the requested image in pixel. Other units are not planed.
34: Examples:
35: {code:none}
36: \http://<host>/<path>/imgserv.cgi?src=images/1.jpg&width=800&height=600
37: \http://<host>/<path>/imgserv.cgi?src=http://<otherhost>/album1/slides/image1.jpg&width=800&height=600
38: {code}
39: 1.1.1 Configuration
40: TODO: describe the configuration file syntax and options
41: 1 Implementation
42: 1.1.1 Raster
43: The dimension to serv is calculeted this way:
44: {code:java}
45: /*pseudo java code*/
46: int calcWidth; //bounding box fitting width
47: int calcHeight; //bounding box fitting height
48: int servWidth; //width to serve
49: int servHeight; //height to serve
50: int raster; //width of the raster
51: servWidth = (calcWidth / raster) * raster; //integer division
52: servHeight = (calcHeight / raster) * raster;
53: {code}
54: This implementation as the problem, that the image ratio would not get kept. I suggest do applz the raster just on one of the dimensions.
55: 1 Contents
56: - [General|Image Server#General]
57: - [Features|Image Server#Features]
58: - [Specification|Image Server#Specification]
59: - [Implementation|Image Server#Implementation]
60: - [Installation|Image Server#Installation]
61: 1 General {anchor:General}
62: The Image Server is a CGI-script that provides pictures in various dimensions.
63: 1 Features {anchor:Features}
64: 1.1 initial version
65: - request with arbitrary bounding box
66: - original picture ratio is maintained
67: - delivering and caching of pictures in dimensions of a certain raster
68: - picture fits into the requested bounding box and configured raster
69: - picture is just scaled down, never up
70: - serving scaled images per HTTP redirect to the location of an static image file
71: 1.1 future versions
72: - support extern storage of scaled images to allow mirroring. (redirection map)
73: - support explicit precaching (to be copied to a mirror)
74: 1 Design Decisions
75: 1.1 Raster
76: We introduced a raster in which the images are scaled. This prevends the cache of get filled up with various fine grain scaled versions of the same image. The raster width is a configuration option which belongs to the caching group.
77: 1 Specification {anchor:Specification}
78: 1.1 Behaviour
79: 1.1.1 Request
80: A picture is requested with a picture path and a bounding box. The bounding box specifies the maximal size of the image. The Image Server has a configured raster in which it provides pictures. Lets assume the raster is set to 50 pixel. The picture size is scaled down to fit in the bounding box and then the width is rounded downwards to multiple of 50. (The height is obviously scaled down as well) The needed version of the picture is looked up in the cache and is generated if needed. The file name contains the dimensions and the request is answered using redirection to that file. That allows browser side caching even for slightly different bounding boxes.
81: 1.1.1 Raster
82: The raster value must be fixed over a reasonable time. The client shouldn't get different scaled images for the same requested dimension. In particular, the server is not allowed to serve a "good matching" version of an images which is a cache hit.
83: 1.1.1 Cache
84: The cache is an important part of the Image Server since it can reduce the server side load and the latency time. The cache has a space limit and the caching stategy is LRU (least recently used). The cached files should have the same modification date as the original file. Why? A file is deleted from the cache because of space limits. If it is requested again and the browser still has it in his cache it can be taken from there instead of downloaded again. Furthermore there should be a minimum lifetime of a chached file since the client needs to download them.
85: 1.1.1 Mirrors
86: A mirror should keep pictures in various sizes to save bandwidth or to gain faster access. It is also handy to be able to store the pictures on cheap webspace without CGI support. The Image Server has a mirror map where every mirror has a list of files it has. Furthermore there could be some information about the bandwith of the mirror. If a file is mirrored on more than one mirror is redirected to the one with more bandwidth. Loadbalancing is not reasonable since we loose the client-side caching.
87: 1.1 Interface
88: 1.1.1 CGI
89: The request URL is:
90: {code:none}
91: \http://<host>/<path>/imgserv.cgi?src=<image src>&width=<width>&height=<height>
92: {code}
93: Where __<image src>__ is an absolute path to the image form the document root.
94: Relative pathes are not possible since they are normally resolved by the browser. Therefor the Image Server cannot detemine the right path. __<width>__ and __<height>__ are integers greater than zero and denote the dimension of the requested image in pixel. Other units are not planed.
95: Examples:
96: {code:none}
97: \http://<host>/<path>/imgserv.cgi?src=images/1.jpg&width=800&height=600
98: \http://<host>/<path>/imgserv.cgi?src=gallery/holiday/1.jpg&width=1048&height=879
99: {code}
100: 1.1.1 Configuration
101: TODO: describe the configuration file syntax and options
102: 1 Implementation {anchor:Implementation}
103: 1.1 Language
104: [Haskell] is a great language for CGI scripts since it is pure functional has an easy to use CGI library.
105: 1.1 Raster
106: The dimension to serv is calculeted this way:
107: {code:java}
108: /*pseudo java code*/
109: int calcWidth; //bounding box fitting width
110: int calcHeight; //bounding box fitting height
111: int servWidth; //width to serve
112: int servHeight; //height to serve
113: int raster; //width of the raster
114: servWidth = (calcWidth / raster) * raster; //integer division
115: servHeight = (servWidth * calcHeight) / calcWidth;
116: {code}
117: This implementation maintains the side ratio of the image.
118: 1 Installation {anchor:Installation}
119: - install Hugs at the webserver machine
120: - check how to use cgi scripts with your webserver
121: - haskell cgi script are used like perl CGI scripts with the difference that runhugs is started instead of perl
122: - TODO: continue