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:

bash 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. if you have been migrated you don't have to make new migrations.

Here’s a basic example:

bash 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.2.2.tar.gz (4.3 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.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for webp_imagefield-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9c2c613702a1f4bdad34ddcbb5bb612135f406e07f40a77f3148fb6e0eb050b5
MD5 2eb7eed40f1e369f56e4dee239122011
BLAKE2b-256 83749503f385f32c3bc4b9828f06258fb3d655ee1aa4e68d6b735f83969da767

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for webp_imagefield-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 898cc235ef8c2e79de13e739be1ae7892b291867375d23019f257cf869292df8
MD5 c61380d0aaa1e3d3a2252d223a43af0e
BLAKE2b-256 f74bf9b0e9b4011d5aaea763008adb5f040cea12bc8aee092f5369d474aee62d

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