Overview
All TypeScript types exported by@sanity-labs/logo-soup. Import them from the main package:
LogoSoupEngine
The engine interface returned bycreateLogoSoup().
Trigger a processing run. Call when inputs change. Automatically cancels any in-flight work.
Subscribe to state changes. Returns an unsubscribe function.
Get the current immutable state snapshot. Returns the same reference if nothing changed.
Clean up resources: revoke blob URLs, cancel work, clear cache, remove listeners.
LogoSoupState
Immutable state snapshot returned byengine.getSnapshot().
Current processing status:
idle— Initial state before firstprocess()callloading— Loading or measuring imagesready— Processing complete, normalized logos availableerror— All logos failed to load
Array of successfully processed and normalized logos. Empty if not ready or if all failed.
Error object if status is
error, otherwise null.ProcessOptions
Options passed toengine.process().
Array of logo URLs (strings) or logo objects with
src and optional alt text.Target size in pixels. All logos are normalized to this approximate size.
Shape handling factor (0-1):
0= Uniform widths (tall logos appear larger)1= Uniform heights (wide logos appear larger)0.5= Balanced (recommended)
Minimum contrast (0-255) for content detection. Lower values detect more subtle edges, higher values only detect high-contrast content.
Enable density compensation. When enabled:
- Dense/bold logos are scaled down
- Light/thin logos are scaled up
- Visual center data is computed for alignment
Strength of density compensation (0-1). Only applies when
densityAware: true.0= No density adjustment1= Full density adjustment0.5= Balanced (recommended)
Automatically crop whitespace/padding from logos. Creates blob URLs for cropped versions.Enable when logos have inconsistent padding baked into the images.
Background color for contrast detection on opaque logos. Can be:
- CSS color string:
'#ffffff','rgb(255, 255, 255)','hsl(0, 0%, 100%)' - RGB tuple:
[255, 255, 255]
NormalizedLogo
A processed and normalized logo with computed dimensions and metadata.Original logo URL.
Alt text for accessibility. Empty string if not provided.
Original image width in pixels.
Original image height in pixels.
Detected content bounding box (excludes whitespace/padding). Present if content detection found a smaller region than the full image.
Computed width for rendering in pixels, after normalization.
Computed height for rendering in pixels, after normalization.
Aspect ratio (
width / height) of the content box or original image.Visual weight density (0-1). Higher values indicate denser/bolder logos. Present when
densityAware: true.Visual weight center data. Present when
densityAware: true and detection succeeded.Use with getVisualCenterTransform() for optical alignment.Blob URL for the cropped version of the logo. Present when
cropToContent: true and content box is smaller than the original.Use this instead of src when rendering to eliminate padding.Usage Example
AlignmentMode
Alignment mode for visual center transforms.bounds
Align by geometric center (bounding box). No transform applied.
visual-center
Align by visual weight center on both X and Y axes.
visual-center-x
Align by visual center horizontally only.
visual-center-y
Align by visual center vertically only. Recommended for horizontal logo strips.
LogoSource
Logo input with optional alt text.Logo URL. Can be relative, absolute, or a data URL.
Alt text for accessibility. If omitted, defaults to empty string.
Usage
VisualCenter
Visual weight center data for a logo.Visual center X coordinate in pixels (relative to the content box or original image).
Visual center Y coordinate in pixels (relative to the content box or original image).
Horizontal offset in pixels from the geometric center. Negative = visual center is left of geometric center.
Vertical offset in pixels from the geometric center. Negative = visual center is above geometric center.
BoundingBox
Rectangular region in pixels.Left edge X coordinate in pixels.
Top edge Y coordinate in pixels.
Width in pixels.
Height in pixels.
MeasurementResult
Raw measurement data for a logo (internal).Original image width.
Original image height.
Detected content region (if smaller than full image).
Visual weight density (0-1).
Visual weight center data.
Detected background luminance (0-255). Used for irradiation compensation.
NormalizedLogo instead.