Serialize Django's ImageField into imgproxy URLs for your Django REST Framework APIs to generate thumbnails.
Project description
Serialize Django’s ImageField into imgproxy URLs for your Django REST Framework APIs to generate thumbnails.
Important Notice
This package only provides the serializer class necessary to translate your ImageField to signed imgproxy URLs.
It does not provide anything to upload images to your object storage bucket. We suggest you use another Django storage backend library that’s able to communicate with your object storage solution, in particular we recommend the following:
Usage
0. Installation
You can easily install this package from PyPI with pip by doing:
pip install drf-imgproxy
1. Quickstart
In settings.py:
INSTALLED_APPS = [
...
'drf_imgproxy',
...
]
# Configure this to either of the following:
# - 's3' for Amazon S3, Minio and any other S3-compatible object
# storage
# - 'gs' for Google Cloud Storage
# - 'abs' for Azure Blob Storage
IMGPROXY_PROTOCOL = 's3'
# Set the following to the bucket name that imgproxy uses.
IMGPROXY_BUCKET_NAME = 'nerv_angel_captures'
# Set both of the following to the appropiate values of
# `IMGPROXY_KEY` and `IMGPROXY_SALT` of your imgproxy server.
IMGPROXY_KEY = 'ThisIsNotASecureKeyAtAll'
IMGPROXY_SALT = 'SeriouslyThisSaltIsVeryInsecure'
# Set the following to the publicly accessible URL of your imgproxy
# server.
IMGPROXY_HOST = 'https://imgproxy.infra.nerv.tld'
# Set the following variable to the available resolutions your API
# provides.
#
# The format is `(<width>, <height>)`.
IMGPROXY_RESOLUTIONS = (
(640, 480),
(800, 600),
(1024, 768),
)
# In case you want to skip imgproxy url generation, set this flag to True.
# When generation is being skipped, all the resolutions return the url of
# the source file if possible or None.
IMGPROXY_SKIP = False
In serializers.py:
...
from drf_imgproxy.serializers import ImgproxyResizeableImageField
...
class AngelActivity(ModelSerializer):
...
captured_photo_thumbs = ImgproxyResizeableImageField(
read_only=True,
source='captured_photo'
)
...
See also
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file drf-imgproxy-1.1.0.tar.gz
.
File metadata
- Download URL: drf-imgproxy-1.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.4 Linux/5.4.0-1046-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41ea4d153d343a31872839c3a023b94ce519cd57c15dc60c8f35450763e3663d |
|
MD5 | 416f98a19363f61f0ac35d25aaa8972b |
|
BLAKE2b-256 | 0d5f3e610d6f48a82579b43fead3c9c412d1cf3ec2b34ccbddaefdb0b14e347f |
File details
Details for the file drf_imgproxy-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: drf_imgproxy-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.9.4 Linux/5.4.0-1046-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a3ffc39af3e486737bc8d71c6fe26018ffd5d3d8e794d2f0b64892867e0a665 |
|
MD5 | e5e9132d2fc0d9a13f7487ccf54db213 |
|
BLAKE2b-256 | c9d6bac90de6852ac2f697bd58ba3edf1375d26a43f2aa8d39e887a79abe4aad |