-
Notifications
You must be signed in to change notification settings - Fork 52
/
index.js
54 lines (45 loc) · 1.37 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {
Platform,
NativeModules,
} from 'react-native';
const Exif = {};
function unifyAndroid(exif) {
const output = {};
output.ImageWidth = parseInt(exif.ImageWidth);
output.ImageHeight = parseInt(exif.ImageLength);
output.Orientation = parseInt(exif.Orientation);
output.originalUri = exif.originalUri;
output.exif = exif;
return output;
}
function unifyIOS(exif) {
const output = {};
output.ImageWidth = exif.PixelWidth;
output.ImageHeight = exif.PixelHeight;
output.Orientation = exif.Orientation;
output.originalUri = exif.originalUri;
output.exif = exif;
return output;
}
Exif.getExif = function (uri) {
const path = uri.replace('file://', '');
return NativeModules.ReactNativeExif.getExif(path).then(result => {
if (Platform.OS === 'android') {
return unifyAndroid(result);
}
return unifyIOS(result);
});
};
Exif.getExifWithLocalIdentifier = function (localIdentifier) {
return NativeModules.ReactNativeExif.getExifWithLocalIdentifier(localIdentifier).then(result => {
if (Platform.OS === 'android') {
return unifyAndroid(result);
}
return unifyIOS(result);
});
};
Exif.getLatLong = function (uri) {
const path = uri.replace('file://', '');
return NativeModules.ReactNativeExif.getLatLong(path);
};
module.exports = Exif;