-
Notifications
You must be signed in to change notification settings - Fork 4
/
thumbor.conf
199 lines (154 loc) · 9.5 KB
/
thumbor.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# -*- coding: utf-8 -*-
import os
from distutils.util import strtobool
home = os.path.expanduser("~")
# thumbor imaging service
# https://github.com/thumbor/thumbor/wiki
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com [email protected]
# the domains that can have their images resized
# use an empty list for allow all sources
ALLOWED_SOURCES = eval(os.environ.get('ALLOWED_SOURCES', '[]'))
# the max width of the resized image
# use 0 for no max width
# if the original image is larger than MAX_WIDTH x MAX_HEIGHT,
# it is proportionally resized to MAX_WIDTH x MAX_HEIGHT
MAX_WIDTH = int(os.environ.get('MAX_WIDTH', 800))
# the max height of the resized image
# use 0 for no max height
# if the original image is larger than MAX_WIDTH x MAX_HEIGHT,
# it is proportionally resized to MAX_WIDTH x MAX_HEIGHT
MAX_HEIGHT = int(os.environ.get('MAX_HEIGHT', 600))
# the quality of the generated image
# this option can vary widely between
# imaging engines and works only on jpeg images
QUALITY = int(os.environ.get('QUALITY', 85))
WEBP_QUALITY = int(os.environ.get('WEBP_QUALITY', 80))
# Automatically converts images to WebP if Accepts header present
AUTO_WEBP = strtobool(os.environ.get('AUTO_WEBP', 'False'))
# Automatically converts PNG to JPG if PNG has no transparency.
# WARNING: Depending on case, this is not a good deal. This
# transformation maybe causes distortions or the size of image can increase.
# Images with texts, for example, the result image maybe will be distorced.
# Dark images, for example, the size of result image maybe will be bigger.
# You have to evaluate the majority of your use cases to take a decision about this conf.
AUTO_PNG_TO_JPG = strtobool(os.environ.get('AUTO_PNG_TO_JPG', 'False'))
# Specify the ratio between 1in and 1px for SVG images. This is only used when
# rasterizing SVG images having their size units in cm or inches.
SVG_DPI = int(os.environ.get('SVG_DPI', 150))
# Preserves exif information in generated images. Increases image size in kbytes, use with caution.
PRESERVE_EXIF_INFO = strtobool(os.environ.get('PRESERVE_EXIF_INFO', 'False'))
# enable this options to specify client-side cache in seconds
MAX_AGE = int(os.environ.get('MAX_AGE', 24 * 60 * 60))
# client-side caching time for temporary images (using queued detectors or after detection errors)
MAX_AGE_TEMP_IMAGE = int(os.environ.get('MAX_AGE_TEMP_IMAGE', 0))
# Sends If-Modified-Since & Last-Modified headers; requires support from result storage
SEND_IF_MODIFIED_LAST_MODIFIED_HEADERS = strtobool(os.environ.get('SEND_IF_MODIFIED_LAST_MODIFIED_HEADERS', 'False'))
# the way images are to be loaded
LOADER = os.environ.get('LOADER', 'thumbor.loaders.http_loader')
# LOADER = 'thumbor.loaders.file_loader'
# the path to find images
FILE_LOADER_ROOT_PATH = os.environ.get('FILE_LOADER_ROOT_PATH', './images')
# maximum size of the source image in Kbytes.
# use 0 for no limit.
# this is a very important measure to disencourage very
# large source images.
# THIS ONLY WORKS WITH http_loader.
MAX_SOURCE_SIZE = int(os.environ.get('MAX_SOURCE_SIZE', 0))
# if you set UPLOAD_ENABLED to True,
# a route /upload will be enabled for your thumbor process
# You can then do a put to this URL to store the photo
# using the specified Storage
UPLOAD_ENABLED = strtobool(os.environ.get('UPLOAD_ENABLED', 'False'))
UPLOAD_PHOTO_STORAGE = os.environ.get('UPLOAD_PHOTO_STORAGE','thumbor.storages.file_storage')
UPLOAD_PUT_ALLOWED = strtobool(os.environ.get('UPLOAD_PUT_ALLOWED', 'False'))
UPLOAD_DELETE_ALLOWED = strtobool(os.environ.get('UPLOAD_DELETE_ALLOWED', 'False'))
UPLOAD_DEFAULT_FILENAME = os.environ.get('UPLOAD_DEFAULT_FILENAME','image')
# how to store the loaded images so we don't have to load
# them again with the loader
#STORAGE = 'thumbor.storages.redis_storage'
# STORAGE = 'thumbor.storages.no_storage'
STORAGE = os.environ.get('STORAGE','thumbor.storages.file_storage')
#STORAGE = 'thumbor.storages.mixed_storage'
#STORAGE = 'thumbor.storages.memcache_storage'
# root path of the file storage
FILE_STORAGE_ROOT_PATH = os.environ.get('FILE_STORAGE_ROOT_PATH',os.path.join(home, 'thumbor', 'storage' ))
# If you want to cache results, use this options to specify how to cache it
# Set Expiration seconds to ZERO if you want them not to expire.
RESULT_STORAGE = os.environ.get('RESULT_STORAGE','thumbor.result_storages.file_storage')
RESULT_STORAGE_EXPIRATION_SECONDS = int(os.environ.get('RESULT_STORAGE_EXPIRATION_SECONDS', 60 * 60 * 24))
RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = os.environ.get('RESULT_STORAGE_FILE_STORAGE_ROOT_PATH', os.path.join(home, 'thumbor', 'result_storage'))
RESULT_STORAGE_STORES_UNSAFE = strtobool(os.environ.get('RESULT_STORAGE_STORES_UNSAFE', 'False'))
# stores the crypto key in each image in the storage
# this is VERY useful to allow changing the security key
STORES_CRYPTO_KEY_FOR_EACH_IMAGE = strtobool(os.environ.get('STORES_CRYPTO_KEY_FOR_EACH_IMAGE', 'True'))
MEMCACHE_STORAGE_SERVERS = eval(os.environ.get('MEMCACHE_STORAGE_SERVERS', '[]'))
# imaging engine to use to process images
ENGINE = os.environ.get('ENGINE', 'thumbor.engines.pil')
# if you need to use the OpenCV engine please refer
# to https://github.com/thumbor/opencv-engine
#ENGINE = 'opencv_engine'
# if you need to use the GraphicsMagick engine please refer
# to https://github.com/thumbor/graphicsmagick-engine
#ENGINE = 'graphicsmagick_engine'
# The graphics engine (and any optimizers) will block the IOLoop. If you want
# to increase the number of concurrent requests Thumbor can handle, increase
# ENGINE_THREADPOOLSIZE to use a thread pool. Benchmarks indicate 1xnumber of
# cpus - 2x number of cpus gives the best results, but do some benchmarks with
# your workload.
ENGINE_THREADPOOL_SIZE = int(os.environ.get('RESULT_STORAGE_EXPIRATION_SECONDS', 0))
# detectors to use to find Focal Points in the image
# more about detectors can be found in thumbor's docs
# at https://github.com/thumbor/thumbor/wiki
DETECTORS = eval(os.environ.get('DETECTORS', "['thumbor.detectors.face_detector','thumbor.detectors.profile_detector','thumbor.detectors.feature_detector']"))
# Redis parameters for queued detectors
REDIS_QUEUE_SERVER_HOST = os.environ.get('REDIS_QUEUE_SERVER_HOST', '')
REDIS_QUEUE_SERVER_PORT = os.environ.get('REDIS_QUEUE_SERVER_PORT', '')
REDIS_QUEUE_SERVER_DB = os.environ.get('REDIS_QUEUE_SERVER_DB', '')
REDIS_QUEUE_SERVER_PASSWORD = os.environ.get('REDIS_QUEUE_SERVER_PASSWORD', '')
# AWS SQS parameters for queued detectors
SQS_QUEUE_KEY_ID = os.environ.get('SQS_QUEUE_KEY_ID', '')
SQS_QUEUE_KEY_SECRET = os.environ.get('SQS_QUEUE_KEY_SECRET', '')
SQS_QUEUE_REGION = os.environ.get('SQS_QUEUE_REGION', '')
# if you use face detection this is the file that
# OpenCV will use to find faces. The default should be
# fine, so change this at your own peril.
# if you set a relative path it will be relative to
# the thumbor/detectors/face_detector folder
#FACE_DETECTOR_CASCADE_FILE = os.environ.get('FACE_DETECTOR_CASCADE_FILE', '')
# this is the security key used to encrypt/decrypt urls.
# make sure this is unique and not well-known
# This can be any string of up to 16 characters
SECURITY_KEY = os.environ.get('SECURITY_KEY', '1234567890')
# if you enable this, the unencryted URL will be available
# to users.
# IT IS VERY ADVISED TO SET THIS TO False TO STOP OVERLOADING
# OF THE SERVER FROM MALICIOUS USERS
ALLOW_UNSAFE_URL = strtobool(os.environ.get('ALLOW_UNSAFE_URL', 'False'))
# Mixed storage classes. Change them to the fullname of the
# storage you desire for each operation.
MIXED_STORAGE_FILE_STORAGE = os.environ.get('MIXED_STORAGE_FILE_STORAGE','thumbor.storages.file_storage')
MIXED_STORAGE_CRYPTO_STORAGE = os.environ.get('MIXED_STORAGE_CRYPTO_STORAGE','thumbor.storages.no_storage')
MIXED_STORAGE_DETECTOR_STORAGE = os.environ.get('MIXED_STORAGE_DETECTOR_STORAGE','thumbor.storages.no_storage')
# This configuration indicates whether thumbor should use a
# custom error handler.
# Defaults to: False
USE_CUSTOM_ERROR_HANDLING=strtobool(os.environ.get('USE_CUSTOM_ERROR_HANDLING', 'False'))
ERROR_HANDLER_MODULE=os.environ.get('ERROR_HANDLER_MODULE','thumbor.error_handlers.sentry')
SENTRY_DSN_URL=os.environ.get('SENTRY_DSN_URL','')
SENTRY_ENVIRONMENT=os.environ.get('SENTRY_ENVIRONMENT',None)
FILTERS = eval(os.environ.get('FILTERS', "['thumbor.filters.brightness','thumbor.filters.colorize','thumbor.filters.contrast','thumbor.filters.rgb','thumbor.filters.round_corner','thumbor.filters.quality','thumbor.filters.noise','thumbor.filters.watermark','thumbor.filters.equalize','thumbor.filters.fill','thumbor.filters.saturation','thumbor.filters.sharpen','thumbor.filters.strip_exif','thumbor.filters.strip_icc','thumbor.filters.frame','thumbor.filters.grayscale','thumbor.filters.rotate','thumbor.filters.format','thumbor.filters.max_bytes','thumbor.filters.no_upscale']"))
OPTIMIZERS = eval(os.environ.get('OPTIMIZERS', "['thumbor.optimizers.jpegtran','thumbor.optimizers.gifv']"))
JPEGTRAN_PATH = os.environ.get('JPEGTRAN_PATH','jpegtran')
# If the CurlAsyncHTTPClient should be used
# Defaults to: False
HTTP_LOADER_CURL_ASYNC_HTTP_CLIENT = strtobool(os.environ.get('HTTP_LOADER_CURL_ASYNC_HTTP_CLIENT', 'False'))
# If the CurlAsyncHTTPClient is being used and
# should timeout on slow download speed.
# SPEED in bytes/s and TIME in s
# Dfaults to: 0 (no timeout)
HTTP_LOADER_CURL_LOW_SPEED_TIME = int(os.environ.get('HTTP_LOADER_CURL_LOW_SPEED_TIME', 0))
HTTP_LOADER_CURL_LOW_SPEED_LIMIT = int(os.environ.get('HTTP_LOADER_CURL_LOW_SPEED_LIMIT', 0))
HEALTHCHECK_ROUTE=os.environ.get('HEALTHCHECK_ROUTE', '/status')
HTTP_LOADER_VALIDATE_CERTS = False