@capawesome/capacitor-exif 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapawesomeCapacitorExif.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +322 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/Exif.java +289 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/ExifPlugin.java +120 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/classes/CustomException.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/classes/CustomExceptions.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/classes/options/ReadExifOptions.java +36 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/classes/options/RemoveExifOptions.java +43 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/classes/options/WriteExifOptions.java +185 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/classes/results/ReadExifResult.java +152 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/interfaces/Callback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/interfaces/EmptyCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/exif/interfaces/Result.java +7 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +746 -0
- package/dist/esm/definitions.d.ts +375 -0
- package/dist/esm/definitions.js +32 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +7 -0
- package/dist/esm/web.js +13 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +59 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +62 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Options/ReadExifOptions.swift +20 -0
- package/ios/Plugin/Classes/Options/RemoveExifOptions.swift +12 -0
- package/ios/Plugin/Classes/Options/WriteExifOptions.swift +49 -0
- package/ios/Plugin/Classes/Results/ReadExifResult.swift +75 -0
- package/ios/Plugin/Enums/CustomError.swift +54 -0
- package/ios/Plugin/Exif.swift +219 -0
- package/ios/Plugin/ExifPlugin.swift +83 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +5 -0
- package/package.json +97 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.exif.classes.options;
|
|
2
|
+
|
|
3
|
+
import android.net.Uri;
|
|
4
|
+
import androidx.annotation.NonNull;
|
|
5
|
+
import androidx.annotation.Nullable;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import com.getcapacitor.PluginCall;
|
|
8
|
+
import io.capawesome.capacitorjs.plugins.exif.classes.CustomExceptions;
|
|
9
|
+
|
|
10
|
+
public class WriteExifOptions {
|
|
11
|
+
|
|
12
|
+
@Nullable
|
|
13
|
+
private final String dateTimeOriginal;
|
|
14
|
+
|
|
15
|
+
@Nullable
|
|
16
|
+
private final Double exposureTime;
|
|
17
|
+
|
|
18
|
+
@Nullable
|
|
19
|
+
private final Double fNumber;
|
|
20
|
+
|
|
21
|
+
@Nullable
|
|
22
|
+
private final Boolean flash;
|
|
23
|
+
|
|
24
|
+
@Nullable
|
|
25
|
+
private final Double focalLength;
|
|
26
|
+
|
|
27
|
+
@Nullable
|
|
28
|
+
private final Double gpsAltitude;
|
|
29
|
+
|
|
30
|
+
@Nullable
|
|
31
|
+
private final Double gpsLatitude;
|
|
32
|
+
|
|
33
|
+
@Nullable
|
|
34
|
+
private final Double gpsLongitude;
|
|
35
|
+
|
|
36
|
+
@Nullable
|
|
37
|
+
private final Integer iso;
|
|
38
|
+
|
|
39
|
+
@Nullable
|
|
40
|
+
private final String lensModel;
|
|
41
|
+
|
|
42
|
+
@Nullable
|
|
43
|
+
private final String make;
|
|
44
|
+
|
|
45
|
+
@Nullable
|
|
46
|
+
private final String model;
|
|
47
|
+
|
|
48
|
+
@Nullable
|
|
49
|
+
private final Integer orientation;
|
|
50
|
+
|
|
51
|
+
@NonNull
|
|
52
|
+
private final String path;
|
|
53
|
+
|
|
54
|
+
@Nullable
|
|
55
|
+
private final String software;
|
|
56
|
+
|
|
57
|
+
public WriteExifOptions(@NonNull PluginCall call) throws Exception {
|
|
58
|
+
JSObject tags = WriteExifOptions.getTagsFromCall(call);
|
|
59
|
+
this.dateTimeOriginal = tags.getString("dateTimeOriginal");
|
|
60
|
+
this.exposureTime = WriteExifOptions.getDoubleFromTags(tags, "exposureTime");
|
|
61
|
+
this.fNumber = WriteExifOptions.getDoubleFromTags(tags, "fNumber");
|
|
62
|
+
this.flash = tags.getBool("flash");
|
|
63
|
+
this.focalLength = WriteExifOptions.getDoubleFromTags(tags, "focalLength");
|
|
64
|
+
this.gpsAltitude = WriteExifOptions.getDoubleFromTags(tags, "gpsAltitude");
|
|
65
|
+
this.gpsLatitude = WriteExifOptions.getDoubleFromTags(tags, "gpsLatitude");
|
|
66
|
+
this.gpsLongitude = WriteExifOptions.getDoubleFromTags(tags, "gpsLongitude");
|
|
67
|
+
this.iso = tags.getInteger("iso");
|
|
68
|
+
this.lensModel = tags.getString("lensModel");
|
|
69
|
+
this.make = tags.getString("make");
|
|
70
|
+
this.model = tags.getString("model");
|
|
71
|
+
this.orientation = tags.getInteger("orientation");
|
|
72
|
+
this.path = WriteExifOptions.getPathFromCall(call);
|
|
73
|
+
this.software = tags.getString("software");
|
|
74
|
+
if ((gpsLatitude == null) != (gpsLongitude == null)) {
|
|
75
|
+
throw CustomExceptions.GPS_COORDINATES_INCOMPLETE;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Nullable
|
|
80
|
+
public String getDateTimeOriginal() {
|
|
81
|
+
return dateTimeOriginal;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Nullable
|
|
85
|
+
public Double getExposureTime() {
|
|
86
|
+
return exposureTime;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Nullable
|
|
90
|
+
public Double getFNumber() {
|
|
91
|
+
return fNumber;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Nullable
|
|
95
|
+
public Boolean getFlash() {
|
|
96
|
+
return flash;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Nullable
|
|
100
|
+
public Double getFocalLength() {
|
|
101
|
+
return focalLength;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@Nullable
|
|
105
|
+
public Double getGpsAltitude() {
|
|
106
|
+
return gpsAltitude;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Nullable
|
|
110
|
+
public Double getGpsLatitude() {
|
|
111
|
+
return gpsLatitude;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@Nullable
|
|
115
|
+
public Double getGpsLongitude() {
|
|
116
|
+
return gpsLongitude;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@Nullable
|
|
120
|
+
public Integer getIso() {
|
|
121
|
+
return iso;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@Nullable
|
|
125
|
+
public String getLensModel() {
|
|
126
|
+
return lensModel;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@Nullable
|
|
130
|
+
public String getMake() {
|
|
131
|
+
return make;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@Nullable
|
|
135
|
+
public String getModel() {
|
|
136
|
+
return model;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@Nullable
|
|
140
|
+
public Integer getOrientation() {
|
|
141
|
+
return orientation;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@NonNull
|
|
145
|
+
public String getPath() {
|
|
146
|
+
return path;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@Nullable
|
|
150
|
+
public String getSoftware() {
|
|
151
|
+
return software;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@Nullable
|
|
155
|
+
private static Double getDoubleFromTags(@NonNull JSObject tags, @NonNull String key) throws Exception {
|
|
156
|
+
if (!tags.has(key)) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return tags.getDouble(key);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@NonNull
|
|
163
|
+
private static String getPathFromCall(@NonNull PluginCall call) throws Exception {
|
|
164
|
+
String path = call.getString("path");
|
|
165
|
+
if (path == null || path.isEmpty()) {
|
|
166
|
+
throw CustomExceptions.PATH_MISSING;
|
|
167
|
+
}
|
|
168
|
+
if (path.startsWith("file://")) {
|
|
169
|
+
String uriPath = Uri.parse(path).getPath();
|
|
170
|
+
if (uriPath != null) {
|
|
171
|
+
return uriPath;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return path;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@NonNull
|
|
178
|
+
private static JSObject getTagsFromCall(@NonNull PluginCall call) throws Exception {
|
|
179
|
+
JSObject tags = call.getObject("tags");
|
|
180
|
+
if (tags == null) {
|
|
181
|
+
throw CustomExceptions.TAGS_MISSING;
|
|
182
|
+
}
|
|
183
|
+
return tags;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.exif.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import androidx.exifinterface.media.ExifInterface;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import io.capawesome.capacitorjs.plugins.exif.interfaces.Result;
|
|
8
|
+
|
|
9
|
+
public class ReadExifResult implements Result {
|
|
10
|
+
|
|
11
|
+
@Nullable
|
|
12
|
+
private final String dateTimeOriginal;
|
|
13
|
+
|
|
14
|
+
@Nullable
|
|
15
|
+
private final Double exposureTime;
|
|
16
|
+
|
|
17
|
+
@Nullable
|
|
18
|
+
private final Double fNumber;
|
|
19
|
+
|
|
20
|
+
@Nullable
|
|
21
|
+
private final Boolean flash;
|
|
22
|
+
|
|
23
|
+
@Nullable
|
|
24
|
+
private final Double focalLength;
|
|
25
|
+
|
|
26
|
+
@Nullable
|
|
27
|
+
private final Double gpsAltitude;
|
|
28
|
+
|
|
29
|
+
@Nullable
|
|
30
|
+
private final Double gpsLatitude;
|
|
31
|
+
|
|
32
|
+
@Nullable
|
|
33
|
+
private final Double gpsLongitude;
|
|
34
|
+
|
|
35
|
+
@Nullable
|
|
36
|
+
private final Integer iso;
|
|
37
|
+
|
|
38
|
+
@Nullable
|
|
39
|
+
private final String lensModel;
|
|
40
|
+
|
|
41
|
+
@Nullable
|
|
42
|
+
private final String make;
|
|
43
|
+
|
|
44
|
+
@Nullable
|
|
45
|
+
private final String model;
|
|
46
|
+
|
|
47
|
+
@Nullable
|
|
48
|
+
private final Integer orientation;
|
|
49
|
+
|
|
50
|
+
@Nullable
|
|
51
|
+
private final Integer pixelHeight;
|
|
52
|
+
|
|
53
|
+
@Nullable
|
|
54
|
+
private final Integer pixelWidth;
|
|
55
|
+
|
|
56
|
+
@Nullable
|
|
57
|
+
private final String software;
|
|
58
|
+
|
|
59
|
+
public ReadExifResult(@NonNull ExifInterface exifInterface, @Nullable Integer pixelWidth, @Nullable Integer pixelHeight) {
|
|
60
|
+
double[] latLong = exifInterface.getLatLong();
|
|
61
|
+
Integer flashValue = ReadExifResult.getIntAttribute(exifInterface, ExifInterface.TAG_FLASH);
|
|
62
|
+
this.dateTimeOriginal = exifInterface.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL);
|
|
63
|
+
this.exposureTime = ReadExifResult.getDoubleAttribute(exifInterface, ExifInterface.TAG_EXPOSURE_TIME);
|
|
64
|
+
this.fNumber = ReadExifResult.getDoubleAttribute(exifInterface, ExifInterface.TAG_F_NUMBER);
|
|
65
|
+
this.flash = flashValue == null ? null : (flashValue & 1) == 1;
|
|
66
|
+
this.focalLength = ReadExifResult.getDoubleAttribute(exifInterface, ExifInterface.TAG_FOCAL_LENGTH);
|
|
67
|
+
this.gpsAltitude = exifInterface.hasAttribute(ExifInterface.TAG_GPS_ALTITUDE) ? exifInterface.getAltitude(0) : null;
|
|
68
|
+
this.gpsLatitude = latLong == null ? null : latLong[0];
|
|
69
|
+
this.gpsLongitude = latLong == null ? null : latLong[1];
|
|
70
|
+
this.iso = ReadExifResult.getIntAttribute(exifInterface, ExifInterface.TAG_PHOTOGRAPHIC_SENSITIVITY);
|
|
71
|
+
this.lensModel = exifInterface.getAttribute(ExifInterface.TAG_LENS_MODEL);
|
|
72
|
+
this.make = exifInterface.getAttribute(ExifInterface.TAG_MAKE);
|
|
73
|
+
this.model = exifInterface.getAttribute(ExifInterface.TAG_MODEL);
|
|
74
|
+
this.orientation = ReadExifResult.getIntAttribute(exifInterface, ExifInterface.TAG_ORIENTATION);
|
|
75
|
+
this.pixelHeight = pixelHeight;
|
|
76
|
+
this.pixelWidth = pixelWidth;
|
|
77
|
+
this.software = exifInterface.getAttribute(ExifInterface.TAG_SOFTWARE);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Override
|
|
81
|
+
@NonNull
|
|
82
|
+
public JSObject toJSObject() {
|
|
83
|
+
JSObject tags = new JSObject();
|
|
84
|
+
if (dateTimeOriginal != null) {
|
|
85
|
+
tags.put("dateTimeOriginal", dateTimeOriginal);
|
|
86
|
+
}
|
|
87
|
+
if (exposureTime != null) {
|
|
88
|
+
tags.put("exposureTime", (double) exposureTime);
|
|
89
|
+
}
|
|
90
|
+
if (fNumber != null) {
|
|
91
|
+
tags.put("fNumber", (double) fNumber);
|
|
92
|
+
}
|
|
93
|
+
if (flash != null) {
|
|
94
|
+
tags.put("flash", (boolean) flash);
|
|
95
|
+
}
|
|
96
|
+
if (focalLength != null) {
|
|
97
|
+
tags.put("focalLength", (double) focalLength);
|
|
98
|
+
}
|
|
99
|
+
if (gpsAltitude != null) {
|
|
100
|
+
tags.put("gpsAltitude", (double) gpsAltitude);
|
|
101
|
+
}
|
|
102
|
+
if (gpsLatitude != null) {
|
|
103
|
+
tags.put("gpsLatitude", (double) gpsLatitude);
|
|
104
|
+
}
|
|
105
|
+
if (gpsLongitude != null) {
|
|
106
|
+
tags.put("gpsLongitude", (double) gpsLongitude);
|
|
107
|
+
}
|
|
108
|
+
if (iso != null) {
|
|
109
|
+
tags.put("iso", (int) iso);
|
|
110
|
+
}
|
|
111
|
+
if (lensModel != null) {
|
|
112
|
+
tags.put("lensModel", lensModel);
|
|
113
|
+
}
|
|
114
|
+
if (make != null) {
|
|
115
|
+
tags.put("make", make);
|
|
116
|
+
}
|
|
117
|
+
if (model != null) {
|
|
118
|
+
tags.put("model", model);
|
|
119
|
+
}
|
|
120
|
+
if (orientation != null) {
|
|
121
|
+
tags.put("orientation", (int) orientation);
|
|
122
|
+
}
|
|
123
|
+
if (pixelHeight != null) {
|
|
124
|
+
tags.put("pixelHeight", (int) pixelHeight);
|
|
125
|
+
}
|
|
126
|
+
if (pixelWidth != null) {
|
|
127
|
+
tags.put("pixelWidth", (int) pixelWidth);
|
|
128
|
+
}
|
|
129
|
+
if (software != null) {
|
|
130
|
+
tags.put("software", software);
|
|
131
|
+
}
|
|
132
|
+
JSObject result = new JSObject();
|
|
133
|
+
result.put("tags", tags);
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@Nullable
|
|
138
|
+
private static Double getDoubleAttribute(@NonNull ExifInterface exifInterface, @NonNull String tag) {
|
|
139
|
+
if (!exifInterface.hasAttribute(tag)) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return exifInterface.getAttributeDouble(tag, 0);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Nullable
|
|
146
|
+
private static Integer getIntAttribute(@NonNull ExifInterface exifInterface, @NonNull String tag) {
|
|
147
|
+
if (!exifInterface.hasAttribute(tag)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return exifInterface.getAttributeInt(tag, 0);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
File without changes
|