diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index f2a7a0ff1..d1bd0a311 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -7,6 +7,8 @@
android:name="io.flutter.app.FlutterApplication"
android:label="Aves"
android:icon="@mipmap/ic_launcher">
+
metadataMap = new HashMap<>();
- if (directory != null) {
- if (directory.containsTag(ExifSubIFDDirectory.TAG_FNUMBER)) {
- metadataMap.put("aperture", directory.getDescription(ExifSubIFDDirectory.TAG_FNUMBER));
- }
- if (directory.containsTag(ExifSubIFDDirectory.TAG_EXPOSURE_TIME)) {
- metadataMap.put("exposureTime", directory.getString(ExifSubIFDDirectory.TAG_EXPOSURE_TIME));
- }
- if (directory.containsTag(ExifSubIFDDirectory.TAG_FOCAL_LENGTH)) {
- metadataMap.put("focalLength", directory.getDescription(ExifSubIFDDirectory.TAG_FOCAL_LENGTH));
- }
- if (directory.containsTag(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT)) {
- metadataMap.put("iso", "ISO" + directory.getDescription(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT));
- }
- }
- result.success(metadataMap);
- } catch (ImageProcessingException e) {
- result.error("getOverlayMetadata-imageprocessing", "failed to get metadata for path=" + path + " (" + e.getMessage() + ")", null);
- } catch (FileNotFoundException e) {
- result.error("getOverlayMetadata-filenotfound", "failed to get metadata for path=" + path + " (" + e.getMessage() + ")", null);
- } catch (Exception e) {
- result.error("getOverlayMetadata-exception", "failed to get metadata for path=" + path, e);
- }
- }
-
private void getAllMetadata(MethodCall call, MethodChannel.Result result) {
String path = call.argument("path");
try (InputStream is = new FileInputStream(path)) {
@@ -159,4 +139,84 @@ public class MetadataHandler implements MethodChannel.MethodCallHandler {
result.error("getAllVideoMetadataFallback-exception", "failed to get metadata for path=" + path, e);
}
}
+
+ private void getCatalogMetadata(MethodCall call, MethodChannel.Result result) {
+ String path = call.argument("path");
+ try (InputStream is = new FileInputStream(path)) {
+ Metadata metadata = ImageMetadataReader.readMetadata(is);
+ Map metadataMap = new HashMap<>();
+
+ // EXIF Sub-IFD
+ ExifSubIFDDirectory exifSubDir = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
+ if (exifSubDir != null) {
+ if (exifSubDir.containsTag(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL)) {
+ metadataMap.put("dateMillis", exifSubDir.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL, null, TimeZone.getDefault()).getTime());
+ }
+ }
+
+ // GPS
+ GpsDirectory gpsDir = metadata.getFirstDirectoryOfType(GpsDirectory.class);
+ if (gpsDir != null) {
+ GeoLocation geoLocation = gpsDir.getGeoLocation();
+ if (geoLocation != null) {
+ metadataMap.put("latitude", geoLocation.getLatitude());
+ metadataMap.put("longitude", geoLocation.getLongitude());
+ }
+ }
+
+ // XMP
+ XmpDirectory xmpDir = metadata.getFirstDirectoryOfType(XmpDirectory.class);
+ if (xmpDir != null) {
+ XMPMeta xmpMeta = xmpDir.getXMPMeta();
+ try {
+ if (xmpMeta.doesPropertyExist(XMP_DC_SCHEMA_NS, XMP_SUBJECT_PROP_NAME)) {
+ StringBuilder sb = new StringBuilder();
+ int count = xmpMeta.countArrayItems(XMP_DC_SCHEMA_NS, XMP_SUBJECT_PROP_NAME);
+ for (int i = 1; i < count + 1; i++) {
+ XMPProperty item = xmpMeta.getArrayItem(XMP_DC_SCHEMA_NS, XMP_SUBJECT_PROP_NAME, i);
+ sb.append(" ").append(item.getValue());
+ }
+ metadataMap.put("keywords", sb.toString());
+ }
+ } catch (XMPException e) {
+ e.printStackTrace();
+ }
+ }
+ result.success(metadataMap);
+ } catch (FileNotFoundException e) {
+ result.error("getCatalogMetadata-filenotfound", "failed to get metadata for path=" + path + " (" + e.getMessage() + ")", null);
+ } catch (Exception e) {
+ result.error("getCatalogMetadata-exception", "failed to get metadata for path=" + path, e);
+ }
+ }
+
+ private void getOverlayMetadata(MethodCall call, MethodChannel.Result result) {
+ String path = call.argument("path");
+ try (InputStream is = new FileInputStream(path)) {
+ Metadata metadata = ImageMetadataReader.readMetadata(is);
+ ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
+ Map metadataMap = new HashMap<>();
+ if (directory != null) {
+ if (directory.containsTag(ExifSubIFDDirectory.TAG_FNUMBER)) {
+ metadataMap.put("aperture", directory.getDescription(ExifSubIFDDirectory.TAG_FNUMBER));
+ }
+ if (directory.containsTag(ExifSubIFDDirectory.TAG_EXPOSURE_TIME)) {
+ metadataMap.put("exposureTime", directory.getString(ExifSubIFDDirectory.TAG_EXPOSURE_TIME));
+ }
+ if (directory.containsTag(ExifSubIFDDirectory.TAG_FOCAL_LENGTH)) {
+ metadataMap.put("focalLength", directory.getDescription(ExifSubIFDDirectory.TAG_FOCAL_LENGTH));
+ }
+ if (directory.containsTag(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT)) {
+ metadataMap.put("iso", "ISO" + directory.getDescription(ExifSubIFDDirectory.TAG_ISO_EQUIVALENT));
+ }
+ }
+ result.success(metadataMap);
+ } catch (ImageProcessingException e) {
+ result.error("getOverlayMetadata-imageprocessing", "failed to get metadata for path=" + path + " (" + e.getMessage() + ")", null);
+ } catch (FileNotFoundException e) {
+ result.error("getOverlayMetadata-filenotfound", "failed to get metadata for path=" + path + " (" + e.getMessage() + ")", null);
+ } catch (Exception e) {
+ result.error("getOverlayMetadata-exception", "failed to get metadata for path=" + path, e);
+ }
+ }
}
\ No newline at end of file
diff --git a/lib/model/metadata_service.dart b/lib/model/metadata_service.dart
index 9a37dfa2f..624faa928 100644
--- a/lib/model/metadata_service.dart
+++ b/lib/model/metadata_service.dart
@@ -4,20 +4,7 @@ import 'package:flutter/services.dart';
class MetadataService {
static const platform = const MethodChannel('deckers.thibault/aves/metadata');
- // return map with: 'aperture' 'exposureTime' 'focalLength' 'iso'
- static Future