Skip to main content

AI automation tools for creative workflows

Project description

semiautomatic

Automation tools for creative AI workflows.

Note: Early release (v0.1.0). Currently shipping simple image processing tools. Generators, video, post-processing, and training modules coming soon as they reach production quality.

Installation

pip install semiautomatic

For development:

git clone https://github.com/drpolygon/semiautomatic.git
cd semiautomatic
uv sync

Features

Image Processing

Batch resize, convert, and compress images with intelligent size optimization for API limits.

CLI Usage:

# Resize images to exact dimensions
semiautomatic process-image --size 1920x1080

# Scale to 50%
semiautomatic process-image --size 0.5

# Width-constrained (preserve aspect ratio)
semiautomatic process-image --size 1920x

# Convert to PNG
semiautomatic process-image --format png

# Compress for Claude Vision API (5MB limit)
semiautomatic process-image --max-size 5

# Process single file
semiautomatic process-image --input photo.jpg --size 0.5

# Short alias
sa process-image --max-size 5

Library Usage:

from pathlib import Path
from semiautomatic.image import compress_for_api, compress_to_size

# Compress image to fit API size limits (returns JPEG bytes)
img_bytes = compress_for_api(Path('photo.jpg'))

# Compress with custom limit
img_bytes = compress_for_api(Path('photo.jpg'), max_bytes=2 * 1024 * 1024)

# Full control over compression
from PIL import Image
with Image.open('photo.jpg') as img:
    result = compress_to_size(img, max_bytes=5 * 1024 * 1024)
    print(f"Final size: {result.final_size} bytes")
    print(f"Dimensions: {result.final_dims}")
    print(f"Quality: {result.quality}")

Size Format Reference

Format Example Description
WxH 1920x1080 Exact dimensions
Wx 1920x Width-constrained, preserve aspect
xH x1080 Height-constrained, preserve aspect
N 0.5 Scale factor (0.5 = 50%)

Compression Algorithm

When using --max-size, the compressor uses a multi-stage strategy:

  1. Start at quality 95
  2. If oversized and large, resize to max 1920px on longest edge
  3. Progressively reduce JPEG quality (in steps of 5)
  4. If still over limit at quality 60, shrink dimensions by 10%
  5. Repeat until under limit or image too small (512px minimum)

This ensures maximum quality preservation while meeting size constraints.

Development

# Run tests
uv run pytest

# Run with coverage
uv run pytest --cov=semiautomatic

License

MIT

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

semiautomatic-0.1.0.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

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

semiautomatic-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: semiautomatic-0.1.0.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for semiautomatic-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f65ddd439d4e383261a3c68af777d99a106aeb9ab8791f9def64555f29348c7d
MD5 f904525abbeb1aaa9ae78e278aad40f5
BLAKE2b-256 c2bfc146ad67e615f82cc5682d21e15fd7b1af526fef1c66a33a824d7782abcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for semiautomatic-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13dbc4ea972eb9ea4c5a2ab583e82f47e7e753b5749bfeeb12e6d7c2aad5b2c3
MD5 085917735f084501473ca78aad7f85c0
BLAKE2b-256 f5e07c333fd7858d442688d423e75581f7723fae418022cfd7ac7b635f8c08c9

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