Skip to main content

Palx - extract color palette from an image and reattach it to the image

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

palx-0.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

palx-0.0.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file palx-0.0.1.tar.gz.

File metadata

  • Download URL: palx-0.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.17

File hashes

Hashes for palx-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9fd22944ceb40084a169bfbbb2ceb1904b04591798159435e3a93c09aeeff1ee
MD5 b0890926d93aef60f79bf7d2b61e8930
BLAKE2b-256 4dc917f4ed96cebe7dc0da11fb6f0d9dac7cdcd854fd6e955e3efd6df34fb015

See more details on using hashes here.

File details

Details for the file palx-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: palx-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.17

File hashes

Hashes for palx-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 636f6f9f9b7c6af5ae05b68ad7042f8cedddee4bf3c4a31cfef610f5af5b136d
MD5 9b5e2653581591e40d15d7eb22c13acc
BLAKE2b-256 92804b7c2583497dddbad4d623711bc13e0c4cf71f78c929ddd9899e2b87e923

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page