PixelOE (Detail-Oriented Pixelization)

0.1.4 · active · verified Fri Apr 17

PixelOE is a Python library for detail-oriented image pixelization based on a contrast-aware outline expansion algorithm. It's designed to create pixel art-style images while preserving key details. The current version is 0.1.4, and the library appears to be actively maintained with releases as features and improvements are developed.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart loads an image (a dummy one created for the example), applies the `pixelize` function with common parameters, and saves the resulting pixelized image. The `pixelize` function takes a `PIL.Image` object as input and returns a new `PIL.Image` object.

from PIL import Image
import pixeloe
import os

# Create a dummy image for demonstration
img_path = "example_input.png"
Image.new('RGB', (100, 100), color = 'red').save(img_path)

# Load the image
img = Image.open(img_path).convert("RGB")

# Pixelize the image with specified parameters
# pixels: size of pixelization blocks
# contrast: contrast awareness level
# outline: whether to include outlines
# levels: number of color levels to quantize to
out_img = pixeloe.pixelize(img, pixels=8, contrast=250, outline=True, levels=8)

# Save the output image
output_path = "pixelized_output.png"
out_img.save(output_path)
print(f"Original image saved to {img_path}")
print(f"Pixelized image saved to {output_path}")

# Clean up dummy image
os.remove(img_path)

view raw JSON →