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-image-field

## 🚀 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. Here’s a basic example:

python
Copy code
from django.db import models
from webp_image_field 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.1.0.tar.gz (3.8 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.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: webp_imagefield-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 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.1.0.tar.gz
Algorithm Hash digest
SHA256 c694b318bbaead249f9607cd39849a5431c14429daa0fd6448063e442dc072ba
MD5 91cb62dfa1b98d86ec1c2676618acd24
BLAKE2b-256 9fbc64ceec883dc34a73d544d2a08a3303f6f1f8b313f789da7a3b1acf936038

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for webp_imagefield-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa282a39107ec545e0e0daef1a175176e30b85e1d8af654fa9fd4b7df0061b8c
MD5 14d505fe41443b98f18b0507bae52a8a
BLAKE2b-256 92bc5d42aaf3b49caabbcb1ee1cfa4668ed7f30ef5fad871a0e1d5e371e62aed

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