<commit_before>Pilbox
======

.. image:: https://pypip.in/v/pilbox/badge.png
    :target: https://pypi.python.org/pypi/pilbox

.. image:: https://travis-ci.org/agschwender/pilbox.png
    :target: https://travis-ci.org/agschwender/pilbox

.. image:: https://coveralls.io/repos/agschwender/pilbox/badge.png
    :target: https://coveralls.io/r/agschwender/pilbox

.. image:: https://pypip.in/d/pilbox/badge.png
    :target: https://pypi.python.org/pypi/pilbox


Pilbox is an image resizing application server built on Python's
`Tornado web framework <http://www.tornadoweb.org/en/stable/>`_ using
the `Python Imaging Library
(Pillow) <https://pypi.python.org/pypi/Pillow/>`_. It is not
intended to be the primary source of images, but instead acts as a proxy
which requests images and resizes them as desired.

Setup
=====

Dependencies
------------

-  >= `Python 2.7 <http://www.python.org/download/>`_
-  `Pillow 2.4.0 <https://pypi.python.org/pypi/Pillow/2.4.0>`_
-  `Tornado 3.2.1 <https://pypi.python.org/pypi/tornado/3.2.1>`_
-  `OpenCV 2.x <http://opencv.org/>`_ (optional)
-  Image Libraries: libjpeg-dev, libfreetype6-dev, libwebp-dev,
   zlib1g-dev, liblcms2-dev

Install
-------

Pilbox can be installed with pip

::

    $ pip install pilbox

Or easy_install

::

    $ easy_install pilbox

Or from source

::

    $ git clone https://github.com/agschwender/pilbox.git

Packaged with Pilbox is a `Vagrant <http://www.vagrantup.com/>`_
configuration file which installs all necessary dependencies on a
virtual box using `Ansible <http://www.ansibleworks.com/>`_. See the
`Vagrant documentation <http://docs.vagrantup.com/v2/installation/>`_
and the `Ansible
documentation <http://www.ansibleworks.com/docs/gettingstarted.html#getting-ansible>`_
for installation instructions. Once installed, the following will start
and provision a virtual machine.

::

    $ vagrant up
    $ vagrant provision

To access the virtual machine itself, simply...

::

    $ vagrant ssh

When running via Vagrant, the application is automatically started on
port 8888 on 192.168.100.100, i.e.

::

    http://192.168.100.100:8888/


Running
=======

To run the application, issue the following command

::

    $ python -m pilbox.app

By default, this will run the application on port 8888 and can be
accessed by visiting:

::

    http://localhost:8888/

To see a list of all available options, run

::

    $ python -m pilbox.app --help
    Usage: pilbox/app.py [OPTIONS]

    Options:

      --allowed_hosts            list of allowed hosts (default [])
      --allowed_operations       list of allowed operations (default [])
      --background               default hexadecimal bg color (RGB or ARGB)
      --client_key               client key
      --client_name              client name
      --config                   path to configuration file
      --content_type_from_image  override content type using image mime type
      --debug                    run in debug mode
      --expand                   default to expand when rotating
      --filter                   default filter to use when resizing
      --help                     show this help information
      --implicit_base_url        prepend protocol/host to url paths
      --max_requests             max concurrent requests (default 40)
      --operation                default operation to perform
      --optimize                 default to optimize when saving
      --port                     run on the given port (default 8888)
      --position                 default cropping position
      --progressive              default to progressive when saving
      --quality                  default jpeg quality, 0-100
      --timeout                  timeout of requests in seconds (default 10)
      --validate_cert            validate certificates (default True)


Calling
=======

To use the image resizing service, include the application url as you
would any other image. E.g. this image url

::

    <img src="http://i.imgur.com/zZ8XmBA.jpg" />

Would be replaced with this image url

::

    <img src="http://localhost:8888/?url=http%3A%2F%2Fi.imgur.com%2FzZ8XmBA.jpg&w=300&h=300&mode=crop" />

This will request the image served at the supplied url and resize it to
``300x300`` using the ``crop`` mode. The below is the list of parameters
that can be supplied to the service.

General Parameters
------------------

-  *url*: The url of the image to be resized
-  *op*: The operation to perform: noop, resize (default), rotate

   -  *noop*: No operation is performed, image is returned as it is
      received
   -  *region*: Select a sub-region from the image
   -  *resize*: Resize the image
   -  *rotate*: Rotate the image

Resize Parameters
-----------------

-  *w*: The desired width of the image
-  *h*: The desired height of the image
-  *mode*: The resizing method: clip, crop (default), fill and scale

   -  *clip*: Resize to fit within the desired region, keeping aspect
      ratio
   -  *crop*: Resize so one dimension fits within region, center, cut
      remaining
   -  *fill*: Fills the clipped space with a background color
   -  *scale*: Resize to fit within the desired region, ignoring aspect
      ratio
<commit_msg>Update README proxies and other minor changes<commit_after>Pilbox
======

.. image:: https://pypip.in/v/pilbox/badge.png
    :target: https://pypi.python.org/pypi/pilbox

.. image:: https://travis-ci.org/agschwender/pilbox.png
    :target: https://travis-ci.org/agschwender/pilbox

.. image:: https://coveralls.io/repos/agschwender/pilbox/badge.png
    :target: https://coveralls.io/r/agschwender/pilbox

.. image:: https://pypip.in/d/pilbox/badge.png
    :target: https://pypi.python.org/pypi/pilbox


Pilbox is an image processing application server built on Python's
`Tornado web framework <http://www.tornadoweb.org/en/stable/>`_ using
the `Python Imaging Library
(Pillow) <https://pypi.python.org/pypi/Pillow/>`_. It is not
intended to be the primary source of images, but instead acts as a proxy
which requests images and resizes them as desired.

Setup
=====

Dependencies
------------

-  >= `Python 2.7 <http://www.python.org/download/>`_
-  `Pillow 2.4.0 <https://pypi.python.org/pypi/Pillow/2.4.0>`_
-  `Tornado 3.2.1 <https://pypi.python.org/pypi/tornado/3.2.1>`_
-  `OpenCV 2.x <http://opencv.org/>`_ (optional)
-  `PycURL 7.x <http://pycurl.sourceforge.net/>`_ (optional; required for proxy requests)
-  Image Libraries: libjpeg-dev, libfreetype6-dev, libwebp-dev,
   zlib1g-dev, liblcms2-dev

Install
-------

Pilbox can be installed with pip

::

    $ pip install pilbox

Or easy_install

::

    $ easy_install pilbox

Or from source

::

    $ git clone https://github.com/agschwender/pilbox.git

Packaged with Pilbox is a `Vagrant <http://www.vagrantup.com/>`_
configuration file which installs all necessary dependencies on a
virtual box using `Ansible <http://www.ansibleworks.com/>`_. See the
`Vagrant documentation <http://docs.vagrantup.com/v2/installation/>`_
and the `Ansible
documentation <http://www.ansibleworks.com/docs/gettingstarted.html#getting-ansible>`_
for installation instructions. Once installed, the following will start
and provision a virtual machine.

::

    $ vagrant up
    $ vagrant provision

To access the virtual machine itself, simply...

::

    $ vagrant ssh

When running via Vagrant, the application is automatically started on
port 8888 on 192.168.100.100, i.e.

::

    http://192.168.100.100:8888/


Running
=======

To run the application, issue the following command

::

    $ python -m pilbox.app

By default, this will run the application on port 8888 and can be
accessed by visiting:

::

    http://localhost:8888/

To see a list of all available options, run

::

    $ python -m pilbox.app --help
    Usage: pilbox/app.py [OPTIONS]

    Options:

      --allowed_hosts            list of allowed hosts (default [])
      --allowed_operations       list of allowed operations (default [])
      --background               default hexadecimal bg color (RGB or ARGB)
      --client_key               client key
      --client_name              client name
      --config                   path to configuration file
      --content_type_from_image  override content type using image mime type
      --debug                    run in debug mode
      --expand                   default to expand when rotating
      --filter                   default filter to use when resizing
      --help                     show this help information
      --implicit_base_url        prepend protocol/host to url paths
      --max_requests             max concurrent requests (default 40)
      --operation                default operation to perform
      --optimize                 default to optimize when saving
      --port                     run on the given port (default 8888)
      --position                 default cropping position
      --progressive              default to progressive when saving
      --proxy_host               proxy hostname
      --proxy_port               proxy port
      --quality                  default jpeg quality, 0-100
      --timeout                  timeout of requests in seconds (default 10)
      --validate_cert            validate certificates (default True)


Calling
=======

To use the image processing service, include the application url as you
would any other image. E.g. this image url

::

    <img src="http://i.imgur.com/zZ8XmBA.jpg" />

Would be replaced with this image url

::

    <img src="http://localhost:8888/?url=http%3A%2F%2Fi.imgur.com%2FzZ8XmBA.jpg&w=300&h=300&mode=crop" />

This will request the image served at the supplied url and resize it to
``300x300`` using the ``crop`` mode. The below is the list of parameters
that can be supplied to the service.

General Parameters
------------------

-  *url*: The url of the image to be resized
-  *op*: The operation to perform: noop, region, resize (default), rotate

   -  *noop*: No operation is performed, image is returned as it is
      received
   -  *region*: Select a sub-region from the image
   -  *resize*: Resize the image
   -  *rotate*: Rotate the image

Resize Parameters
-----------------

-  *w*: The desired width of the image
-  *h*: The desired height of the image
-  *mode*: The resizing method: clip, crop (default), fill and scale

   -  *clip*: Resize to fit within the desired region, keeping aspect
      ratio
   -  *crop*: Resize so one dimension fits within region, center, cut
      remaining
   -  *fill*: Fills the clipped space with a background color
   -  *scale*: Resize to fit within the desired region, ignoring aspect
      ratio

{'fraction_non_alphanumeric': 0.1107986501687289, 'fraction_numerical': 0.017529058867641546, 'mean_word_length': 2.447172859450727, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 30, 'https://': 24, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5720851', 'n_tokens_mistral': 3381, 'n_tokens_neox': 3142, 'n_words': 1073}