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.2.0b2.tar.gz (205.8 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.2.0b2-py3-none-any.whl (107.5 kB view details)

Uploaded Python 3

File details

Details for the file semiautomatic-0.2.0b2.tar.gz.

File metadata

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

File hashes

Hashes for semiautomatic-0.2.0b2.tar.gz
Algorithm Hash digest
SHA256 c306534927a52003d7be857a84b619ebe3c53fbdc06a3d3f4f314a45fc1df2be
MD5 d0bbbc1ed47d03260effdce8c16563b7
BLAKE2b-256 93be3b746c194727bb516d968be6236cda2771f863e8d7ee8588ce27c95242c0

See more details on using hashes here.

File details

Details for the file semiautomatic-0.2.0b2-py3-none-any.whl.

File metadata

File hashes

Hashes for semiautomatic-0.2.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc669a1d09db5b811b2b3e6c4ec78c51f77b8954513d0442a12d88a058b5e284
MD5 c85318ff5cecbb0e54167a4f1392760c
BLAKE2b-256 add5d3cf2ebae5d2935eba46ca6a359aab6c41f05c5a97376841b599e16f3d31

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