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.3.tar.gz (9.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.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coloursamples-0.1.3.tar.gz
  • Upload date:
  • Size: 9.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.3.tar.gz
Algorithm Hash digest
SHA256 9543cee081c3937d1fdc2e8a60db878a798aa46db2de0db0935e6b1e70b4f483
MD5 b76052b3c5784ec9d3d833045452c5bd
BLAKE2b-256 dd4774831635ae92f60f1d22fc461bc3a01b16ca2ddd7713229a4c60bdc3827d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: coloursamples-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7a57dc13deac4771734cee4278bc0c802d7f3cc6aec3099ce747c6efce797539
MD5 f6497f4b746ef06e3b0b0c02918cf6dd
BLAKE2b-256 b651116a5078659418ef91e500e813d2590ff3a171fdb8feabfd8e3010fe3f58

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