ImageCompressionOptions class

Configuration for in-place image compression before upload.

Constructors

ImageCompressionOptions({int skipBelowBytes = 1 * 1024 * 1024, int maxDimension = 2048, List<CompressionTier> tiers = const [CompressionTier(minBytes: 8 * 1024 * 1024, jpegQuality: 75), CompressionTier(minBytes: 4 * 1024 * 1024, jpegQuality: 80), CompressionTier(jpegQuality: 85)], Interpolation interpolation = img.Interpolation.linear})
const
ImageCompressionOptions.aggressive()
Aggressive compression for bandwidth-constrained scenarios. Downscale to 640px, 60% quality.
factory
ImageCompressionOptions.disabled()
Disables compression entirely. compressImage returns the original bytes.
factory
ImageCompressionOptions.preserveQuality()
Preserve maximum quality (still re-encodes if over skipBelowBytes). No downscale, 95% quality.
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
interpolation → Interpolation
Interpolation algorithm for downscaling. Default: linear.
final
maxDimension int
Maximum dimension (longest side) in pixels. Larger images are downscaled preserving aspect ratio. Default: 2048.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
skipBelowBytes int
Files at or below this byte size are returned unchanged (no re-encode). Default: 1 MB.
final
tiers List<CompressionTier>
Quality tiers, evaluated in minBytes descending order. First match wins. Include one tier with minBytes: null as catch-all.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolveQualityFor(int fileBytes) int
Resolves the JPEG quality for a file of the given size, walking the tier list in minBytes descending order. Tiers with null minBytes are treated as catch-all and evaluated last.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override