28#define LOGFILE "/tmp/iipsrv.log"
29#define MAX_IMAGE_CACHE_SIZE 10.0
30#define FILENAME_PATTERN "_pyr_"
31#define JPEG_QUALITY 75
33#define WEBP_QUALITY 50
36#define FILESYSTEM_PREFIX ""
37#define FILESYSTEM_SUFFIX ""
39#define WATERMARK_PROBABILITY 1.0
40#define WATERMARK_OPACITY 1.0
41#define LIBMEMCACHED_SERVERS "localhost"
42#define LIBMEMCACHED_TIMEOUT 86400
43#define INTERPOLATION 1
46#define CACHE_CONTROL "max-age=86400";
47#define ALLOW_UPSCALING true
50#define KAKADU_READMODE 0
63 static int getVerbosity(){
64 int loglevel = VERBOSITY;
65 const char *envpara = getenv(
"VERBOSITY" );
67 loglevel = atoi( envpara );
69 if( loglevel < 0 ) loglevel = 0;
75 static std::string getLogFile(){
76 const char* envpara = getenv(
"LOGFILE" );
77 if( envpara )
return std::string( envpara );
82 static float getMaxImageCacheSize(){
83 float max_image_cache_size = MAX_IMAGE_CACHE_SIZE;
84 const char* envpara = getenv(
"MAX_IMAGE_CACHE_SIZE" );
86 max_image_cache_size = atof( envpara );
88 return max_image_cache_size;
92 static std::string getFileNamePattern(){
93 const char* envpara = getenv(
"FILENAME_PATTERN" );
94 std::string filename_pattern;
96 filename_pattern = std::string( envpara );
98 else filename_pattern = FILENAME_PATTERN;
100 return filename_pattern;
104 static int getJPEGQuality(){
105 const char* envpara = getenv(
"JPEG_QUALITY" );
108 jpeg_quality = atoi( envpara );
109 if( jpeg_quality > 100 ) jpeg_quality = 100;
110 if( jpeg_quality < 1 ) jpeg_quality = 1;
112 else jpeg_quality = JPEG_QUALITY;
118 static int getPNGQuality(){
119 const char* envpara = getenv(
"PNG_QUALITY" );
122 quality = atoi( envpara );
123 if( quality > 9 ) quality = 9;
124 if( quality < 0 ) quality = 0;
126 else quality = PNG_QUALITY;
132 static int getWebPQuality(){
133 const char* envpara = getenv(
"WEBP_QUALITY" );
136 quality = atoi( envpara );
137 if( quality > 100 ) quality = 900;
138 if( quality < 0 ) quality = 0;
140 else quality = WEBP_QUALITY;
146 static int getMaxCVT(){
147 const char* envpara = getenv(
"MAX_CVT" );
150 max_CVT = atoi( envpara );
152 if( max_CVT < -1 ) max_CVT = 1;
154 else if( max_CVT == 0 ) max_CVT = MAX_CVT;
156 else max_CVT = MAX_CVT;
162 static int getMaxLayers(){
163 const char* envpara = getenv(
"MAX_LAYERS" );
165 if( envpara ) layers = atoi( envpara );
166 else layers = MAX_LAYERS;
172 static std::string getFileSystemPrefix(){
173 const char* envpara = getenv(
"FILESYSTEM_PREFIX" );
174 std::string filesystem_prefix;
176 filesystem_prefix = std::string( envpara );
178 else filesystem_prefix = FILESYSTEM_PREFIX;
180 return filesystem_prefix;
184 static std::string getFileSystemSuffix(){
185 const char* envpara = getenv(
"FILESYSTEM_SUFFIX" );
186 std::string filesystem_suffix;
188 filesystem_suffix = std::string( envpara );
190 else filesystem_suffix = FILESYSTEM_SUFFIX;
192 return filesystem_suffix;
196 static std::string getWatermark(){
197 const char* envpara = getenv(
"WATERMARK" );
198 std::string watermark;
200 watermark = std::string( envpara );
202 else watermark = WATERMARK;
208 static float getWatermarkProbability(){
209 float watermark_probability = WATERMARK_PROBABILITY;
210 const char* envpara = getenv(
"WATERMARK_PROBABILITY" );
213 watermark_probability = atof( envpara );
214 if( watermark_probability > 1.0 ) watermark_probability = 1.0;
215 if( watermark_probability < 0 ) watermark_probability = 0.0;
218 return watermark_probability;
222 static float getWatermarkOpacity(){
223 float watermark_opacity = WATERMARK_OPACITY;
224 const char* envpara = getenv(
"WATERMARK_OPACITY" );
227 watermark_opacity = atof( envpara );
228 if( watermark_opacity > 1.0 ) watermark_opacity = 1.0;
229 if( watermark_opacity < 0 ) watermark_opacity = 0.0;
232 return watermark_opacity;
236 static std::string getMemcachedServers(){
237 const char* envpara = getenv(
"MEMCACHED_SERVERS" );
238 std::string memcached_servers;
240 memcached_servers = std::string( envpara );
242 else memcached_servers = LIBMEMCACHED_SERVERS;
244 return memcached_servers;
248 static unsigned int getMemcachedTimeout(){
249 const char* envpara = getenv(
"MEMCACHED_TIMEOUT" );
250 unsigned int memcached_timeout;
251 if( envpara ) memcached_timeout = atoi( envpara );
252 else memcached_timeout = LIBMEMCACHED_TIMEOUT;
254 return memcached_timeout;
258 static unsigned int getInterpolation(){
259 const char* envpara = getenv(
"INTERPOLATION" );
260 unsigned int interpolation;
261 if( envpara ) interpolation = atoi( envpara );
262 else interpolation = INTERPOLATION;
264 return interpolation;
268 static std::string getCORS(){
269 const char* envpara = getenv(
"CORS" );
271 if( envpara ) cors = std::string( envpara );
277 static std::string getBaseURL(){
278 const char* envpara = getenv(
"BASE_URL" );
279 std::string base_url;
280 if( envpara ) base_url = std::string( envpara );
281 else base_url = BASE_URL;
286 static std::string getCacheControl(){
287 const char* envpara = getenv(
"CACHE_CONTROL" );
288 std::string cache_control;
289 if( envpara ) cache_control = std::string( envpara );
290 else cache_control = CACHE_CONTROL;
291 return cache_control;
295 static bool getAllowUpscaling(){
296 const char* envpara = getenv(
"ALLOW_UPSCALING" );
297 bool allow_upscaling;
298 if( envpara ) allow_upscaling = atoi( envpara );
299 else allow_upscaling = ALLOW_UPSCALING;
300 return allow_upscaling;
304 static std::string getURIMap(){
305 const char* envpara = getenv(
"URI_MAP" );
307 if( envpara ) uri_map = std::string( envpara );
308 else uri_map = URI_MAP;
313 static unsigned int getEmbedICC(){
314 const char* envpara = getenv(
"EMBED_ICC" );
316 if( envpara ) embed = atoi( envpara );
317 else embed = EMBED_ICC;
322 static unsigned int getKduReadMode(){
323 unsigned int readmode;
324 const char* envpara = getenv(
"KAKADU_READMODE" );
326 readmode = atoi( envpara );
327 if( readmode > 2 ) readmode = 2;
329 else readmode = KAKADU_READMODE;
334 static unsigned int getIIIFVersion(){
335 unsigned int version;
336 const char* envpara = getenv(
"IIIF_VERSION" );
338 version = atoi( envpara );
339 if( version < 1 ) version = IIIF_VERSION;
341 else version = IIIF_VERSION;
Class to obtain environment variables.
Definition: Environment.h:58