CompressionOptions class
Configuration options for image compression and format optimization.
Constructors
- CompressionOptions({int? maxBytes, int quality = 85, int minQuality = 10, int? maxWidth, int? maxHeight, OutputFormat format = OutputFormat.preserve, bool autoOrientation = true, bool keepExif = false})
-
Creates a new CompressionOptions instance.
const
- CompressionOptions.avatar({int maxBytes = 200 * 1024})
-
Profile avatar preset (512x512, max 200 KB, quality 85).
factory
- CompressionOptions.targetSize(int bytes, {OutputFormat format = OutputFormat.preserve})
-
Target size compressor preset with binary search.
factory
- CompressionOptions.thumbnail({int maxBytes = 50 * 1024})
-
Thumbnail preset (max 256x256, max 50 KB).
factory
- CompressionOptions.webOptimized({int maxBytes = 500 * 1024})
-
Web-optimized preset (max 1920x1080, max 500 KB, WebP format).
factory
Properties
- autoOrientation → bool
-
Whether to automatically bake EXIF orientation into the image pixels.
final
- format → OutputFormat
-
Target encoding format.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- keepExif → bool
-
Whether to preserve EXIF metadata if supported by the encoder.
final
- maxBytes → int?
-
Target maximum file size in bytes (e.g., 500 * 1024 for 500 KB).
final
- maxHeight → int?
-
Maximum pixel height of the output image.
If specified and the image exceeds this height, it will be proportionally scaled down.
final
- maxWidth → int?
-
Maximum pixel width of the output image.
If specified and the image exceeds this width, it will be proportionally scaled down.
final
- minQuality → int
-
Minimum acceptable quality factor when performing binary search compression.
final
- quality → int
-
Compression quality factor from 1 (lowest) to 100 (highest).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copyWith(
{int? maxBytes, int? quality, int? minQuality, int? maxWidth, int? maxHeight, OutputFormat? format, bool? autoOrientation, bool? keepExif}) → CompressionOptions - Creates a copy of this CompressionOptions with specified attributes updated.
-
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