shrink static method
Future<SDNImageFile>
shrink({
- required Uint8List bytes,
- required String name,
- int maxDimension = 1600,
- String? mimeType,
- Future<
SDNImageFileResizedResponse?> customImageResizer()?, - @Deprecated('Use [nativeImplementations] instead') ComputeRunner? compute,
- NativeImplementations nativeImplementations = NativeImplementations.dummy,
Builds a SDNImageFile and shrinks it in order to reduce traffic. If shrinking does not work (e.g. for unsupported MIME types), the initial image is preserved without shrinking it.
Implementation
static Future<SDNImageFile> shrink({
required Uint8List bytes,
required String name,
int maxDimension = 1600,
String? mimeType,
Future<SDNImageFileResizedResponse?> Function(SDNImageFileResizeArguments)?
customImageResizer,
@Deprecated('Use [nativeImplementations] instead') ComputeRunner? compute,
NativeImplementations nativeImplementations = NativeImplementations.dummy,
}) async {
if (compute != null) {
nativeImplementations =
NativeImplementationsIsolate.fromRunInBackground(compute);
}
final image = SDNImageFile(name: name, mimeType: mimeType, bytes: bytes);
return await image.generateThumbnail(
dimension: maxDimension,
customImageResizer: customImageResizer,
nativeImplementations: nativeImplementations) ??
image;
}