create static method

Future<SDNImageFile> create({
  1. required Uint8List bytes,
  2. required String name,
  3. String? mimeType,
  4. @Deprecated('Use [nativeImplementations] instead') ComputeRunner? compute,
  5. NativeImplementations nativeImplementations = NativeImplementations.dummy,
})

Creates a new image file and calculates the width, height and blurhash.

Implementation

static Future<SDNImageFile> create({
  required Uint8List bytes,
  required String name,
  String? mimeType,
  @Deprecated('Use [nativeImplementations] instead') ComputeRunner? compute,
  NativeImplementations nativeImplementations = NativeImplementations.dummy,
}) async {
  if (compute != null) {
    nativeImplementations =
        NativeImplementationsIsolate.fromRunInBackground(compute);
  }
  final metaData = await nativeImplementations.calcImageMetadata(bytes);

  return SDNImageFile(
    bytes: metaData?.bytes ?? bytes,
    name: name,
    mimeType: mimeType,
    width: metaData?.width,
    height: metaData?.height,
    blurhash: metaData?.blurhash,
  );
}