django-webp


Namedjango-webp JSON
Version 3.0.0 PyPI version JSON
download
home_page
SummaryServes a webp version of static images to browsers instead of jpg, gif or png
upload_time2023-09-02 22:17:34
maintainer
docs_urlNone
author
requires_python>=3.5
licenseThe MIT License (MIT) Copyright (c) 2023 André Farzat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords django webp python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            django-webp
===========

Speeds up static file load times by generating a webp image to load to a webpage instead of a jpg, gif or png

|Build Status| |Coverage Status|


Usage
-----

Load the ``webp`` module in your template and use the ``webp``
templatetag to point to the image you want to convert.

.. code:: html

    {% load webp %}

    {# Use webp as you would use static templatetag #}
    <img src="{% webp 'path/to/your/image.png' %}" alt="image" />
    <!--
    If the browser has support, generates:
    <img src="/static/WEBP_CACHE/path/to/your/image.webp" alt="image" />

    else, generates:
    <img src="/static/path/to/your/image.png" alt="image" />
    -->

Installation
------------

First, if you are using a version of Pillow <= 9.3.0, you must install  webp support since earlier versions of Pillow do not 
have webp support built-in. In ubuntu, you can install via apt-get:

.. code:: sh

    apt-get install libwebp-dev

Please, check `the official guide`_ for the other systems.

Then, install ``django-webp``.

.. code:: sh

    pip install django-webp

add it to ``INSTALLED_APPS`` configuration

.. code:: python

    INSTALLED_APPS = (
        'django.contrib.staticfiles',
        'django_webp',
        '...',
    )
    
edit your installation of Whitenoise to use our slightly modded version of it

.. code:: python

    MIDDLEWARE = [
        'django.middleware.security.SecurityMiddleware',
        'django_webp.middleware.ModdedWhiteNoiseMiddleware',
        '...',
    ]

add the django\_webp context processor

.. code:: python

    TEMPLATES = [
        {
            '...'
            'OPTIONS': {
                'context_processors': [
                    '...',
                    'django_webp.context_processors.webp',
                ],
            },
        },
    ]

Settings
--------

The following Django-level settings affect the behavior of the library

- ``WEBP_CHECK_URLS``

  When set to ``True``, urls that link to externally stored images (i.e. images hosted by another site) are checked to confirm if they are valid image links.
  Ideally, this should temporarily be set to ``True`` whenever the ``WEBP_CACHE`` has been cleaned or if there has been substantial changes to your project's template files.
  This defaults to ``False``.


  


Possible Issues
-----------------

- ``django-webp`` uses ``Pillow`` to convert the images. If you’ve installed the ``libwebp-dev`` after already installed ``Pillow``, it’s necessary to uninstall and install it back because it needs to be compiled with it.
- This package was built specifically for production environments that use Whitenoise for serving static files so there currently isn't support for serving files via dedicated servers or through cloud services

Cleaning the cache
------------------

You can clean the cache running:

.. code:: sh

    python manage.py clean_webp_images

.. _the official guide: https://developers.google.com/speed/webp/docs/precompiled

.. |Build Status| image:: https://github.com/andrefarzat/django-webp/actions/workflows/django.yml/badge.svg?branch=master
   :target: https://github.com/andrefarzat/django-webp/actions/workflows/django.yml
.. |Coverage Status| image:: https://coveralls.io/repos/github/andrefarzat/django-webp/badge.svg?branch=master
   :target: https://coveralls.io/github/andrefarzat/django-webp?branch=master

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-webp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "Andre Farzat <andrefarzat@gmail.com>, Daniel Opara <daniel.opara@tufts.edu>",
    "keywords": "django,webp,python",
    "author": "",
    "author_email": "Andre Farzat <andrefarzat@gmail.com>, Daniel Opara <daniel.opara@tufts.edu>",
    "download_url": "https://files.pythonhosted.org/packages/e7/b4/177eadadb57b5d53d31f4bdb3400082b090971c7a534127c94126a2fb1c3/django-webp-3.0.0.tar.gz",
    "platform": null,
    "description": "django-webp\n===========\n\nSpeeds up static file load times by generating a webp image to load to a webpage instead of a jpg, gif or png\n\n|Build Status| |Coverage Status|\n\n\nUsage\n-----\n\nLoad the ``webp`` module in your template and use the ``webp``\ntemplatetag to point to the image you want to convert.\n\n.. code:: html\n\n    {% load webp %}\n\n    {# Use webp as you would use static templatetag #}\n    <img src=\"{% webp 'path/to/your/image.png' %}\" alt=\"image\" />\n    <!--\n    If the browser has support, generates:\n    <img src=\"/static/WEBP_CACHE/path/to/your/image.webp\" alt=\"image\" />\n\n    else, generates:\n    <img src=\"/static/path/to/your/image.png\" alt=\"image\" />\n    -->\n\nInstallation\n------------\n\nFirst, if you are using a version of Pillow <= 9.3.0, you must install  webp support since earlier versions of Pillow do not \nhave webp support built-in. In ubuntu, you can install via apt-get:\n\n.. code:: sh\n\n    apt-get install libwebp-dev\n\nPlease, check `the official guide`_ for the other systems.\n\nThen, install ``django-webp``.\n\n.. code:: sh\n\n    pip install django-webp\n\nadd it to ``INSTALLED_APPS`` configuration\n\n.. code:: python\n\n    INSTALLED_APPS = (\n        'django.contrib.staticfiles',\n        'django_webp',\n        '...',\n    )\n    \nedit your installation of Whitenoise to use our slightly modded version of it\n\n.. code:: python\n\n    MIDDLEWARE = [\n        'django.middleware.security.SecurityMiddleware',\n        'django_webp.middleware.ModdedWhiteNoiseMiddleware',\n        '...',\n    ]\n\nadd the django\\_webp context processor\n\n.. code:: python\n\n    TEMPLATES = [\n        {\n            '...'\n            'OPTIONS': {\n                'context_processors': [\n                    '...',\n                    'django_webp.context_processors.webp',\n                ],\n            },\n        },\n    ]\n\nSettings\n--------\n\nThe following Django-level settings affect the behavior of the library\n\n- ``WEBP_CHECK_URLS``\n\n  When set to ``True``, urls that link to externally stored images (i.e. images hosted by another site) are checked to confirm if they are valid image links.\n  Ideally, this should temporarily be set to ``True`` whenever the ``WEBP_CACHE`` has been cleaned or if there has been substantial changes to your project's template files.\n  This defaults to ``False``.\n\n\n  \n\n\nPossible Issues\n-----------------\n\n- ``django-webp`` uses ``Pillow`` to convert the images. If you\u2019ve installed the ``libwebp-dev`` after already installed ``Pillow``, it\u2019s necessary to uninstall and install it back because it needs to be compiled with it.\n- This package was built specifically for production environments that use Whitenoise for serving static files so there currently isn't support for serving files via dedicated servers or through cloud services\n\nCleaning the cache\n------------------\n\nYou can clean the cache running:\n\n.. code:: sh\n\n    python manage.py clean_webp_images\n\n.. _the official guide: https://developers.google.com/speed/webp/docs/precompiled\n\n.. |Build Status| image:: https://github.com/andrefarzat/django-webp/actions/workflows/django.yml/badge.svg?branch=master\n   :target: https://github.com/andrefarzat/django-webp/actions/workflows/django.yml\n.. |Coverage Status| image:: https://coveralls.io/repos/github/andrefarzat/django-webp/badge.svg?branch=master\n   :target: https://coveralls.io/github/andrefarzat/django-webp?branch=master\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2023 Andr\u00e9 Farzat  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Serves a webp version of static images to browsers instead of jpg, gif or png",
    "version": "3.0.0",
    "project_urls": {
        "Homepage": "http://pypi.python.org/pypi/django-webp/"
    },
    "split_keywords": [
        "django",
        "webp",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0472883626339e5876a580804fc0ce21e2ca585bd8a1c53734cd580d47155d7e",
                "md5": "f111995562489fe7980050cff4bfb646",
                "sha256": "67286441df0eddfad0c5d439f5092e993714975e212a1b7194ae7c8bf483abbf"
            },
            "downloads": -1,
            "filename": "django_webp-3.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f111995562489fe7980050cff4bfb646",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 11393,
            "upload_time": "2023-09-02T22:17:32",
            "upload_time_iso_8601": "2023-09-02T22:17:32.301378Z",
            "url": "https://files.pythonhosted.org/packages/04/72/883626339e5876a580804fc0ce21e2ca585bd8a1c53734cd580d47155d7e/django_webp-3.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e7b4177eadadb57b5d53d31f4bdb3400082b090971c7a534127c94126a2fb1c3",
                "md5": "d7ca422e967e07e17dd10a02e7250270",
                "sha256": "59bf03538b46f5bf5a80b7e0d39280587f951fe3fc3b7834f9d661bdd27aa116"
            },
            "downloads": -1,
            "filename": "django-webp-3.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d7ca422e967e07e17dd10a02e7250270",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 153236,
            "upload_time": "2023-09-02T22:17:34",
            "upload_time_iso_8601": "2023-09-02T22:17:34.037805Z",
            "url": "https://files.pythonhosted.org/packages/e7/b4/177eadadb57b5d53d31f4bdb3400082b090971c7a534127c94126a2fb1c3/django-webp-3.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-02 22:17:34",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-webp"
}
        
Elapsed time: 0.10556s