getImageSize static method

Future<Size> getImageSize(
  1. Uint8List bytes
)

get image size with exif

Implementation

static Future<Size> getImageSize(Uint8List bytes) async {
  try {
    Map<String?, IfdTag>? data =
      await readExifFromBytes(bytes);
    double width = data?['EXIF ExifImageWidth']?.values?[0].toDouble();
    double height = data?['EXIF ExifImageLength']?.values?[0].toDouble();
    if(width > height) {
      if (data!['Image Orientation']!.printable!.contains('Horizontal')) {
        return Size(width.toDouble(), height);
      }else {
        return Size(height, width);
      }
    }else{
      return Size(width, height);
    }
  } catch (e) {
    imageGetter.ImageInput imageInput = imageGetter.MemoryInput(bytes);
    double width = imageGetter.ImageSizeGetter.getSize(imageInput).width.toDouble();
    double height = imageGetter.ImageSizeGetter.getSize(imageInput).height.toDouble();
    final Size memoryImageSize = Size(width, height);
    return Size(memoryImageSize.width, memoryImageSize.height);
  }

}