ImageProcessing 🥚
Provides higher-level image processing helpers that are commonly needed when handling image uploads.
This package process images with the libvips library. Libvips is a library that can process images very rapidly (often multiple times faster than ImageMagick).
Requirements
You need to install first the libvips library.
- In a MacOS terminal (using Homebrew) run:
brew install vips - In a Debian/Ubuntu terminal run:
sudo apt install libvips-tools
Installation
Install this library with pip, or add it to your requirements/dependencies:
pip install image-processing-egg
Usage
Processing is performed through the ImageProcessing class that
uses a chainable API for defining the processing pipeline:
from image_processing import ImageProcessing
processed = (
ImageProcessing(source_path)
.resize_to_limit(400, 400)
.convert("png")
.save()
)
processed #=> /temp/.../20180316-18446-1j247h6.png>
This allows easy branching when generating multiple derivates:
from image_processing import ImageProcessing
pipeline = ImageProcessing(source_path).convert("png")
large = pipeline.resize_to_limit(800, 800).save()
medium = pipeline.resize_to_limit(500, 500).save()
small = pipeline.resize_to_limit(300, 300).save()
The processing is executed with save().
processed = ImageProcessing(source_path) \
.convert("png") \
.resize_to_limit(400, 400) \
.save()
You can inspect the pipeline options at any point before executing it:
pipeline = ImageProcessing(source_path) \
.loader(page=1) \
.convert("png") \
.resize_to_limit(400, 400) \
.strip()
pipeline.options
# => {
# 'source': '/path/to/source.jpg',
# 'loader': {'page': 1},
# 'saver': {},
# 'format': 'png',
# 'operations': [
# ['resize_to_limit', [400, 400], {}],
# ['strip', [], {}],
# ]
# }
The source object needs to be a string or a Path.
Note that the processed file is always saved to a new location,
in-place processing is not supported.
ImageProcessing("source.jpg")
ImageProcessing(Path("source.jpg"))
You can define the source at any time using source()
ImageProcessing().source("source.jpg")
ImageProcessing().source(Path("source.jpg"))
When save() is called without options, the result of processing is a temp file. You can save the processing result to a specific location by passing a destination, as a string or a Path, to save().
pipeline = ImageProcessing(source_path)
pipeline.save() #=> tempfile
pipeline.save("/path/to/destination")
Credits
This library is a port to Python of the Ruby image_processing gem.
License
Metadata
Release files for image-processing-egg 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| image_processing_egg-0.3.1.tar.gz | 13.7 kB | Without provenance | Details for image_processing_egg-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| image_processing_egg-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for image_processing_egg-0.3.1-py3-none-any.whl |
Total release size: 22.9 kB
Release files / image_processing_egg-0.3.1.tar.gz
| Download URL | image_processing_egg-0.3.1.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
559b20969fb046f640d138c172c204cc7df8b9ffc3bbc776c9ca43e3fc328993
|
|
BLAKE2b-256 checksum How to use checksums |
fa5b63c07c3246a4f15de5368f9152fb62eac62583ad858130182e29169569d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Release files / image_processing_egg-0.3.1-py3-none-any.whl
| Download URL | image_processing_egg-0.3.1-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4c50909cf67f9e24c83d92a8fce7776ebbc3803fbe2914d98127b398a23a289
|
|
BLAKE2b-256 checksum How to use checksums |
d164448086a989b17442629a1d919827f8a23e860216fd0841a4362565ce5ab4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.21
|
Security for image-processing-egg 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.