Skip to main content

Python utility for generating JPEG images with specified dimensions and colours

Project description

colourSamples

A Python utility for generating JPEG images with specified dimensions and colors.

Getting Started

Installation

Install the package and its dependencies using uv:

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install the package in development mode
uv pip install -e ".[dev]"

Alternatively, install dependencies manually:

pip install Pillow pytest ruff

Usage

Command Line Interface

The package provides a modern CLI with rich formatting and helpful options:

# Direct command with arguments
coloursamples create 800 600 "#FF5733"

# With custom output directory
coloursamples create 400 300 "3498db" --output-dir ./my_images

# Interactive mode with prompts and defaults
coloursamples create --interactive

# Verbose logging for debugging
coloursamples create 200 150 "#8E44AD" --verbose

# Get help
coloursamples --help
coloursamples create --help

# Display tool information
coloursamples info

Programmatic Usage

from coloursamples import create_image

# Create a 500x300 red image
create_image(500, 300, "#FF0000")

# Create an image in a specific directory
create_image(100, 100, "#00FF00", "my_output_dir")

The function will create an image of the specified size and color, and save it as a JPEG file. The filename will be the color code without the leading '#'.

Running Tests

Run all tests:

pytest

Run tests with verbose output:

pytest -v

Run a specific test file:

pytest tests/test_core.py

Development Setup

Code Formatting and Linting

This project uses ruff for code formatting and linting:

# Check code style
ruff check .

# Format code
ruff format .

Project Structure

colourSamples/
├── src/
│   └── coloursamples/
│       ├── __init__.py
│       ├── core.py           # Main image creation functionality
│       └── cli.py            # Modern typer-based CLI
├── tests/
│   ├── __init__.py
│   └── test_core.py          # Test suite
├── docs/                     # Documentation
├── logs/                     # Log files
├── pyproject.toml            # Project configuration with console scripts
├── README.md                 # This file
└── .gitignore               # Git ignore rules

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please ensure tests pass and code is formatted before submitting:

pytest
ruff check .
ruff format .

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

coloursamples-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

coloursamples-0.1.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file coloursamples-0.1.1.tar.gz.

File metadata

  • Download URL: coloursamples-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for coloursamples-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d4d1f0f28ac13b202610d1cf4147ca3fbe5e9d3d1cdaee3c8eaf3d9f957b76ea
MD5 90f478f33ed5110c60514edfb84c10e8
BLAKE2b-256 3c5b369d147395efcf64abdb60bac281d8048f9420aa5a0b48d660127336b647

See more details on using hashes here.

File details

Details for the file coloursamples-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: coloursamples-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for coloursamples-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1a08b95a67d83ba9d0f3578064b785db67176a43ed2c03ac8548a82b49b5747
MD5 daac7beb1c6c07fb2698646416b29af4
BLAKE2b-256 e2da701d178ad0f5308e0b8ac072596eded524334ef701f7299e4d29924421f2

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