Skip to content

Compress

Module · Stable

Compress a file (PDF or image) using a provider-abstracted pipeline. Returns metadata about the result.

Compresses a PDF or image using a provider-abstracted pipeline (Ghostscript for PDF, Pillow for images). Skips compression when the file is smaller than compress_min_bytes (default 50 KB). Returns the new file_path, compression_ratio, and original_size. ok is true when compression succeeded or was skipped safely.

Use when a file_path (e.g. from Document Store or OCR) needs to be shrunk before sending or storing — for example, reducing a scanned proposal PDF before Send email attaches it. The output file_path slots directly into any downstream step that consumes a file path.

To extract text or structured fields from the file, use OCR or Extract Proposal Field instead. To persist an uploaded file durably and get a stable document ID, use Document Store — compression is a size-reduction pass, not a storage operation.

Configured per use: file_path, content_type, compress_provider, compress_min_bytes.

  • ok
  • error
  • file_path
  • file_size
  • content_type
  • original_size
  • compression_ratio
  • provider_used
  • note

Auto-generated from the skill registry (load_skills()). Do not edit by hand.