Skip to main content

A simple library that convert any user uploaded images to webP format

Project description

This is a library for Django that provides a custom model field for storing WebP images. The WebPField model field allows you to store WebP images in your Django models and provides convenient methods for converting between WebP and other image formats.

Installation

To install the library, simply add it to your project’s dependencies using pip:

pip install django-webpfield

Usage

To use the WebPField model field, simply import it from the library and add it to your Django model:

from django.db import models
from webpfield.fields import WebPField


class MyModel(models.Model):
    my_image = WebPField(upload_to="images/")

Settings

The default settings are:

WEBP_FIELD_SETTINGS = {
    "saving_kwargs": {
        "quality": 75,
        "lossless": False,
    },
    "delete_original": False,
    "enable_svg": True,
    "image_field_class": {"module": "django.db.models", "class_name": "ImageField"},
}
  • saving_kwargs: are the kwargs passed to pillow when saving the new image

  • enable_svg: if True you can upload and svg and it will remain svg as original, this achieved by updating the formfield kwargs of WebPField to file field instead of image field

  • image_field_class: The default parent class of WebPField is django ImageField, but you can override it with yours

Contributing

Contributions to the library are welcome! If you find a bug, have a feature request, or would like to contribute code, please open an issue or pull request on the GitHub repo.

License

This library is licensed under the MIT license. See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_webpfield-0.0.1.tar.gz (116.8 kB view details)

Uploaded Source

Built Distribution

django_webpfield-0.0.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file django_webpfield-0.0.1.tar.gz.

File metadata

  • Download URL: django_webpfield-0.0.1.tar.gz
  • Upload date:
  • Size: 116.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for django_webpfield-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c13501d7c749fa1b47e8258c12023056dd4d3d651b93bcb774b342c39a2b4495
MD5 b8a9e26cec8c529d479957a3462a6745
BLAKE2b-256 6b420bbf3574e79dd6c1a4ad152923622d0d7b520821378b10f99711071bede3

See more details on using hashes here.

File details

Details for the file django_webpfield-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_webpfield-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 95cd4ad511115496395d70d4d24c4962734088089a5fee962ecc9c5d92729d6f
MD5 5796529d9af68d35e309d9260638d468
BLAKE2b-256 413a81fd09d89dd5d5b92ecf6791cbd6ba3734227f12ff44ad65bdd53300db56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page