Skip to main content

Python utility for generating JPEG images with specified dimensions and colors

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.0.tar.gz (6.8 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.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coloursamples-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 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.0.tar.gz
Algorithm Hash digest
SHA256 219bd2fc9c1f92391572c7934e709fd1da5a9e27df7a35a32739ac1e33d6f1aa
MD5 ae77d43d3a8409973aa0f4610068170b
BLAKE2b-256 062b75324bccaf6bab790ea548ead8784d356d81aff926c5818b863a454ec8f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: coloursamples-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 763e59e08ee24c0a84d3a7ec872ad64c9abfeca81c0896ea4b347f44e5f0caf1
MD5 0d2ecd4bff360417ae2bd8268ad55636
BLAKE2b-256 c9c9cddd7dbab03065fd627d5130653d090d720f7fbb47aca0eebd7de5da1b0f

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