Skip to main content

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

resizebento_image-1.0.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resizebento_image-1.0.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

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

Hashes for resizebento_image-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b687b5239c57b91d51280937e8a2c09e32d0c3ee04bb3041864943a7621ab82b
MD5 f32614b0b6314209fbbfa6fa319bc156
BLAKE2b-256 61186c783f134215f049011ea34388f8d1de669c8550e291a44403116caee7a7

See more details on using hashes here.

File details

Details for the file resizebento_image-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for resizebento_image-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f95b00fe425c8d090d94016b1bd0c0d4b542a2d3c76bca81686c2e095191af4
MD5 2d02f7a49bc8f55e8f1275ad09bf34cc
BLAKE2b-256 77b750ccb316447cee7212938e159fb04a575d828f076ff849c7c66285706aac

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page