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.4.tar.gz (15.4 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.4-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coloursamples-0.1.4.tar.gz
  • Upload date:
  • Size: 15.4 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.4.tar.gz
Algorithm Hash digest
SHA256 a88254075596571ff0d292951cf68484fc30e159ae0553b6ed0808928f38d8cb
MD5 61b7e8f0da39c4f1d5725794f24962dc
BLAKE2b-256 f3d006a4d2cde161be5e456bb9d8bfe14feacd459b7a921a9e160413af707154

See more details on using hashes here.

File details

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

File metadata

  • Download URL: coloursamples-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 398642227200f83ca639e83856f3c671e205cc68eb283bcfa08f691352f37615
MD5 185fd9e46afa0ddec1f200fd2226a915
BLAKE2b-256 51f3b120ea70ba93fc0e1c29eb52e8ff6b8e1351fc5ff140edfc1df578696e12

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