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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
|
********
Settings
********
.. highlight:: python
``THUMBNAIL_DEBUG``
===================
- Default: ``False``
When set to ``True`` the ``ThumbnailNode.render`` method can raise errors.
Django recommends that tags never raise errors in the ``Node.render`` method
but since sorl-thumbnail is such a complex tag we will need to have more
debugging available.
``THUMBNAIL_BACKEND``
=====================
- Default: ``'sorl.thumbnail.base.ThumbnailBackend'``
This is the entry point for generating thumbnails, you probably want to keep the
default one but just in case you would like to generate thumbnails filenames
differently or need some special functionality you can override this and use
your own implementation.
``THUMBNAIL_KVSTORE``
=====================
- Default: ``'sorl.thumbnail.kvstores.cached_db_kvstore.KVStore'``
sorl-thumbnail needs a Key Value Store to :doc:`/operation`.
sorl-thumbnail ships with support for two Key Value Stores:
Cached DB
---------
``sorl.thumbnail.kvstores.cached_db_kvstore.KVStore``. This is the default and
preferred Key Value Store.
Features
^^^^^^^^
* Fast persistent storage
* First query uses database which is slow. Successive queries are cached and if
you use memcached this is very fast.
* Easy to transfer data between environments since the data is in the default
database.
* If you get the database and fast cache out of sync there could be problems.
Redis
-----
``sorl.thumbnail.kvstores.redis_kvstore.KVStore``. It requires you to install a
Redis server as well as a `redis python client
<https://github.com/andymccurdy/redis-py/>`_.
Features
^^^^^^^^
* Fast persistent storage
* More dependencies
* Requires a little extra work to transfer data between environments
Dbm
---
``sorl.thumbnail.kvstores.dbm_kvstore.KVStore``. A simple Key Value Store has no
dependencies outside the standard Python library and uses the DBM modules to
store the data.
Features
^^^^^^^^
* No external dependencies, besides the standard library
* No extra components required, e.g., database or cache
* Specially indicated for local development environments
``THUMBNAIL_KEY_DBCOLUMN``
==========================
- Default ``'key'``
Since MSSQL reserved the ``key`` name for db columns you can change this to
something else using this setting.
``THUMBNAIL_ENGINE``
====================
- Default: ``'sorl.thumbnail.engines.pil_engine.Engine'``
This is the processing class for sorl-thumbnail. It does all the resizing,
cropping or whatever processing you want to perform. sorl-thumbnail ships with
three engines:
PIL
---
``'sorl.thumbnail.engines.pil_engine.Engine'``. This is the default engine
because it is what most people have installed already. Features:
* Easy to install
* Produces good quality images but not the best
* It is fast
* Can not handle CMYK sources
Pgmagick
--------
``'sorl.thumbnail.engines.pgmagick_engine.Engine'``. Pgmagick uses `Graphics
<http://www.graphicsmagick.org/>`_. Fatures:
* Not easy to install unless on linux, very slow to compile
* Produces high quality images
* It is a tad slow?
* Can handle CMYK sources
ImageMagick / GraphicsMagick
----------------------------
``'sorl.thumbnail.engines.convert_engine.Engine'``. This engine uses the
ImageMagick ``convert`` or GraphicsMagic ``gm convert`` command. Features:
* Easy to install
* Produces high quality images
* It is pretty fast
* Can handle CMYK sources
* It is a command line command, that is less than ideal,
Wand
----------------------------
``'sorl.thumbnail.engines.wand_engine.Engine'``. This engine uses `Wand
<http://wand-py.org>`_, a ctypes-based simple ImageMagick binding for Python.
Features:
* Easy to install
* Produces high quality images
* Can handle CMYK sources
* Works on Python 2.6, 2.7, 3.2, 3.3, and PyPy
``THUMBNAIL_CONVERT``
=====================
- Default ``'convert'``
Path to convert command, use ``'gm convert'`` for GraphicsMagick.
Only applicable for the convert Engine.
``THUMBNAIL_IDENTIFY``
======================
- Default ``'identify'``
Path to identify command, use ``'gm identify'`` for GraphicsMagick.
Only applicable for the convert Engine.
``THUMBNAIL_STORAGE``
=====================
- Default: ``settings.DEFAULT_FILE_STORAGE``
The storage class to use for the generated thumbnails.
``THUMBNAIL_REDIS_DB``
======================
- Default: ``0``
The Redis database. Only applicable for the Redis Key Value Store
``THUMBNAIL_REDIS_PASSWORD``
============================
- Default: ``''``
The password for Redis server. Only applicable for the Redis Key Value Store
``THUMBNAIL_REDIS_HOST``
========================
- Default: ``'localhost'``
The host for Redis server. Only applicable for the Redis Key Value Store
``THUMBNAIL_REDIS_PORT``
========================
- Default: ``6379``
The port for Redis server. Only applicable for the Redis Key Value Store
``THUMBNAIL_DBM_FILE``
======================
- Default: ``thumbnail_kvstore``
Filename of the DBM database. Depending on the DBM engine selected by your
Python installation, this will be used as a prefix because multiple files may be
created. This can be an absolute path.
``THUMBNAIL_DBM_MODE``
======================
- Default: ``0x644``
Permission bits to use when creating new DBM files
``THUMBNAIL_CACHE_TIMEOUT``
===========================
- Default: ``3600 * 24 * 365 * 10``
Cache timeout for Cached DB Key Value Store in seconds. You should probably keep this
at maximum or ``None`` if your caching backend can handle that as infinite.
Only applicable for the Cached DB Key Value Store.
``THUMBNAIL_CACHE``
===================
- Default: ``'default'``
Cache configuration for Cached DB Key Value Store. Defaults to the ``'default'`` cache
but some applications might have multiple cache clusters.
``THUMBNAIL_KEY_PREFIX``
========================
- Default: ``'sorl-thumbnail'``
Key prefix used by the key value store.
``THUMBNAIL_PREFIX``
====================
- Default: ``'cache/'``
The generated thumbnails filename prefix.
``THUMBNAIL_FORMAT``
====================
- Default: ``'JPEG'``
Default image format, supported formats are: ``'JPEG'``, ``'PNG'``. This also implicitly
sets the filename extension. This can be overridden by individual options.
``THUMBNAIL_PRESERVE_FORMAT``
=============================
- Default: ``False``
If ``True``, the format of the input file will be preserved. If ``False``,
``THUMBNAIL_FORMAT`` will be used.
``THUMBNAIL_COLORSPACE``
========================
- Default: ``'RGB'``
Default thumbnail color space, engines are required to implement: ``'RGB'``,
``'GRAY'`` Setting this to None will keep the original color space. This can be
overridden by individual options.
``THUMBNAIL_UPSCALE``
=====================
- Default: ``True``
Should we upscale by default? ``True`` means we upscale images by default.
``False`` means we don't. This can be overridden by individual options.
``THUMBNAIL_QUALITY``
=====================
- Default: ``95``
Default thumbnail quality. A value between 0 and 100 is allowed. This can be
overridden by individual options.
``THUMBNAIL_PROGRESSIVE``
=========================
- Default: ``True``
Saves jpeg thumbnails as progressive jpegs. This can be overridden by individual
options.
``THUMBNAIL_ORIENTATION``
=========================
- Default: ``True``
Orientate the thumbnail with respect to source EXIF orientation tag
``THUMBNAIL_DUMMY``
===================
- Default: ``False``
This is a very powerful option which came from real world frustration. The use
case is when you want to do development on a deployed project that has image
references in its database. Instead of downloading all the image files from the
server hosting the deployed project and all its thumbnails we just set this
option to ``True``. This will generate placeholder images for all thumbnails
missing input source.
``THUMBNAIL_DUMMY_SOURCE``
==========================
- Default ``http://dummyimage.com/%(width)sx%(height)s``
This is the generated thumbnail whensource of the presented thumbnail. Width and
Height is passed to the string for formatting. Other options are for example:
- ``http://placehold.it/%(width)sx%(height)s``
- ``http://placekitten.com/%(width)s/%(height)s``
``THUMBNAIL_DUMMY_RATIO``
=========================
- Default: ``1.5``
This value sets an image ratio to all thumbnails that are not defined by width
**and** height since we cannot determine from the file input (since we don't
have that).
``THUMBNAIL_ALTERNATIVE_RESOLUTIONS``
=====================================
- Default: ``[]``
- Example: ``[1.5, 2]``
This value enables creation of additional high-resolution ("Retina") thumbnails
for every thumbnail. Resolution multiplicators, e.g. value 2 means for every thumbnail
of regular size x\*y, additional thumbnail of 2x\*2y size is created.
``THUMBNAIL_FILTER_WIDTH``
==========================
- Default: ``500``
This value sets the width of thumbnails inserted when running filters one texts
that regex replaces references to images with thumbnails.
``THUMBNAIL_URL_TIMEOUT``
=========================
- Default: ``None``
This value sets the timeout value in seconds when retrieving a source image from a URL.
If no timeout value is specified, it will wait indefinitely for a response.
|