Skip to main content

Pixelator

A simple python package to pixelate images given a color palette

Features

  • Users can:
    1. Load in array data, image files or capture directly from a camera
    2. Pixelate images to a specific color palette and image resolution
    3. Access pixelated array data or write it back to an image file

Technical Docs

https://connor-makowski.github.io/pixelator/pixelator/pixelator.html

Setup

Make sure you have Python 3.6.x (or higher). You can download it here.

Installation

pip install pixelator

Getting Started

Import the pixelator into your project

from pixelator import Pixelator

Some important notes:

  • All data is stored and processed as BGR (to match open cv2)
    • EG: Provided pallettes should be in BGR

Examples

Load from a file:

from pixelator import Pixelator
# Use the input filename provided
image = Pixelator(filename='./images/input.jpg')
# Pixelate the image to a 28x28 black and white array
pixelated_image = image.pixelate(
    width=28,
    height=28,
    palette=[[0,0,0],[255,255,255]]
)
# Write to `output.png` scaled up to a 300x300 image (to be easily viewed)
pixelated_image.write(filename='./images/output_test_1.jpg', width=300, height=300)

Input:

Output:

Capture from a webcam:

from pixelator import Pixelator
# Capture from a webcam since no data or filename is provided
image = Pixelator()

# Pixelate the image to a 64x64 black, white and multiple gray array
pixelated_image = image.pixelate(
    width=64,
    height=64,
    palette=[[0,0,0],[80,80,80],[160,160,160],[200,200,200],[255,255,255]]
)
# Write to `output.png` scaled up to a 500x500 image (to be easily viewed)
pixelated_image.write(filename='./images/output_test_3.jpg', width=300, height=300)

Access Pixelator Data:

from pixelator import Pixelator
# Use the input filename provided
image = Pixelator(filename='./images/input.jpg')
# Pixelate the image to a 28x28 black and white array
pixelated_image = image.pixelate(
    width=28,
    height=28,
    palette=[[0,0,0],[255,255,255]]
)
# Show pixelated image data
print(pixelated_image.data)
# Show Color Counts:
print(pixelated_image.get_color_counts())

Metadata

Release files for pixelator 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pixelator 1.3.0
File Size Uploaded
pixelator-1.3.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pixelator 1.3.0
File Interpreter ABI Platform
pixelator-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / pixelator-1.3.0.tar.gz

Download URL pixelator-1.3.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8a5b57e0312427f098d69f0bd01223dc62bca2f6117ebb7a4b604e292e4c28cd
BLAKE2b-256 checksum
How to use checksums
a7a25e3d6cf96fc054f43e6d35226e0449e91e65f0de90722da1c884af800cce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / pixelator-1.3.0-py3-none-any.whl

Download URL pixelator-1.3.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ae2f2f8b2da1214119c8312e5d8526032457e53f048afb8855018343d52e88c
BLAKE2b-256 checksum
How to use checksums
ff1cca5ad7c27d92bf13a5ccce23e4517a4776e4cb7a43b1a65074d2abdf91e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

1 release file

1.0.0

1 release file

0.1

1 release file

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