resizebento-image
Image resizing, cropping, padding, and format conversion for Python, built with Pillow.
Built by ResizeBento.com, a collection of privacy-friendly image tools.
Install
pip install resizebento-image
Resize a file
from resizebento_image import resize_image
result = resize_image(
"input.jpg",
"output.webp",
width=800,
height=600,
mode="crop-to-fit",
quality=80,
)
print(result.width, result.height)
When an output path is supplied and output_format is omitted, the output format is inferred from .jpg, .jpeg, .png, or .webp.
Work with bytes
from resizebento_image import resize_image
with open("input.png", "rb") as file:
source = file.read()
result = resize_image(
source,
width=1200,
height=630,
mode="add-padding",
output_format="jpg",
padding_color="#ffffff",
quality=90,
)
with open("result.jpg", "wb") as file:
file.write(result.data)
bytes, bytearray, BytesIO, file-like binary objects, str paths, and pathlib.Path are supported as inputs.
Resize by percentage
from resizebento_image import resize_image_by_percentage
result = resize_image_by_percentage(
"input.png",
50,
"output.png",
)
Read dimensions
from resizebento_image import get_image_dimensions
dimensions = get_image_dimensions("input.webp")
print(dimensions.width, dimensions.height)
Resize modes
| Mode | Behavior |
|---|---|
crop-to-fit |
Center-crops to completely fill the target size. |
stretch |
Stretches directly to the target size. |
add-padding |
Fits the complete image inside the target and fills the remaining area with a background color. |
fill-frame |
Uses the same centered cover behavior as ResizeBento's Fill Frame mode. |
Formats and defaults
Input formats: JPEG, PNG, WebP.
Output formats: JPG, PNG, WebP.
Without a destination path or explicit output_format, the default output is WebP. JPG and WebP support quality from 10 to 100, with 80 as the default. PNG ignores quality.
Target dimensions range from 1 to 16,384 pixels per side, with a maximum output area of 64,000,000 pixels. Percentage resizing supports 1% to 500%.
Result
Every resize returns a ResizeResult:
result.data # encoded image bytes
result.width
result.height
result.format # "webp", "jpg", or "png"
result.mime_type
result.filename
result.output_path
Errors
Validation and processing failures raise ImageResizerError with a machine-readable code.
from resizebento_image import ImageResizerError, resize_image
try:
resize_image("input.jpg", width=0, height=600)
except ImageResizerError as error:
print(error.code)
Privacy
The package processes images locally in your Python process. It does not upload image content to ResizeBento.
For interactive browser tools, visit ResizeBento.com.
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file resizebento_image-1.0.1.tar.gz.
File metadata
- Download URL: resizebento_image-1.0.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b687b5239c57b91d51280937e8a2c09e32d0c3ee04bb3041864943a7621ab82b
|
|
| MD5 |
f32614b0b6314209fbbfa6fa319bc156
|
|
| BLAKE2b-256 |
61186c783f134215f049011ea34388f8d1de669c8550e291a44403116caee7a7
|
File details
Details for the file resizebento_image-1.0.1-py3-none-any.whl.
File metadata
- Download URL: resizebento_image-1.0.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f95b00fe425c8d090d94016b1bd0c0d4b542a2d3c76bca81686c2e095191af4
|
|
| MD5 |
2d02f7a49bc8f55e8f1275ad09bf34cc
|
|
| BLAKE2b-256 |
77b750ccb316447cee7212938e159fb04a575d828f076ff849c7c66285706aac
|