dreamega-ico-encoder
Generate .ico favicon files from any image. Multi-size support. Built by Dreamega.
Installation
pip install dreamega-ico-encoder
Usage
Generate ICO from a file
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
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
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
DEFAULT_SIZES = [16, 32, 48, 64, 128, 256]
The default set of icon sizes used when sizes is not specified.
License
MIT -- see LICENSE.
Links
- Homepage: https://dreamega.ai
Metadata
Release files for dreamega-ico-encoder 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dreamega_ico_encoder-1.0.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dreamega_ico_encoder-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / dreamega_ico_encoder-1.0.0.tar.gz
| Download URL | dreamega_ico_encoder-1.0.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c5199762f9996e0633fc11f6d44a9c10645437e2167fd76588ea98de936e962
|
|
BLAKE2b-256 checksum How to use checksums |
59761cd0337e4a2495b0e7b290289a6b2834cfe61a08bd6f47b3495bffd0f284
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / dreamega_ico_encoder-1.0.0-py3-none-any.whl
| Download URL | dreamega_ico_encoder-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53cff7d93e4313ff642775cecce18f47cccb6655c3b1fbe807825fdb5c508254
|
|
BLAKE2b-256 checksum How to use checksums |
195d115ca8f0e3a97a358762418487a66c9e3373e3672f2f8e8badd3f332174f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|