Metadata-Version: 2.4
Name: resizebento-image
Version: 1.0.1
Summary: Image resizing, cropping, padding, and format conversion for Python by ResizeBento.com: https://resizebento.com/
Author: ResizeBento
License-Expression: MIT
Project-URL: Homepage, https://resizebento.com/
Project-URL: Documentation, https://resizebento.com/
Keywords: image resize,image resizer,image crop,image conversion,pillow,webp,jpeg,png,resizebento
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Pillow<13,>=10.4
Provides-Extra: dev
Requires-Dist: build>=1.2.2; extra == "dev"
Requires-Dist: pytest>=8.3; extra == "dev"
Requires-Dist: twine>=5.1; extra == "dev"
Dynamic: license-file

# resizebento-image

Image resizing, cropping, padding, and format conversion for Python, built with Pillow.

Built by [ResizeBento.com](https://resizebento.com/), a collection of privacy-friendly image tools.

## Install

```bash
pip install resizebento-image
```

## Resize a file

```python
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

```python
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

```python
from resizebento_image import resize_image_by_percentage

result = resize_image_by_percentage(
    "input.png",
    50,
    "output.png",
)
```

## Read dimensions

```python
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`:

```python
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`.

```python
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](https://resizebento.com/).

## License

MIT
