ImageCompressConfig class
Image compression request.
Priority: lossless > targetSizeKB (iterative, precise) > quality.
Constructors
- ImageCompressConfig({ImageFormat? format, int quality = 85, int? targetSizeKB, int? maxWidth, int? maxHeight, bool keepExif = false, bool lossless = false, bool keepOriginalIfLarger = true})
-
const
Properties
- format → ImageFormat?
-
Output format. When
null(the default), the source's format is kept (a PNG stays PNG, a JPEG stays JPEG); set it only to convert to a specific format. HEIC without a platform encoder falls back to JPEG; the real output format is reported on ImageCompressResult.format.final - hashCode → int
-
The hash code for this object.
no setterinherited
- keepExif → bool
-
Keep EXIF metadata (orientation, GPS, …). Default strips it.
final
- keepOriginalIfLarger → bool
-
If the compressed output would be larger than the source (common when
re-encoding an already-compressed JPEG, or with lossless), keep the
original untouched and mark the result ImageCompressResult.skipped.
Defaults to
true. ImageCompressResult.outputPath then points at the source, with its original size/format/dimensions.final - lossless → bool
-
Encode losslessly (pixel-for-pixel). When true, quality and
targetSizeKB are ignored — you can't lossless-encode to an arbitrary
size. The output format is preserved: PNG is truly lossless;
ImageFormat.webp uses its lossless mode where the platform supports it;
ImageFormat.jpeg has no lossless mode, so it stays JPEG encoded at
maximum quality (100). (ImageFormat.heic still falls back to JPEG on
platforms without a HEIC encoder.) maxWidth / maxHeight still apply if
set — "lossless" refers to the encode, not the resize.
final
- maxHeight → int?
-
final
- maxWidth → int?
-
Cap dimensions; aspect ratio is kept and the image is only scaled down.
final
- quality → int
-
1–100 quality, used when targetSizeKB is null (ignored for PNG).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- targetSizeKB → int?
-
Desired output size in KB. The native engines iterate (binary-search the
quality, then downscale if needed) to land at or just under this — images
encode in milliseconds, so this is accurate, unlike single-pass video.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited