Skip to main content

A custom Django ImageField that automatically converts images to WebP format.

Project description

🌐 WebP Image Field

PyPI version License: MIT Django Version Python Version

WebP Image Field is a Django package that provides a custom ImageField which automatically converts uploaded images to the WebP format. This helps optimize image loading times on the web, as WebP images are often significantly smaller than JPEG or PNG files.

✨ Features

  • 🚀 Automatic Conversion: Seamlessly converts images to WebP during upload.
  • 🔧 Customizable Quality: Adjust WebP quality to balance between size and image fidelity.
  • 🔌 Easy Integration: Drop-in replacement for Django's ImageField.

📋 Requirements

Before using WebP Image Field, ensure you have the following dependencies installed:

  • Python: >= 3.6
  • Django: >= 3.0
  • Pillow: >= 8.0.0

🛠 Installation

Install the package using pip:

pip install webp-imagefield

🚀 How to Use

  1. Add to Your Django Project First, make sure that webp-image-field is installed in your environment .

  2. Update Your Models if you have been using ImageField Replace Django’s built-in ImageField with WebPImageField in your models. if you have been migrated you don't have to make new migrations.

Here’s a basic example:

from django.db import models
from webp_imagefield import WebPImageField

class MyModel(models.Model):
    image = WebPImageField(upload_to='images/', quality=85)

    def __str__(self):
        return f"Image: {self.image.url}"

upload_to: Specifies the directory within your MEDIA_ROOT where the images will be saved.

quality: Sets the quality of the WebP images (default is 90). You can adjust this value to balance between image quality and file size.

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

webp_imagefield-0.2.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webp_imagefield-0.2.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file webp_imagefield-0.2.0.tar.gz.

File metadata

  • Download URL: webp_imagefield-0.2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for webp_imagefield-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6acd7338c85a97c0e657777f181f065e462b52437e2ed02a11682d936aca6191
MD5 2df74cb9744c9cccc9aac27e0f2de60b
BLAKE2b-256 ce240edd576610c435c16bee6add83ff2e8837a941acbae8cf5c2a75b7051075

See more details on using hashes here.

File details

Details for the file webp_imagefield-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for webp_imagefield-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5b7ad99740f3bbd3e05267f827173103cc0f533e2e02d612f948caf94caf8cc
MD5 96f67f3d83abb7ff9cc2ebcf72069cc9
BLAKE2b-256 b177904976144d0097d4172a3efa5958bc6e7fd36565210be5a08dbb24244ba0

See more details on using hashes here.

Supported by

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