-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
thumbor's configuration file is just a regular python script. Tornado loads it and places the specified options under the Tornado.options.options dictionary.
The loader is responsible for retrieving the source image that thumbor will work with. This configuration defines the module that thumbor will use for it. This must be a full namespace module (a.k.a. python has to be able to import it).
i.e.: thumbor.loaders.http_loader
The storage is responsible for storing the source image bytes and related metadata (face-detection, encryption and such) so that we don't keep loading it every time. This must be a full namespace module (a.k.a. python has to be able to import it).
i.e.: thumbor.storages.file_storage
If you are using thumbor's mixed storage (thumbor.storages.mixed_storage), this is where you specify the storage that will be used to store images. This must be a full namespace module (a.k.a. python has to be able to import it).
i.e.: thumbor.storages.file_storage
If you are using thumbor's mixed storage (thumbor.storages.mixed_storage), this is where you specify the storage that will be used to store cryptography information. This must be a full namespace module (a.k.a. python has to be able to import it).
i.e.: thumbor.storages.redis_storage
If you are using thumbor's mixed storage (thumbor.storages.mixed_storage), this is where you specify the storage that will be used to store facial and feature detection results. This must be a full namespace module (a.k.a. python has to be able to import it).
i.e.: thumbor.storages.mongo_storage
The engine is responsible for transforming the image. This must be a full namespace module (a.k.a. python has to be able to import it).
Thumbor ships with three imaging engines:
- thumbor.engines.pil
- thumbor.engines.opencv
- thumbor.engines.graphicsmagick
-
thumbor.engines.imagemagick(This engine isn't supported anymore, check #52)
The result storage is responsible for storing the resulting image with the specified parameters (think of it as a cache), so that we don't keep processing it every time a request comes in. This must be a full namespace module (a.k.a. python has to be able to import it).
i.e.: thumbor.result_storages.file_storage
In order to specify the filters that thumbor will use, you need a configuration key called FILTERS. This is a regular python list with the full names (names that python can import) of the filter modules you want to use.
An example:
FILTERS = [
'thumbor.filters.brightness',
'thumbor.filters.contrast',
'thumbor.filters.rgb',
'thumbor.filters.round_corner',
'thumbor.filters.quality',
'thumbor.filters.noise',
'thumbor.filters.watermark',
]
If you want thumbor to use JSONP for image metadata instead of using JSON, just set this variable to the callback name you want.
i.e.: "thumbor_callback"
This options specifies the detectors that should run the image to check for focal points.
i.e.: ["thumbor.detectors.face_detector", "thumbor.detectors.feature_detector"]
This option specifies the cascade (XML) file path to train openCV to find faces.
i.e.: haarcascade_frontalface_alt.xml
This configuration defines the source of the images that thumbor will load. This is only used in the HttpLoader (check the LOADER configuration above).
i.e.: ALLOWED_SOURCE=['http://s.glbimg.com']
These define the box that the resulting image for thumbor must fit-in. This means that no image that thumbor generates will have a width larger than MAX_WIDTH or height larger than MAX_HEIGHT.
i.e.: MAX_WIDTH = 1200 MAX_HEIGHT = 800
This option defines the quality that JPEG images will be generated with. It defaults to 80.
i.e.: QUALITY = 90
This option specifies the security key that thumbor uses to decrypt encrypted URLs. This should be a 16-char key.
i.e.: 1234567890123456
This option specifies that the /unsafe url should be available in this thumbor instance. It is boolean (True or False).
In case you are using thumbor's built-in file loader, this is the option that allows you to specify where to find the images.
This options specifies the default expiration time in seconds for the storage.
i.e.: 60 (1 minute)
This option specifies whether thumbor should store the key for each image (thus allowing the image to be found even if the security key changes). This is a boolean flag (True or False).
In case you are using thumbor's built-in file storage, this is the option that allows you to specify where to save the images.
This is the option that specifies the host for mongodb.
i.e.: 127.0.0.1
This is the option that specifies the port where mongodb is running in.
i.e.: 27017
This is the option that specifies the database for mongodb.
i.e.: thumbor
This is the option that specifies the collection for thumbor's documents.
i.e.: images
This option specifies the host server for Redis.
i.e.: localhost
This option specifies the port that redis is listening in.
i.e.: 6379
This option specifies the database that thumbor should use.
i.e.: 0
This option specifies the password that thumbor should use to authenticate with redis.
i.e.: my-redis-password
# the domains that can have their images resized
ALLOWED_SOURCES = ['s.glbimg.com', 'www.globo.com']
# the max width of the resized image
# use 0 for no max width - default is 0
# if the original image is larger than MAX_WIDTH x MAX_HEIGHT,
# it is proportionally resized to MAX_WIDTH x MAX_HEIGHT
MAX_WIDTH = 0
# the max height of the resized image
# use 0 for no max height - default is 0
# if the original image is larger than MAX_WIDTH x MAX_HEIGHT,
# it is proportionally resized to MAX_WIDTH x MAX_HEIGHT
MAX_HEIGHT = 0
# the quality of the generated image
# this option can vary widely between
# imaging engines and is used only on jpeg images
QUALITY = 80
# the way images are to be loaded
LOADER = 'thumbor.loaders.http_loader'
# 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 = 500
# how to store the original images
STORAGE = 'thumbor.storages.redis_storage'
# if you are using the file storage, this is
# the path where files will get saved
FILE_STORAGE_ROOT_PATH = '/tmp'
# if you are using the Redis storage, these are
# the connection options to Redis Server.
REDIS_STORAGE_SERVER_PORT = 6379
REDIS_STORAGE_SERVER_HOST = 'localhost'
REDIS_STORAGE_SERVER_DB = 0
REDIS_STORAGE_SERVER_PASSWORD = 'my-redis-password'
# imaging engine to use to process images
ENGINE = 'thumbor.engines.graphicsmagick'
# in case imagemagick engine is used
# the path for the magickwand bindings
# this is not a required option since
# thumbor should be able to find magickwand
# on its own
MAGICKWAND_PATH = []
# detectors to use to find Focal Points in the image
# more about detectors can be found in thumbor's docs
# at https://github.com/globocom/thumbor/wiki
DETECTORS = [
'thumbor.detectors.face_detector',
'thumbor.detectors.feature_detector'
]
# 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 = 'haarcascade_frontface_alt.xml'
# if you need to use Jsonp to get metadata (cross-domain)
# use this option to specify the callback name to use
METADATA_CALLBACK_NAME = "callback"
# 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 24 characters
SECURITY_KEY = "MY_SECURE_KEY"
# 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 = True