Skip to main content

Generate Adobe ASE swatches from images.

Project description

Swatcher

Swatcher is a Python module for generating Adobe ASE color swatches from images.

Background

Swatcher was born out of necessity in my day job as a Graphic Designer. 👨‍💻

Often, I need to extract exact color values from images for use in Adobe products and I just couldn't find a good way...

"Isn't there already software that samples colors from images?"

Yeah, there's a bunch, problem is, most are designed for sampling photographs and use algorithms that provide approximate color values. I typically sample computer generated graphics with fairly distinct colors, and I need exact values. 🎯

FYI, Swatcher works great on photographs too! 📸

Credit to Marcos Ojeda for his work on the Adobe ASE file writer. 👏

Installation

Install Swatcher with pip:

pip install swatcher

Usage

from swatcher import Swatcher

s = Swatcher('/path/to/your/image.jpg')

# view the most common colors (RGB values)
s.palette

Swatcher will automatically sample the provided image at initialization using the default settings max_colors=8 and sensitivity=75. I have found these general settings to work best for most images.

ℹ️ You can also specify max_colors and sensitivity at object creation.

s = Swatcher('/path/to/your/image.jpg', max_colors=5, sensitivity=125)

View the sampled swatches

To view the sample palette swatches in your default system image viewer.

s.show_palette_image()

Resample the image

If the sampled colors were not what you were expecting, you can easily resample your image with different settings.

s.sample(max_colors=4, sensitivity=50)
  • max_colors: Maximum number of colors to sample (may sample less)
  • sensitivity: How perceptively different (Euclidean Distance) a color must be from others to be included in the sampled palette. A lower value = more similar colors, a higher value = less similar colors.

Sensitivity Example:

If you have numerous grey values in your image, reducing the sensitivity will make sure you sample each individual grey. On the flip side, a landscape photograph with a lot of sky will probably sample too many blue values. Increasing the sensitivity will sample a more diverse palette with colors from more areas of the photograph.

Export an Adobe ASE swatch file

Once you have a palette you like, you can export it to an Adobe ASE swatch file for use in Adobe design products.

s.export_ase_file()

By default, the ASE swatch file will be saved in one of two places depending on how you initialized your Swatcher object.

  1. If you provided an image file path, the Adobe ASE swatch file will be saved in the same directory.
  2. If you provided a file object, the Adobe ASE swatch file will be saved in your current users home directory.

...or export to a specific location

s.export_ase_file("path/you/want/to/use/")

Resources

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

swatcher-1.0.3.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

swatcher-1.0.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file swatcher-1.0.3.tar.gz.

File metadata

  • Download URL: swatcher-1.0.3.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for swatcher-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e3608c6fbba6b552d09d49918c71fa62ae1794d140f03a167809520ca0017aab
MD5 82433e512bbf9c1512a6ab92bc2798a4
BLAKE2b-256 01b0dd8870dda570e011cdcf665e089a97c84de63f0f3219096bc9c9d3f98740

See more details on using hashes here.

File details

Details for the file swatcher-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: swatcher-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.2

File hashes

Hashes for swatcher-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c423979de8fb3c85e712576ff6b1ec37b2643eb2d046f2146b42ebc9bc694f7a
MD5 dfdd04d4a4c5a1dad895801f5e26ffbd
BLAKE2b-256 d45a00632ace700c429e7a1153be02f380979546b7d6dc4219f10116a22503e5

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