mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-12-25 23:50:40 +00:00
a1ce17d675
* removed unused analytics event & added `logCrash` * added analytics to `RemoteConfigService` * run app with `runZonedGuarded` * added crash logging to `CameraContainerBloc` * log product id for IAP errors * typo * log crashes in `RemoteConfigService` * ignore silent `FlutterError` * fixed `evFromImage` test * fixed `showBuyProDialog` test * log errors in console * depend on iap 0.7.2 * Made errors non-fatal by default * improved EXIF errors reporting * fixed tests
27 lines
1.1 KiB
Dart
27 lines
1.1 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import 'package:exif/exif.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
|
|
|
Future<double> evFromImage(Uint8List bytes) async {
|
|
final tags = await readExifFromBytes(bytes);
|
|
final iso = double.tryParse("${tags["EXIF ISOSpeedRatings"]}");
|
|
final apertureValueRatio = (tags["EXIF FNumber"]?.values as IfdRatios?)?.ratios.first;
|
|
final speedValueRatio = (tags["EXIF ExposureTime"]?.values as IfdRatios?)?.ratios.first;
|
|
if (iso == null || apertureValueRatio == null || speedValueRatio == null) {
|
|
throw ArgumentError(
|
|
'Error parsing EXIF: ${tags.keys.join(', ')}',
|
|
[
|
|
if (iso == null) 'EXIF ISOSpeedRatings',
|
|
if (apertureValueRatio == null) 'EXIF FNumber',
|
|
if (speedValueRatio == null) 'EXIF ExposureTime',
|
|
].join(', '),
|
|
);
|
|
}
|
|
|
|
final aperture = apertureValueRatio.numerator / apertureValueRatio.denominator;
|
|
final speed = speedValueRatio.numerator / speedValueRatio.denominator;
|
|
|
|
return log2(math.pow(aperture, 2)) - log2(speed) - log2(iso / 100);
|
|
}
|