boxmath
This provides image crop/resize algorithm for chaining multiple resize, crop actions and producing a resulting crop/resize action pair.
Usage
The usage is fairly simple:
from boxmath import box, resize, crop, size, make_transformer
from wand import image
# Load the image to get its width and height
i = image.Image(filename="chrysanthemum.jpg")
b = box(i.width, i.height)
# manipulate the virtual image
b = resize(b, 629, 483)
b = crop(b, 0, 0, 480, 480)
b = resize(b, 1000, 1000)
# render
def resizer(img, w, h):
img.resize(int(w), int(h), filter=FILTER)
return img
def cropper(img, l,t,r,b):
img.crop(int(l),int(t),int(r),int(b))
return img
t = make_transformer(b, resizer, cropper)
i = t(i)
i.save(filename="chrysanthemum-1000x1000.jpg")
Normally, if we would of used wand or PIL directly, each resize would degrade the image. The action of down scaling and then up scaling would wreck the quality of the image; with the power of math, we only apply the resize and crop when we need render the image.
Not that the width, height, left, top, right, and bottom values passed to the resizer and cropper functions are cast as ints.
This is because they are either fractions.Fraction() instances or int(). boxmath uses the Fraction class to ensure precision while resizing and cropping.
Metadata
Release files for boxmath 0.1.3
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 |
|---|---|---|---|---|
| boxmath-0.1.3.tar.gz | 9.2 kB | Without provenance | Details for boxmath-0.1.3.tar.gz |
Release files / boxmath-0.1.3.tar.gz
| Download URL | boxmath-0.1.3.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b27ea9301d1902c3202699ddcdaf829c646551e23d0c1f9a5124b4fde2005107
|
|
BLAKE2b-256 checksum How to use checksums |
78f30d87d662e368370909bbf80e9f662c9a846475aabfb9af7e157fcedf1ce1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for boxmath 0.1.3
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.