Skip to content
heynemann edited this page Jul 18, 2012 · 39 revisions

thumbor's configuration file is just a regular python script that thumbor loads.

In order to get a commented configuration file, just run:

thumbor-config > ./thumbor.conf

Extensibility Section

LOADER

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

STORAGE

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

MIXED_STORAGE_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

MIXED_STORAGE_CRYPTO_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

MIXED_STORAGE_DETECTOR_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

ENGINE

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)

RESULT_STORAGE

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

Filters Section

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',
]

Metadata Section

META_CALLBACK_NAME

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"

Face and Feature Detection Section

DETECTORS

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"]

FACE_DETECTOR_CASCADE_FILE

This option specifies the cascade (XML) file path to train openCV to find faces.

i.e.: haarcascade_frontalface_alt.xml

Imaging Section

ALLOWED_SOURCES

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_SOURCES=['http://s.glbimg.com']

MAX_WIDTH and MAX_HEIGHT

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

QUALITY

This option defines the quality that JPEG images will be generated with. It defaults to 80.

i.e.: QUALITY = 90

MAX_AGE

This option defines the number of seconds that images should remain in the browser's cache. It relates directly with the Expires and Cache-Control headers.

i.e.: MAX_AGE = 24 * 60 * 60 # A day of caching

MAX_AGE_TEMP_IMAGE

When an image has some error in its detection or it has deferred queueing, it's convenient to set a much lower expiration time for the image cache. This way the browser will request the proper image faster.

This option defines the number of seconds that images in this scenario should remain in the browser's cache. It relates directly with the Expires and Cache-Control headers.

i.e.: MAX_AGE_TEMP_IMAGE = 60 # A minute of caching

RESPECT_ORIENTATION

If this option is set to True, thumbor will reorient the image according to it's EXIF Orientation tag (if one can be found). This options defaults to False.

The operations performed in the image are as follow (considering the value of the Orientation EXIF tag):

  1. Nothing
  2. Flips the image horizontally
  3. Rotates the image 180 degrees
  4. Flips the image vertically
  5. Flips the image vertically and rotates 270 degrees
  6. Rotates the image 270 degrees
  7. Flips the image horizontally and rotates 270 degrees
  8. Rotates the image 90 degrees

i.e.: RESPECT_ORIENTATION = False

Security Section

SECURITY_KEY

This option specifies the security key that thumbor uses to sign secure URLs.

i.e.: 1234567890123456

ALLOW_UNSAFE_URL

This option specifies that the /unsafe url should be available in this thumbor instance. It is boolean (True or False).

ALLOW_OLD_URLS

This option specifies that the format prior to 3.0.0-release-changes should be allowed. It defaults to True.

THIS OPTION IS DEPRECATED AND WILL DEFAULT TO FALSE IN THE NEXT MAJOR.

Loader Options Section

FILE_LOADER_ROOT_PATH

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.

Storage Options Section

STORAGE_EXPIRATION_SECONDS

This options specifies the default expiration time in seconds for the storage.

i.e.: 60 (1 minute)

STORES_CRYPTO_KEY_FOR_EACH_IMAGE

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).

File Storage Section

FILE_STORAGE_ROOT_PATH

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.

MongoDB Storage Section

MONGO_STORAGE_SERVER_HOST

This is the option that specifies the host for mongodb.

i.e.: 127.0.0.1

MONGO_STORAGE_SERVER_PORT

This is the option that specifies the port where mongodb is running in.

i.e.: 27017

MONGO_STORAGE_SERVER_DB

This is the option that specifies the database for mongodb.

i.e.: thumbor

MONGO_STORAGE_SERVER_COLLECTION

This is the option that specifies the collection for thumbor's documents.

i.e.: images

Redis Storage Section

REDIS_STORAGE_SERVER_HOST

This option specifies the host server for Redis.

i.e.: localhost

REDIS_STORAGE_SERVER_PORT

This option specifies the port that redis is listening in.

i.e.: 6379

REDIS_STORAGE_SERVER_DB

This option specifies the database that thumbor should use.

i.e.: 0

REDIS_STORAGE_SERVER_PASSWORD

This option specifies the password that thumbor should use to authenticate with redis.

i.e.: my-redis-password

Example of Configuration File

# 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:/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
Clone this wiki locally