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.5.tar.gz (16.7 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.5-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for coloursamples-0.1.5.tar.gz
Algorithm Hash digest
SHA256 5d6cd72d42f83b1e0c28f247d9ac8d7e1ffef18996f2b5513862504da3d59b51
MD5 43a7f6ac5bcb13275165e5333b9c5256
BLAKE2b-256 774717f3a1bf9e61ae15f16e1f2edfac62ee5fdf65fae41073f5fb79c9e12959

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for coloursamples-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f25a51bfc29823d1afe6bc77b466e8dd67e658b053a8fe75ccb740c013354563
MD5 a95ad4228c40d88c718c25762a7fe7c7
BLAKE2b-256 6b5ed155938b2e0460c2da809d588eac4613dc83453e47802e0d98f764dbbd52

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