Classes and methods to handle pictures for the web
Project description
Gallerist
Classes and methods to handle pictures for the web, using Pillow.
$ pip install gallerist
Features
- Code api to handle the generation of pictures in various sizes (e.g. medium size picture, small size, thumbnail)
- Both asynchronous api and synchronous api
- Supports user defined stores for binaries, for example to read and write files in Azure Blob Storage, or AWS S3
- Supports scaling animated GIF files
- Maintain PNG transparencies
- Handles by default JPG, PNG, GIF, MPO; and provides a code api to support adding more supported formats
Examples
Basic example using the synchronous api, and reading files from file system:
from gallerist import Gallerist
from gallerist.fs import FileSystemSyncFileStore
gallerist = Gallerist(FileSystemSyncFileStore('tests'))
metadata = gallerist.process_image('files/blacksheep.png')
Configuring sizes
from gallerist import Gallerist, ImageSize
from gallerist.fs import FileSystemSyncFileStore
store = FileSystemSyncFileStore('tests')
# configuring sizes by mime (use '*' to match any mime):
gallerist = Gallerist(store, sizes={
'image/jpeg': [
ImageSize('a', 500),
ImageSize('b', 400),
ImageSize('c', 300)
],
'image/png': [
ImageSize('a', 350),
ImageSize('b', 250),
ImageSize('c', 150)
]
})
Implementing a custom file store
from gallerist.abc import FileStore, SyncFileStore
class MyAsyncFileStore(FileStore):
"""Implement your async file store, then use gallerist.process_image_async method"""
async def read_file(self, file_path: str) -> bytes:
pass
async def write_file(self, file_path: str, data: bytes):
pass
async def delete_file(self, file_path: str):
pass
class MySyncFileStore(SyncFileStore):
"""Implement your sync file store, then use gallerist.process_image method"""
def read_file(self, file_path: str) -> bytes:
pass
def write_file(self, file_path: str, data: bytes):
pass
def delete_file(self, file_path: str):
pass
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
gallerist-0.0.3.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for gallerist-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28a95cb7d4583a3c8bceae5f1dd66bc65d2cfb90b36ac65905f6f76cb58bc3b0 |
|
MD5 | 2a586198b97b19731701858e61db19f7 |
|
BLAKE2b-256 | 5f31f203932e77798271a69c3d8b60327b8cf8a228efbb123cabcc928f5b3f34 |