[Python-modules-commits] [willow] 01/04: import willow_0.3.1.orig.tar.gz
Christopher Hoskin
christopher.hoskin at gmail.com
Sun Sep 11 20:29:50 UTC 2016
This is an automated email from the git hooks/post-receive script.
grinorcole-guest pushed a commit to branch master
in repository willow.
commit b16000d074b69f68aca2e22958bc3c965e9ea2e0
Author: Christopher Hoskin <christopher.hoskin at gmail.com>
Date: Sun Sep 11 21:06:53 2016 +0100
import willow_0.3.1.orig.tar.gz
---
.drone.yml | 4 +
.gitignore | 6 +
.travis.yml | 17 +
CHANGELOG.txt | 1 +
Dockerfile | 8 +
LICENSE | 27 +
MANIFEST.in | 4 +
docker-test.sh | 5 +
docs/.gitignore | 1 +
docs/Makefile | 182 +
docs/_static/.gitkeep | 0
docs/autobuild.sh | 4 +
docs/changelog.rst | 53 +
docs/concepts.rst | 67 +
docs/conf.py | 278 +
docs/guide/extend.rst | 161 +
docs/guide/index.rst | 20 +
docs/guide/open.rst | 60 +
docs/guide/operations.rst | 125 +
docs/guide/save.rst | 32 +
docs/index.rst | 24 +
docs/installation.rst | 24 +
docs/reference.rst | 277 +
docs/spelling_wordlist.txt | 0
readme.rst | 90 +
requirements-dev.txt | 1 +
runtests.py | 17 +
setup.cfg | 2 +
setup.py | 48 +
tests/__init__.py | 0
tests/images/flower.jpg | Bin 0 -> 32764 bytes
tests/images/newtons_cradle.gif | Bin 0 -> 297216 bytes
tests/images/orientation/README | 1 +
tests/images/orientation/landscape_1.jpg | Bin 0 -> 139435 bytes
tests/images/orientation/landscape_2.jpg | Bin 0 -> 137359 bytes
tests/images/orientation/landscape_3.jpg | Bin 0 -> 140965 bytes
tests/images/orientation/landscape_4.jpg | Bin 0 -> 140588 bytes
tests/images/orientation/landscape_5.jpg | Bin 0 -> 137611 bytes
tests/images/orientation/landscape_6.jpg | Bin 0 -> 137628 bytes
tests/images/orientation/landscape_7.jpg | Bin 0 -> 140645 bytes
tests/images/orientation/landscape_8.jpg | Bin 0 -> 141286 bytes
tests/images/people.jpg | Bin 0 -> 69263 bytes
tests/images/transparent.gif | Bin 0 -> 14437 bytes
tests/images/transparent.png | Bin 0 -> 26538 bytes
tests/test_image.py | 106 +
tests/test_opencv.py | 42 +
tests/test_pillow.py | 219 +
tests/test_registry.py | 381 +
tests/test_wand.py | 186 +
willow/__init__.py | 30 +
.../data/cascades/haarcascade_frontalface_alt2.xml | 23550 +++++++++++++++++++
willow/image.py | 171 +
willow/plugins/__init__.py | 0
willow/plugins/opencv.py | 112 +
willow/plugins/pillow.py | 160 +
willow/plugins/wand.py | 138 +
willow/registry.py | 337 +
willow/utils/__init__.py | 0
willow/utils/deprecation.py | 2 +
59 files changed, 26973 insertions(+)
diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..e6135dc
--- /dev/null
+++ b/.drone.yml
@@ -0,0 +1,4 @@
+build:
+ image: willow-ci
+ commands:
+ - python runtests.py --opencv
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0a7b971
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+*.pyc
+*.swp
+/build
+/Willow.egg-info
+/dist
+/venv
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..8a815d0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+language: python
+
+# Test matrix
+python:
+ - 2.7
+ - 3.3
+ - 3.4
+ - 3.5
+
+# Package installation
+install:
+ - pip install Pillow Wand
+ - python setup.py install
+
+# Run the tests
+script:
+ python runtests.py
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
new file mode 100644
index 0000000..e18a168
--- /dev/null
+++ b/CHANGELOG.txt
@@ -0,0 +1 @@
+The changelog has moved to http://willow.readthedocs.org/en/latest/changelog.html
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..af6ff5e
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,8 @@
+FROM debian:jessie
+MAINTAINER Karl Hobley <karlhobley10 at gmail.com>
+
+RUN apt-get update -y
+RUN apt-get install -y python python-opencv python-numpy python-pillow python-wand python-mock
+
+VOLUME ["/src"]
+WORKDIR /src
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8c6aacc
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2014 Torchbox Ltd and individual contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of Torchbox nor the names of its contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..e1dab17
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,4 @@
+graft willow
+global-exclude __pycache__
+global-exclude *.py[co]
+global-exclude *.swp
diff --git a/docker-test.sh b/docker-test.sh
new file mode 100755
index 0000000..06a4bbb
--- /dev/null
+++ b/docker-test.sh
@@ -0,0 +1,5 @@
+# Runs the tests using the provided Dockerfile
+# Saves having to install OpenCV locally
+
+docker build -t willow .
+docker run --rm -ti -v $(pwd):/src willow python runtests.py --opencv
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 0000000..a485625
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1 @@
+/_build
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..2333c27
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,182 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+spelling:
+ $(SPHINXBUILD) -b spelling $(ALLSPHINXOPTS) $(BUILDDIR)/spelling
+ @echo
+ @echo "Spellcheck complete."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Wagtail.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Wagtail.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/Wagtail"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Wagtail"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/docs/_static/.gitkeep b/docs/_static/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docs/autobuild.sh b/docs/autobuild.sh
new file mode 100755
index 0000000..f31a2a8
--- /dev/null
+++ b/docs/autobuild.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+echo "Waiting for you to save the docs..."
+watchmedo shell-command --patterns="*.rst" --ignore-pattern='_build/*' --recursive --command='make html; echo "Waiting for more changes..."'
diff --git a/docs/changelog.rst b/docs/changelog.rst
new file mode 100644
index 0000000..a3a9de5
--- /dev/null
+++ b/docs/changelog.rst
@@ -0,0 +1,53 @@
+Changelog
+=========
+
+0.4 (IN DEVELOPMENT)
+--------------------
+
+ - Added documentation
+
+0.3.1 (IN DEVELOPMENT)
+----------------------
+
+ - Fixed crash in the Pillow auto_orient operation when the image has an invalid Orientation EXIF Tag (Sigurdur J Eggertsson)
+ - The ``auto_orient`` operation now catches all errors raised while reading EXIF data (Tomas Olander)
+ - Palette formatted PNG and GIF files that have transparency no longer lose their transparency when resizing them
+
+0.3 (09/03/2016)
+----------------
+
+A major internals refactor has taken place in this release, there are a number of breaking changes:
+
+ - The Image class is now immutable. Previously, "resize" and "crop" operations altered the image in-place but now they now always return a new image leaving the original untouched.
+ - There are now multiple Image classes. Each one represents possible state the image can be in (eg, in a file, loaded in Pillow, etc). Operations can return an image in a different class to what the operation was performed on.
+ - The "backends" have been renamed to "plugins".
+ - A new registry module has been added which can be used for registering new plugins and operations.
+ - The "original_format" attribute has been deprecated.
+
+Other changes in this release:
+
+- Added auto_orient operation
+
+0.2.1 (27/05/2015)
+------------------
+
+- JPEGs are now detected from first two bytes of their file. Allowing non JFIF/EXIF JPEG images to be loaded
+
+0.2 (01/04/2015)
+----------------
+
+- Added loader for BMP files
+- Added has_alpha and has_animation operations
+- Added get_pillow_image and get_wand_image operations
+- Added save_as_{jpeg,png,gif} operations
+- Crop and resize now all arguments in a tuple (Similar to Pillow)
+- Dropped Python 2.6 and 3.2 support
+- Formats now detected using images header instead of extension
+- Now possible to specify alternative cascade file for face detection
+- Fix: Images now saved in the same format they were loaded
+- Fix: 1 and P formatted images now converted to RGB when saving to JPEG
+
+0.1 (22/02/2015)
+----------------
+
+Initial release
diff --git a/docs/concepts.rst b/docs/concepts.rst
new file mode 100644
index 0000000..f5e3f59
--- /dev/null
+++ b/docs/concepts.rst
@@ -0,0 +1,67 @@
+Concepts
+========
+
+Image classes
+-------------
+
+An image can either be a file, an image loaded into an underlying library or a
+simple buffer of pixels. Each of these states has its own Python class
+(subclass of :class:`willow.image.Image`).
+
+For example ``JPEGImageFile``, ``PillowImage`` and ``RGBAImageBuffer`` are three
+of the image classes in Willow.
+
+Operations
+----------
+
+These are functions that perform actions on an image in a particular state. For
+example, ``resize`` and ``crop``.
+
+Operations can either be defined as methods on the image class or as functions
+registered separately.
+
+All operations are registered in a central registry and will appear as a method
+on all other image classes. If it's called from a class that doesn't implement
+the operation, the image will be automatically converted to the nearest image
+class that supports it and the operation is run on that.
+
+Operations that alter an image return a new image object instead of altering the
+source one. This also means that if a conversion took place, the new image's
+class would be different.
+
+Converters
+----------
+
+These are functions that convert an image between two image classes. For
+example, a converter from ``JPEGImageFile`` to ``PillowImage`` would simply be a
+function that calls ``PIL.Image.open`` on the underlying file to get a Pillow
+image.
+
+Like operations, these can either be methods on the image class or registered
+separately.
+
+Each converter has a cost which helps Willow decide which is the best available
+image library to use for a particular file format.
+
+Registry
+--------
+
+The registry is where all image classes, operations and converters are
+registered. It contains methods to allow you to register new items and even
+override existing ones.
+
+It also is responsible for finding operations and planning routes between image
+classes.
+
+Plugins
+-------
+
+These are used to group related image classes, operations and converters
+together allowing them to be registered as a single unit.
+
+The convention within Willow is to create a single plugin for each underlying
+library. The default ones are "pillow", "wand" and "opencv".
+
+Plugins can be registered even if the underlying library is not installed. This
+allows Willow to generate a useful error message if an operation is requested
+that only exists in a plugin without an underlying library.
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..80b0740
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,278 @@
+# -*- coding: utf-8 -*-
+#
+# Willow documentation build configuration file, created by
+# sphinx-quickstart on Tue Jan 14 17:38:55 2014.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+
+# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if not on_rtd: # only import and set the theme if we're building docs locally
+ import sphinx_rtd_theme
+ html_theme = 'sphinx_rtd_theme'
+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath('..'))
+
+# Get Willow version
+from willow import __version__
+
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+]
+
+if not on_rtd:
+ extensions.append('sphinxcontrib.spelling')
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = 'Willow'
+copyright = '2015, Torchbox'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = __version__
+# The full version, including alpha/beta/rc tags.
+release = __version__
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# splhinxcontrib.spelling settings
+
+spelling_lang = 'en_GB'
+spelling_word_list_filename='spelling_wordlist.txt'
+
+
+# -- Options for HTML output ----------------------------------------------
+
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = 'logo.png'
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'Willowdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ ('index', 'Willow.tex', 'Willow Documentation',
+ 'Torchbox', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'wagtail', 'Willow Documentation',
+ ['Torchbox'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ ('index', 'Willow', 'Willow Documentation',
+ 'Torchbox', 'Willow', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
diff --git a/docs/guide/extend.rst b/docs/guide/extend.rst
new file mode 100644
index 0000000..bbe271b
--- /dev/null
+++ b/docs/guide/extend.rst
@@ -0,0 +1,161 @@
+Extending Willow
+================
+
+This section describes how to extend Willow with custom operations, image formats
+and plugins.
+
+Don't forget to look at the :doc:`concepts </concepts>` section first!
+
+Implementing new operations
+---------------------------
+
+You can add operations to any existing image class and register them by calling the
+:meth:`Registry.register_operation` method passing it the image class, name of
+the operation and the function to call when the operation is used.
+
+For example, let's implement a ``blur`` operation for both the
+:class:`~willow.plugins.pillow.PillowImage` and :class:`~willow.plugins.wand.WandImage`
+classes:
+
+.. code-block:: python
+
+ from willow.registry import registry
+ from willow.plugins.pillow import PillowImage
+ from willow.plugins.wand import WandImage
+
+ def pillow_blur(image):
+ from PIL import ImageFilter
+
+ blurred_image = image.image.filter(ImageFilter.BLUR)
+ return PillowImage(blurred_image)
+
+ def wand_blur(image):
+ # Wand modifies images in place so clone it first to prevent
+ # altering the original image
+ blurred_image = image.image.clone()
+ blurred_image.gaussian_blur()
+ return WandImage(blurred_image)
+
+
+ # Register the operations in Willow
+
+ registry.register_operation(PillowImage, 'blur', pillow_blur)
+ registry.register_operation(WandImage, 'blur', wand_blur)
+
+It is not required to support both :class:`~willow.plugins.pillow.PillowImage`
+and :class:`~willow.plugins.wand.WandImage` but it's recommended that libraries
+support both for maximum compatibility. You must support Wand if you need
+animated GIF support.
+
+Implementing custom image classes
+---------------------------------
+
+You can create your own image classes and register them by calling the
+:meth:`Registry.register_image_class` method. All image classes must be a
+subclass of :class:`willow.image.Image`.
+
+Methods on image classes can be decorated with ``@Image.operation``,
+``@Image.converter_from`` or ``@Image.converter_to`` which will make Willow
+automatically register those methods as operations or converters.
+
+For example, let's implement our own image class for Pillow:
+
+.. code-block:: python
+
+ from __future__ import absolute_import
+
+ import PIL.Image
+
+ from willow.image import (
+ Image,
+ JPEGImageFile,
+ PNGImageFile,
+ GIFImageFile,
+ )
+
+
+ class NewPillowImage(Image):
+ def __init__(self, image):
+ self.image = image
+
+
+ # Informational operations
+
+ @Image.operation
+ def get_size(self):
+ return self.image.size
+
+ @Image.operation
+ def has_alpha(self):
+ img = self.image
+ return img.mode in ('RGBA', 'LA') or (img.mode == 'P' and 'transparency' in img.info)
+
+ @Image.operation
+ def has_animation(self):
+ # Animation is not supported by PIL
+ return False
+
+
+ # Resize and crop operations
+
+ @Image.operation
+ def resize(self, size):
+ return PillowImage(image.resize(size, PIL.Image.ANTIALIAS))
+
+ @Image.operation
+ def crop(self, rect):
+ return PillowImage(self.image.crop(rect))
+
+
+ # Converter from supported file formats, this is where the image is opened
+
+ # Pillow doesn't support GIFs very well. Adding a cost will make Willow try
+ # a different image class first. The default cost for all converters is 100.
+
+ @classmethod
+ @Image.converter_from(JPEGImageFile)
+ @Image.converter_from(PNGImageFile)
+ @Image.converter_from(GIFImageFile, cost=200)
+ @Image.converter_from(BMPImageFile)
+ def open(cls, image_file):
+ image_file.f.seek(0)
+ image = PIL.Image.open(image_file.f)
+
+ return cls(image)
+
+The image class can then be registered by calling :meth:`Registry.register_image_class`:
+
+.. code-block:: python
+
+ from willow.registry import registry
+
+ from newpillow import NewPillowImage
+
+ registry.register_image_class(NewPillowImage)
+
+This will also register all operations and converters defined on the class.
+
+
+Plugins
+-------
+
+Plugins allow multiple image classes and/or operations to be registered together.
+They are Python modules with any of the following attributes defined:
+``willow_image_classes``, ``willow_operations`` or ``willow_converters``.
+
+For example, we can convert the Python module in the example above into a Willow
+plugin by adding the following line at the bottom of the file:
+
+.. code-block:: python
+
+ willow_image_operations = [NewPillowImage]
+
+It can now be registered using the :meth:`Registry.register_plugin` method:
+
+.. code-block:: python
+
+ from willow.registry import registry
+
+ import newpillow
+
+ registry.register_plugin(newpillow)
diff --git a/docs/guide/index.rst b/docs/guide/index.rst
new file mode 100644
index 0000000..4b324eb
--- /dev/null
+++ b/docs/guide/index.rst
@@ -0,0 +1,20 @@
+===========
+Usage guide
+===========
+
+If you're looking at Willow for the first time, have a look at the :doc:`concepts
+</concepts>` and :doc:`installation guide </installation>` first.
+
+This section describes general, everyday usage of the Willow library.
+
+Index
+=====
+
+.. toctree::
+ :maxdepth: 2
+ :titlesonly:
+
... 26353 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/willow.git
More information about the Python-modules-commits
mailing list