shrink static method

Future<SDNImageFile> shrink({
  1. required Uint8List bytes,
  2. required String name,
  3. int maxDimension = 1600,
  4. String? mimeType,
  5. Future<SDNImageFileResizedResponse?> customImageResizer(
    1. SDNImageFileResizeArguments
    )?,
  6. @Deprecated('Use [nativeImplementations] instead') ComputeRunner? compute,
  7. 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;
}