0 purchases
djangowebcampicture 0.1.9
django-webcampicture
django-webcampicture is a very simple Django app that provides a specialization of Django's native ImageField: WebcamPictureField, which allows users to save images taken from their webcams, instead of uploading.
Quick start
Install using pip:
pip install django-webcampicture
Add "webcampicture" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'webcampicture',
]
Use the field in your models:
from django.db import models
from webcampicture.fields import WebcamPictureField
class Child(models.Model):
name = models.CharField("Name", max_length=255)
# WebcamPictureField takes the same parameters as ImageField,
# besides the "width" and "height" positional parameters.
picture = WebcamPictureField(
"Picture", width=480, height=360, upload_to="pictures", blank=True
)
# Image URL example...
@property
def picture_url(self):
if self.picture and hasattr(self.picture, "url"):
return self.picture.url
Remember to include in your templates:
{% load static %}
<link rel="stylesheet" href="{% static "webcampicture/css/webcampicture.css" %}">
<script src="{% static 'webcampicture/js/webcampicture.js' %}"></script>
Demo
Settings and default values
WEBCAM_BASE64_PREFIX = "data:image/png;base64,"
WEBCAM_CONTENT_TYPE = "image/png"
WEBCAM_FILENAME_SUFFIX = ".png"
Overridable templates
webcampicture/webcampicture.html
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.