resizeImplementation static method

SDNImageFileResizedResponse? resizeImplementation(
  1. SDNImageFileResizeArguments arguments
)

you would likely want to use NativeImplementations and Client.nativeImplementations instead

Implementation

static SDNImageFileResizedResponse? resizeImplementation(
    SDNImageFileResizeArguments arguments) {
  final image = decodeImage(arguments.bytes);

  final resized = copyResize(image!,
      height: image.height > image.width ? arguments.maxDimension : null,
      width: image.width >= image.height ? arguments.maxDimension : null);

  final encoded = encodeNamedImage(arguments.fileName, resized);
  if (encoded == null) return null;
  final bytes = Uint8List.fromList(encoded);
  return SDNImageFileResizedResponse(
    bytes: bytes,
    width: resized.width,
    height: resized.height,
    originalHeight: image.height,
    originalWidth: image.width,
    blurhash: arguments.calcBlurhash
        ? BlurHash.encode(
            resized,
            numCompX: 4,
            numCompY: 3,
          ).hash
        : null,
  );
}