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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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