getImageExifInfoByBuffer static method

Future<ImageExifInfo?> getImageExifInfoByBuffer({
  1. required Uint8List fileBuffer,
})

Implementation

static Future<ImageExifInfo?> getImageExifInfoByBuffer({
  required Uint8List fileBuffer,
}) async {
  if (kIsWeb) {
    return null;
  }

  final data = await readExifFromBytes(fileBuffer);

  String? owidth = data["EXIF ExifImageWidth"]?.printable;
  String? oheight = data["EXIF ExifImageLength"]?.printable;
  bool isRotate = false;
  String rotate = data["Image Orientation"]?.printable ?? "";
  if (owidth != null && owidth != '0' && oheight != null && oheight != '0') {
    if (rotate.contains("90") || rotate.contains("270")) {
      isRotate = true;
    }
    if (isRotate) {
      (owidth, oheight) = (oheight, owidth);
    }
    return ImageExifInfo(height: double.parse(oheight), width: double.parse(owidth), isRotate: isRotate);
  }
  return null;
}