Optimize assets in memory. Never touch disk.

Condense compresses images, audio, video, code, and WebAssembly through Buffers and Streams — stateless processing built for APIs, microservices, and serverless runtimes where disk I/O is undesirable.

npm version downloads License
View usage Star on GitHub
npm i @studioframes/condense
interactive benchmark · benchmark suite

Interactive visualization based on the project's real-world publishing benchmarks. Select a target to see file size reductions across different compression presets.

Why teams reach for Condense

in-memory

No temp files

Uploads and assets are processed entirely through Buffers and Streams. No state, zero temporary files written to disk.

stateless

Scales horizontally

Optimizations run cleanly in request handlers. No central worker databases, and perfect compatibility with load-balanced servers.

ephemeral

Serverless-ready

Perfect for lightweight, serverless runtimes (AWS Lambda, Cloud Functions) where write permissions are constrained.

intelligent

Dynamic Resizing

Includes built-in dynamic image aspect-ratio adjustments using standard width, height, and fit API parameters.

utilities

Video Extractor

Extracts beautiful JPEG/PNG video thumbnails and supports instant Standard MP4 Faststart optimizations directly on streams.

performance

Built-in LRU Cache

Dramatically reduces latency of static asset processing via an active memory store. Enable instantly via CONDENSE_CACHE=true.

Optimization methods

quality

Safest Fidelity

Visually lossless, highly secure compression preset that keeps maximum resolution and structure intact.

balanced

Sweet Spot

An ideal equilibrium. Uses mild lossy compressions (e.g., 65% Quality for JPEGs, CRF 26 for video feeds).

extreme

Max Reduction

Forces conversions to modern formats, strips console logs, clears WASM custom tags, and downscales video structures.

Extensive format coverage

Images
.png .jpg .jpeg .webp .avif .gif .svg
Audio
.mp3 .wav
Video
.mp4
Web Code
.html .css .js .ts .jsx .tsx .json .xml .yaml .yml .graphql .less .scss

Ignore directives

Opt out specific segments or entire assets from optimization using standard, non-intrusive annotations.

HTML Block Ignore
<!-- Use data-condense-ignore attribute -->
<div data-condense-ignore>
  <pre>
    Preserves exact formatted spacers
  </pre>
</div>
Code Skip Comment
/* condense-ignore */
function legacyParser() {
  // Spacing & keywords will stay untouched
  var size =   10;
}

Three ways to run it

CLI Runner
# Optimize a single local asset
npx @studioframes/condense optimize photo.png -o out.webp --method extreme

# Direct directory-wide bundle minimization
npx @studioframes/condense optimize ./src/ -o ./dist/ --method balanced
Express Middleware
const express = require('express');
const { condenseApp } = require('@studioframes/condense');

const app = express();
app.use('/v1', condenseApp);

app.listen(8080, () => {
  console.log('POST files to http://localhost:8080/v1/optimize');
});
Programmatic Helper SDK
const { optimizeImage } = require('@studioframes/condense');

const { buffer, outMime } = await optimizeImage(
  rawBuffer, 'image/png', 'quality'
);
// Returns lightweight optimized Buffer directly back into RAM
Copied to clipboard!