getImageProperties static method
Gets the properties of an image
Gets the properties of an image given the fileName
.
Implementation
static Future<ImageProperties> getImageProperties(String fileName) async {
ImageOrientation decodeOrientation(int? orientation) {
// For details, see: https://developer.android.com/reference/android/media/ExifInterface
switch (orientation) {
case 1:
return ImageOrientation.normal;
case 2:
return ImageOrientation.flipHorizontal;
case 3:
return ImageOrientation.rotate180;
case 4:
return ImageOrientation.flipVertical;
case 5:
return ImageOrientation.transpose;
case 6:
return ImageOrientation.rotate90;
case 7:
return ImageOrientation.transverse;
case 8:
return ImageOrientation.rotate270;
default:
return ImageOrientation.undefined;
}
}
var properties = Map.from(await (_channel.invokeMethod("getImageProperties", {'file': fileName})));
return new ImageProperties(
width: properties["width"],
height: properties["height"],
orientation: decodeOrientation(properties["orientation"]));
}