getImageInfo method

Future<ImageInfo?> getImageInfo(
  1. File file
)

Implementation

Future<ImageInfo?> getImageInfo(File file) async {
  try {
    final bytes = await file.readAsBytes();
    final image = img.decodeImage(bytes);

    if (image == null) return null;

    return ImageInfo(
      width: image.width,
      height: image.height,
      format: image.format.name,
      hasAlpha: image.hasAlpha,
    );
  } catch (e) {
    throw AssetOptException('Failed to read image ${file.path}: $e');
  }
}