Skip to main content

palx: Image Palette Extractor

palx is a command-line tool and Python package that allows users to extract a color palette from an image and attach it to the image's edge. This tool is perfect for designers, artists, or anyone interested in color analysis and image manipulation.

Features

  • Extract Color Palette: Analyzes an image and extracts a dominant color palette.
  • Attach Palette to Image: Adds the extracted color palette to the specified edge (top, bottom, left, or right) of the original image.
  • Customizable Options: Allows customization of the number of colors in the palette, the position of the palette on the image, and the border width around color squares.

Installation

To install palx, run the following command in your terminal:

pip install palx

CLI Usage

To use palx from the command line, follow this syntax:

palx <image_path> [--clusters <number_of_clusters>] [--position <position>] [--border_width <width>] [--output <output_path>]
  • image_path: Path to the input image.
  • --clusters: Optional. Number of color clusters to extract (default is 5).
  • --position: Optional. Position of the color palette on the image (left, right, top, bottom). Default is right.
  • --border_width: Optional. Width of the border around color squares (default is 10).
  • --output: Optional. Path to the output image. If not specified, the modified image will be displayed but not saved.

Example

palx myimage.jpg --clusters 8 --position bottom --border_width 5 --output myimage_with_palette.jpg

This command extracts an 8-color palette from myimage.jpg, attaches it to the bottom with a border width of 5 pixels, and saves the result to myimage_with_palette.jpg.

Python Package Usage

palx can also be used as a Python package to integrate palette extraction and attachment into your own projects.

Extracting a Palette and Edge Length

from palx import extract_palette_and_edge_length

palette, edge_length = extract_palette_and_edge_length("path/to/image.jpg", n_clusters=5)
print(palette, edge_length)

Attaching the pallette to an image

from palx import attach_palette

attach_palette("path/to/image.jpg", palette, "right", edge_length, border_width=10, border_color='black', output_path="path/to/output.jpg")

Requirements

  • Python 3.6 or higher
  • Pillow
  • NumPy
  • scikit-learn

License

palx is open-source software licensed under the MIT license.

Metadata

Release files for palx 0.0.1

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

Source distribution (sdist)

Source distribution for palx 0.0.1
File Size Uploaded
palx-0.0.1.tar.gz 4.3 kB Details

Built distribution (wheel)

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

Total release size: 9.0 kB

Release files / palx-0.0.1.tar.gz

Download URL palx-0.0.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9fd22944ceb40084a169bfbbb2ceb1904b04591798159435e3a93c09aeeff1ee
BLAKE2b-256 checksum
How to use checksums
4dc917f4ed96cebe7dc0da11fb6f0d9dac7cdcd854fd6e955e3efd6df34fb015
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.17

Release files / palx-0.0.1-py3-none-any.whl

Download URL palx-0.0.1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
636f6f9f9b7c6af5ae05b68ad7042f8cedddee4bf3c4a31cfef610f5af5b136d
BLAKE2b-256 checksum
How to use checksums
92804b7c2583497dddbad4d623711bc13e0c4cf71f78c929ddd9899e2b87e923
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

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