Condense exposes three main integration paths:
- Programmatic helpers for direct use inside your application
- A command-line interface for automation and batch work
- An HTTP server or middleware layer for file uploads and API endpoints
The public helpers are exported from src/index.js. Common helpers include:
- optimizeText for HTML, CSS, JS, JSON, YAML, and similar text assets
- optimizeImage for raster and vector images
- optimizeMediaStream for audio and video streams
- extractVideoThumbnail for generating a thumbnail from a video stream
- optimizeEsbuild for TypeScript and JSX/TSX workflows
- optimizeWasm for WebAssembly optimization
Example:
const { optimizeImage } = require('@studioframes/condense');
const { buffer, outMime } = await optimizeImage(rawBuffer, 'image/png', 'balanced');The built-in Express app exposes a POST /optimize endpoint and a GET /health endpoint.
Use a multipart form upload with a field named file. The request body can include:
- method: quality, balanced, or extreme
- width, height, fit for image resizing
- keepMetadata and keepFormat for image handling
- faststart, thumbnail for media processing
Example:
curl -X POST http://localhost:3000/optimize \
-F "file=@./photo.png;type=image/png" \
-F "method=balanced"Returns basic process and memory diagnostics for monitoring and debugging.
The CLI entry point is bin/cli.js. Typical usage looks like this:
npx @studioframes/condense optimize ./src -o ./dist -m balancedCondense handles the major format families implemented in the service layer, including images, text, media, esbuild-based code, and WebAssembly.
- Ignore directives remain supported for selective bypassing
- Some operations, such as media streaming, are best handled through the HTTP or streaming APIs
- For production deployments, consider using caching and request timeouts as needed