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.0.tar.gz (10.1 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.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file resizebento_image-1.0.0.tar.gz.

File metadata

  • Download URL: resizebento_image-1.0.0.tar.gz
  • Upload date:
  • Size: 10.1 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.0.tar.gz
Algorithm Hash digest
SHA256 fb79bebb647c151ed4e25aee819bacfb3c20680078e1ec7d69ce4efe933d0746
MD5 51734048b9efeabbe97f5ab18962acf5
BLAKE2b-256 0623cfabad7d4a90972ef709f4c7c6377ed148a463136b68b3f3ccd75190fe0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for resizebento_image-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 733e71f5b08a170d2dcc6c0e2cc72ac20862c0d5ebe60f0eb4203185cf534ccf
MD5 843e75b908f538906998e6888dd931b2
BLAKE2b-256 f83b7f6ee46dd121efbd0a57770a8515c574a1444979ff973d96203811e64a86

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

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