Changed lines at line 16
16: We introduced a raster in which the images are scaled. This prevends the cache of filling up with various fine grained 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 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: 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.
55: 1 Specification
56: 1.1 Behaviour
57: 1.1.1 Request
58: 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.
59: 1.1.1 Raster
60: 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.
61: 1.1.1 Cache
62: 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).
63: 1.1.1 Mirrors
64: 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.
65: 1.1 Interface
66: 1.1.1 CGI
67: The request URL is:
68: {code:none}
69: \http://<host>/<path>/imgserv.cgi?src=<image src>&width=<width>&height=<height>
70: {code}
71: 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.
72: Examples:
73: {code:none}
74: \http://<host>/<path>/imgserv.cgi?src=images/1.jpg&width=800&height=600
75: \http://<host>/<path>/imgserv.cgi?src=http://<otherhost>/album1/slides/image1.jpg&width=800&height=600
76: {code}
77: 1.1.1 Configuration
78: TODO: describe the configuration file syntax and options
79: 1 Implementation
80: 1.1.1 Raster
81: The dimension to serv is calculeted this way:
82: {code:java}
83: /*pseudo java code*/
84: int calcWidth; //bounding box fitting width
85: int calcHeight; //bounding box fitting height
86: int servWidth; //width to serve
87: int servHeight; //height to serve
88: int raster; //width of the raster
89: servWidth = (calcWidth / raster) * raster; //integer division
90: servHeight = (calcHeight / raster) * raster;
91: {code}
92: 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.