ImageOptimizer class

Utility for automatically optimizing and downscaling images for on-device SLMs (e.g. Gemini Nano on Android, Apple FoundationModels) and multimodal LLMs.

Constructors

ImageOptimizer()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

isImageMime(String? mimeType) → bool
Determines whether a MIME type represents a supported image format.
shrinkToOptimalSize(Uint8List inputBytes, {int maxDimension = defaultMaxDimension}) → Future<Uint8List>
Downscales inputBytes so that neither width nor height exceeds maxDimension, preserving the original aspect ratio.

Constants

defaultMaxDimension → const int
Default optimal max dimension (width or height) for on-device and mobile models. 768px provides rich visual fidelity while keeping payload sizes under ~100 KB and avoiding mobile NPU memory bottlenecks / OOM.