Returns
LogoSoupEngine — an object with the following methods:
engine.process(options)
Triggers a processing run. Loads images, measures them, and produces normalized dimensions. Cancels any in-flight work from a previous process() call.
The processing options. See Options Reference for full details.
- If
logosis empty, transitions directly to"ready"with an empty array (synchronous). - If all logos are already cached, re-normalizes from cache (synchronous, no network requests).
- Otherwise, transitions to
"loading", fetches images, measures them, and transitions to"ready"or"error". - Calling
process()again while loading cancels the previous run. Only the latest call’s results are emitted.
engine.subscribe(listener)
Subscribes to state changes. Returns an unsubscribe function.
A callback invoked whenever the engine’s state changes. The listener receives no arguments — call
getSnapshot() inside it to read the current state.() => void — call this to unsubscribe.
The
subscribe(callback) → unsubscribe shape is designed to plug directly into framework reactivity primitives: React’s useSyncExternalStore, Vue’s shallowRef, Svelte’s createSubscriber, Solid’s from(), and Angular’s signal().engine.getSnapshot()
Returns the current immutable state snapshot.
Returns: LogoSoupState
engine.destroy()
Cleans up the engine: revokes blob URLs created by cropToContent, cancels in-flight image loading, clears the measurement cache, and removes all subscribers.
destroy() when you’re done with the engine. Framework adapters handle this automatically on component unmount / scope disposal.
After calling destroy(), the engine ignores subsequent process() calls.
Types
LogoSoupEngine
LogoSoupState
| Status | Description |
|---|---|
"idle" | Initial state, before process() is called |
"loading" | Images are being fetched and measured |
"ready" | Normalization complete, normalizedLogos is populated |
"error" | All images failed to load, error is set |
If some images fail but others succeed, the engine transitions to
"ready" with the successful logos. "error" only occurs when every image fails.ProcessOptions
NormalizedLogo
Caching Behavior
The engine caches image measurements by URL. This means:- Changing
baseSizeorscaleFactorre-normalizes from cache (synchronous, no network). - Changing
contrastThreshold,densityAware, orbackgroundColorinvalidates the cache because these affect the measurement itself. - Adding new logos only loads the new ones; previously cached logos are reused.
- Removing logos prunes their cache entries and revokes any associated blob URLs.