getSize static method

Future<Size> getSize(
  1. AsyncImageInput input
)

Implementation

static Future<Size> getSize(AsyncImageInput input) async {
  if (!await input.exists()) {
    throw Exception('The input is not exists.');
  }

  if (!(await input.supportRangeLoad())) {
    final delegateInput = await input.delegateInput();
    try {
      return ImageSizeGetter.getSize(delegateInput);
    } finally {
      delegateInput.release();
    }
  }

  if (await isJpg(input)) {
    return ad.JpegDecoder(input).size;
  }
  if (await isPng(input)) {
    return ad.PngDecoder(input).size;
  }
  if (await isWebp(input)) {
    return ad.WebpDecoder(input).size;
  }
  if (await isGif(input)) {
    return ad.GifDecoder(input).size;
  }

  throw Exception('The input is not supported.');
}