Metadata-Version: 2.4
Name: dreamega-ico-encoder
Version: 1.0.0
Summary: Generate multi-size ICO favicon files from PNG/JPG images. Pure Python with Pillow.
Author-email: Dreamega <dev@dreamega.ai>
License-Expression: MIT
Project-URL: Homepage, https://dreamega.ai
Project-URL: Repository, https://github.com/dreamega/dreamega-ico-encoder
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Pillow>=9.0
Dynamic: license-file

# dreamega-ico-encoder

Generate .ico favicon files from any image. Multi-size support. Built by [Dreamega](https://dreamega.ai).

## Installation

```bash
pip install dreamega-ico-encoder
```

## Usage

### Generate ICO from a file

```python
from dreamega_ico_encoder import generate_ico_from_file

# Create favicon with default sizes (16, 32, 48, 64, 128, 256)
generate_ico_from_file("logo.png", "favicon.ico")

# Custom sizes
generate_ico_from_file("logo.png", "favicon.ico", sizes=[16, 32, 48])
```

### Generate ICO from a PIL Image

```python
from PIL import Image
from dreamega_ico_encoder import generate_ico

img = Image.open("logo.png")
ico_bytes = generate_ico(img, sizes=[16, 32, 64, 256])

with open("favicon.ico", "wb") as f:
    f.write(ico_bytes)
```

### Generate ICO from raw bytes

```python
from dreamega_ico_encoder import generate_ico_from_bytes

with open("logo.png", "rb") as f:
    raw = f.read()

ico_bytes = generate_ico_from_bytes(raw, sizes=[16, 32, 48])

with open("favicon.ico", "wb") as f:
    f.write(ico_bytes)
```

## API Reference

### `generate_ico(source, sizes=None) -> bytes`

Generate a multi-size ICO file from a PIL `Image`.

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `source` | `PIL.Image.Image` | *(required)* | Input image (any mode, converted to RGBA internally). |
| `sizes` | `list[int] \| None` | `[16, 32, 48, 64, 128, 256]` | Square icon sizes in pixels. Each must be 1-256. |

**Returns:** `bytes` -- the ICO file content.

### `generate_ico_from_file(input_path, output_path, sizes=None) -> None`

Read an image file and write an ICO file to disk.

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `input_path` | `str` | *(required)* | Path to source image (PNG, JPG, BMP, etc.). |
| `output_path` | `str` | *(required)* | Destination path for the ICO file. |
| `sizes` | `list[int] \| None` | `[16, 32, 48, 64, 128, 256]` | Square icon sizes. |

### `generate_ico_from_bytes(image_bytes, sizes=None) -> bytes`

Generate ICO from raw image bytes.

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `image_bytes` | `bytes` | *(required)* | Raw bytes of any Pillow-supported image format. |
| `sizes` | `list[int] \| None` | `[16, 32, 48, 64, 128, 256]` | Square icon sizes. |

**Returns:** `bytes` -- the ICO file content.

### `DEFAULT_SIZES`

```python
DEFAULT_SIZES = [16, 32, 48, 64, 128, 256]
```

The default set of icon sizes used when `sizes` is not specified.

## License

MIT -- see [LICENSE](LICENSE).

## Links

- Homepage: [https://dreamega.ai](https://dreamega.ai)
