@lodev09/react-native-exify 0.1.0
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/Exify.podspec +41 -0
- package/LICENSE +20 -0
- package/README.md +50 -0
- package/android/build.gradle +95 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/exify/ExifyModule.kt +99 -0
- package/android/src/main/java/com/exify/ExifyPackage.kt +17 -0
- package/android/src/main/java/com/exify/ExifyTags.kt +142 -0
- package/android/src/main/java/com/exify/ExifyUtils.kt +41 -0
- package/ios/Exify-Bridging-Header.h +11 -0
- package/ios/Exify.mm +28 -0
- package/ios/Exify.swift +131 -0
- package/ios/Exify.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/Exify.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/Exify.xcodeproj/project.xcworkspace/xcuserdata/lodev09.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Exify.xcodeproj/xcuserdata/lodev09.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/ExifyUtils.swift +131 -0
- package/lib/commonjs/index.js +53 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/index.js +31 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/src/index.d.ts +16 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +161 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +181 -0
- package/src/index.ts +40 -0
- package/src/types.ts +161 -0
package/Exify.podspec
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "Exify"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
15
|
+
s.source = { :git => "https://github.com/lodev09/react-native-exify.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
+
|
|
19
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
20
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
21
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
22
|
+
install_modules_dependencies(s)
|
|
23
|
+
else
|
|
24
|
+
s.dependency "React-Core"
|
|
25
|
+
|
|
26
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
27
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
28
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
29
|
+
s.pod_target_xcconfig = {
|
|
30
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
31
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
32
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
33
|
+
}
|
|
34
|
+
s.dependency "React-Codegen"
|
|
35
|
+
s.dependency "RCT-Folly"
|
|
36
|
+
s.dependency "RCTRequired"
|
|
37
|
+
s.dependency "RCTTypeSafety"
|
|
38
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 lodev09
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @lodev09/react-native-exify
|
|
2
|
+
|
|
3
|
+
A simple library to read and write Exif metadata from images in React Native.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Read Exif data from an image
|
|
7
|
+
- Write Exif data into an image
|
|
8
|
+
- Tags are typed and standardized
|
|
9
|
+
- Works with Expo and bare React Native projects
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
yarn add @lodev09/react-native-exify
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { writeAsync, readAsync, ExifTags } from '@lodev09/react-native-exify';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 🧐 Reading Exif
|
|
24
|
+
```ts
|
|
25
|
+
// ...
|
|
26
|
+
const uri = 'file://path/to/image.jpg'
|
|
27
|
+
|
|
28
|
+
// Read exif from image via URI
|
|
29
|
+
const tags = await readAsync(uri)
|
|
30
|
+
console.log(tags)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ✍️ Writing Exif
|
|
34
|
+
```ts
|
|
35
|
+
const uri = 'file://path/to/image.jpg'
|
|
36
|
+
const newTags: ExifTags = {
|
|
37
|
+
Make: 'Apple',
|
|
38
|
+
Model: 'iPhone 12 Pro Max',
|
|
39
|
+
Software: '14.4.2'
|
|
40
|
+
}
|
|
41
|
+
const response = await writeAsync(uri, newTags)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
💡 Note: On IOS, writing exif into an Asset file will duplicate the image.
|
|
45
|
+
Try to write to a local file first before saving!
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
Contributions are welcome!
|
|
49
|
+
|
|
50
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Exify_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
apply plugin: "kotlin-android"
|
|
23
|
+
|
|
24
|
+
if (isNewArchitectureEnabled()) {
|
|
25
|
+
apply plugin: "com.facebook.react"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def getExtOrDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Exify_" + name]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrIntegerDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Exify_" + name]).toInteger()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def supportsNamespace() {
|
|
37
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
38
|
+
def major = parsed[0].toInteger()
|
|
39
|
+
def minor = parsed[1].toInteger()
|
|
40
|
+
|
|
41
|
+
// Namespace support was added in 7.3.0
|
|
42
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
android {
|
|
46
|
+
if (supportsNamespace()) {
|
|
47
|
+
namespace "com.exify"
|
|
48
|
+
|
|
49
|
+
sourceSets {
|
|
50
|
+
main {
|
|
51
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
57
|
+
|
|
58
|
+
defaultConfig {
|
|
59
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
60
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
buildTypes {
|
|
65
|
+
release {
|
|
66
|
+
minifyEnabled false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
lintOptions {
|
|
71
|
+
disable "GradleCompatible"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
compileOptions {
|
|
75
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
76
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
repositories {
|
|
81
|
+
mavenCentral()
|
|
82
|
+
google()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
86
|
+
|
|
87
|
+
dependencies {
|
|
88
|
+
// For < 0.71, this will be from the local maven repo
|
|
89
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
90
|
+
//noinspection GradleDynamicVersion
|
|
91
|
+
implementation "com.facebook.react:react-native:+"
|
|
92
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
93
|
+
implementation 'androidx.exifinterface:exifinterface:1.3.7'
|
|
94
|
+
}
|
|
95
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
package com.exify
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.net.Uri
|
|
5
|
+
import androidx.exifinterface.media.ExifInterface
|
|
6
|
+
import com.exify.ExifyUtils.formatTags
|
|
7
|
+
import com.facebook.react.bridge.Arguments
|
|
8
|
+
import com.facebook.react.bridge.Promise
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
11
|
+
import com.facebook.react.bridge.ReactMethod
|
|
12
|
+
import com.facebook.react.bridge.ReadableMap
|
|
13
|
+
import com.facebook.react.bridge.ReadableType
|
|
14
|
+
import java.io.IOException
|
|
15
|
+
|
|
16
|
+
private const val ERROR_TAG = "E_EXIFY_ERROR"
|
|
17
|
+
|
|
18
|
+
class ExifyModule(reactContext: ReactApplicationContext) :
|
|
19
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
20
|
+
|
|
21
|
+
private val context: Context = reactContext
|
|
22
|
+
|
|
23
|
+
override fun getName(): String {
|
|
24
|
+
return NAME
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ReactMethod
|
|
28
|
+
fun readAsync(uri: String, promise: Promise) {
|
|
29
|
+
val photoUri = Uri.parse(uri)
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
context.contentResolver.openInputStream(photoUri)?.use {
|
|
33
|
+
val tags = formatTags(ExifInterface(it))
|
|
34
|
+
it.close()
|
|
35
|
+
|
|
36
|
+
promise.resolve(tags)
|
|
37
|
+
}
|
|
38
|
+
} catch (e: Exception) {
|
|
39
|
+
promise.resolve(null)
|
|
40
|
+
e.printStackTrace()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
@Throws(IOException::class)
|
|
46
|
+
fun writeAsync(uri: String, tags: ReadableMap, promise: Promise) {
|
|
47
|
+
val photoUri = Uri.parse(uri)
|
|
48
|
+
val params = Arguments.createMap()
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
context.contentResolver.openFileDescriptor(photoUri, "rw", null)?.use { parcelDescriptor ->
|
|
52
|
+
val exif = ExifInterface(parcelDescriptor.fileDescriptor)
|
|
53
|
+
|
|
54
|
+
for ((_, tag) in EXIFY_TAGS) {
|
|
55
|
+
if (!tags.hasKey(tag)) continue
|
|
56
|
+
|
|
57
|
+
val type = tags.getType(tag)
|
|
58
|
+
|
|
59
|
+
when (type) {
|
|
60
|
+
ReadableType.Boolean -> exif.setAttribute(tag, tags.getBoolean(tag).toString())
|
|
61
|
+
ReadableType.Number -> exif.setAttribute(tag, tags.getDouble(tag).toBigDecimal().toPlainString())
|
|
62
|
+
ReadableType.String -> exif.setAttribute(tag, tags.getString(tag))
|
|
63
|
+
ReadableType.Array -> exif.setAttribute(tag, tags.getArray(tag).toString())
|
|
64
|
+
else -> exif.setAttribute(tag, tags.getString(tag))
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
tags.hasKey(ExifInterface.TAG_GPS_LATITUDE) &&
|
|
70
|
+
tags.hasKey(ExifInterface.TAG_GPS_LONGITUDE)
|
|
71
|
+
) {
|
|
72
|
+
exif.setLatLong(
|
|
73
|
+
tags.getDouble(ExifInterface.TAG_GPS_LATITUDE),
|
|
74
|
+
tags.getDouble(ExifInterface.TAG_GPS_LONGITUDE)
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (tags.hasKey(ExifInterface.TAG_GPS_ALTITUDE)) {
|
|
79
|
+
exif.setAltitude(tags.getDouble(ExifInterface.TAG_GPS_ALTITUDE))
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
params.putString("uri", uri)
|
|
83
|
+
params.putString("assetId", null)
|
|
84
|
+
params.putMap("tags", formatTags(exif))
|
|
85
|
+
|
|
86
|
+
exif.saveAttributes()
|
|
87
|
+
promise.resolve(params)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
} catch (e: Exception) {
|
|
91
|
+
promise.reject(ERROR_TAG, e.message, e)
|
|
92
|
+
e.printStackTrace()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
companion object {
|
|
97
|
+
const val NAME = "Exify"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.exify
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ExifyPackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(ExifyModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
package com.exify
|
|
2
|
+
import androidx.exifinterface.media.ExifInterface
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Supported Exif Tags
|
|
6
|
+
* Note: Latitude, Longitude and Altitude tags are updated separately
|
|
7
|
+
*/
|
|
8
|
+
val EXIFY_TAGS = arrayOf(
|
|
9
|
+
arrayOf("string", ExifInterface.TAG_ARTIST),
|
|
10
|
+
arrayOf("int", ExifInterface.TAG_BITS_PER_SAMPLE),
|
|
11
|
+
arrayOf("int", ExifInterface.TAG_COMPRESSION),
|
|
12
|
+
arrayOf("string", ExifInterface.TAG_COPYRIGHT),
|
|
13
|
+
arrayOf("string", ExifInterface.TAG_DATETIME),
|
|
14
|
+
arrayOf("string", ExifInterface.TAG_IMAGE_DESCRIPTION),
|
|
15
|
+
arrayOf("int", ExifInterface.TAG_IMAGE_LENGTH),
|
|
16
|
+
arrayOf("int", ExifInterface.TAG_IMAGE_WIDTH),
|
|
17
|
+
arrayOf("int", ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT),
|
|
18
|
+
arrayOf("int", ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH),
|
|
19
|
+
arrayOf("string", ExifInterface.TAG_MAKE),
|
|
20
|
+
arrayOf("string", ExifInterface.TAG_MODEL),
|
|
21
|
+
arrayOf("int", ExifInterface.TAG_ORIENTATION),
|
|
22
|
+
arrayOf("int", ExifInterface.TAG_PHOTOMETRIC_INTERPRETATION),
|
|
23
|
+
arrayOf("int", ExifInterface.TAG_PLANAR_CONFIGURATION),
|
|
24
|
+
arrayOf("double", ExifInterface.TAG_PRIMARY_CHROMATICITIES),
|
|
25
|
+
arrayOf("double", ExifInterface.TAG_REFERENCE_BLACK_WHITE),
|
|
26
|
+
arrayOf("int", ExifInterface.TAG_RESOLUTION_UNIT),
|
|
27
|
+
arrayOf("int", ExifInterface.TAG_ROWS_PER_STRIP),
|
|
28
|
+
arrayOf("int", ExifInterface.TAG_SAMPLES_PER_PIXEL),
|
|
29
|
+
arrayOf("string", ExifInterface.TAG_SOFTWARE),
|
|
30
|
+
arrayOf("int", ExifInterface.TAG_STRIP_BYTE_COUNTS),
|
|
31
|
+
arrayOf("int", ExifInterface.TAG_STRIP_OFFSETS),
|
|
32
|
+
arrayOf("int", ExifInterface.TAG_TRANSFER_FUNCTION),
|
|
33
|
+
arrayOf("double", ExifInterface.TAG_WHITE_POINT),
|
|
34
|
+
arrayOf("double", ExifInterface.TAG_X_RESOLUTION),
|
|
35
|
+
arrayOf("double", ExifInterface.TAG_Y_CB_CR_COEFFICIENTS),
|
|
36
|
+
arrayOf("int", ExifInterface.TAG_Y_CB_CR_POSITIONING),
|
|
37
|
+
arrayOf("int", ExifInterface.TAG_Y_CB_CR_SUB_SAMPLING),
|
|
38
|
+
arrayOf("double", ExifInterface.TAG_Y_RESOLUTION),
|
|
39
|
+
arrayOf("double", ExifInterface.TAG_APERTURE_VALUE),
|
|
40
|
+
arrayOf("double", ExifInterface.TAG_BRIGHTNESS_VALUE),
|
|
41
|
+
arrayOf("string", ExifInterface.TAG_CFA_PATTERN),
|
|
42
|
+
arrayOf("int", ExifInterface.TAG_COLOR_SPACE),
|
|
43
|
+
arrayOf("array", ExifInterface.TAG_COMPONENTS_CONFIGURATION),
|
|
44
|
+
arrayOf("double", ExifInterface.TAG_COMPRESSED_BITS_PER_PIXEL),
|
|
45
|
+
arrayOf("int", ExifInterface.TAG_CONTRAST),
|
|
46
|
+
arrayOf("int", ExifInterface.TAG_CUSTOM_RENDERED),
|
|
47
|
+
arrayOf("string", ExifInterface.TAG_DATETIME_DIGITIZED),
|
|
48
|
+
arrayOf("string", ExifInterface.TAG_DATETIME_ORIGINAL),
|
|
49
|
+
arrayOf("string", ExifInterface.TAG_DEVICE_SETTING_DESCRIPTION),
|
|
50
|
+
arrayOf("double", ExifInterface.TAG_DIGITAL_ZOOM_RATIO),
|
|
51
|
+
arrayOf("array", ExifInterface.TAG_EXIF_VERSION),
|
|
52
|
+
arrayOf("double", ExifInterface.TAG_EXPOSURE_BIAS_VALUE),
|
|
53
|
+
arrayOf("double", ExifInterface.TAG_EXPOSURE_INDEX),
|
|
54
|
+
arrayOf("int", ExifInterface.TAG_EXPOSURE_MODE),
|
|
55
|
+
arrayOf("int", ExifInterface.TAG_EXPOSURE_PROGRAM),
|
|
56
|
+
arrayOf("double", ExifInterface.TAG_EXPOSURE_TIME),
|
|
57
|
+
arrayOf("double", ExifInterface.TAG_F_NUMBER),
|
|
58
|
+
arrayOf("string", ExifInterface.TAG_FILE_SOURCE),
|
|
59
|
+
arrayOf("int", ExifInterface.TAG_FLASH),
|
|
60
|
+
arrayOf("double", ExifInterface.TAG_FLASH_ENERGY),
|
|
61
|
+
arrayOf("array", ExifInterface.TAG_FLASHPIX_VERSION),
|
|
62
|
+
arrayOf("double", ExifInterface.TAG_FOCAL_LENGTH),
|
|
63
|
+
arrayOf("string", ExifInterface.TAG_LENS_MAKE),
|
|
64
|
+
arrayOf("string", ExifInterface.TAG_LENS_MODEL),
|
|
65
|
+
arrayOf("array", ExifInterface.TAG_LENS_SPECIFICATION),
|
|
66
|
+
arrayOf("int", ExifInterface.TAG_FOCAL_LENGTH_IN_35MM_FILM),
|
|
67
|
+
arrayOf("int", ExifInterface.TAG_FOCAL_PLANE_RESOLUTION_UNIT),
|
|
68
|
+
arrayOf("double", ExifInterface.TAG_FOCAL_PLANE_X_RESOLUTION),
|
|
69
|
+
arrayOf("double", ExifInterface.TAG_FOCAL_PLANE_Y_RESOLUTION),
|
|
70
|
+
arrayOf("int", ExifInterface.TAG_GAIN_CONTROL),
|
|
71
|
+
arrayOf("array", ExifInterface.TAG_ISO_SPEED_RATINGS),
|
|
72
|
+
arrayOf("string", ExifInterface.TAG_IMAGE_UNIQUE_ID),
|
|
73
|
+
arrayOf("int", ExifInterface.TAG_LIGHT_SOURCE),
|
|
74
|
+
arrayOf("string", ExifInterface.TAG_MAKER_NOTE),
|
|
75
|
+
arrayOf("double", ExifInterface.TAG_MAX_APERTURE_VALUE),
|
|
76
|
+
arrayOf("int", ExifInterface.TAG_METERING_MODE),
|
|
77
|
+
arrayOf("int", ExifInterface.TAG_NEW_SUBFILE_TYPE),
|
|
78
|
+
arrayOf("string", ExifInterface.TAG_OECF),
|
|
79
|
+
arrayOf("int", ExifInterface.TAG_PIXEL_X_DIMENSION),
|
|
80
|
+
arrayOf("int", ExifInterface.TAG_PIXEL_Y_DIMENSION),
|
|
81
|
+
arrayOf("string", ExifInterface.TAG_RELATED_SOUND_FILE),
|
|
82
|
+
arrayOf("int", ExifInterface.TAG_SATURATION),
|
|
83
|
+
arrayOf("int", ExifInterface.TAG_SCENE_CAPTURE_TYPE),
|
|
84
|
+
arrayOf("string", ExifInterface.TAG_SCENE_TYPE),
|
|
85
|
+
arrayOf("int", ExifInterface.TAG_SENSING_METHOD),
|
|
86
|
+
arrayOf("int", ExifInterface.TAG_SHARPNESS),
|
|
87
|
+
arrayOf("double", ExifInterface.TAG_SHUTTER_SPEED_VALUE),
|
|
88
|
+
arrayOf("string", ExifInterface.TAG_SPATIAL_FREQUENCY_RESPONSE),
|
|
89
|
+
arrayOf("string", ExifInterface.TAG_SPECTRAL_SENSITIVITY),
|
|
90
|
+
arrayOf("int", ExifInterface.TAG_SUBFILE_TYPE),
|
|
91
|
+
arrayOf("string", ExifInterface.TAG_SUBSEC_TIME),
|
|
92
|
+
arrayOf("string", ExifInterface.TAG_SUBSEC_TIME_DIGITIZED),
|
|
93
|
+
arrayOf("string", ExifInterface.TAG_SUBSEC_TIME_ORIGINAL),
|
|
94
|
+
arrayOf("array", ExifInterface.TAG_SUBJECT_AREA),
|
|
95
|
+
arrayOf("double", ExifInterface.TAG_SUBJECT_DISTANCE),
|
|
96
|
+
arrayOf("int", ExifInterface.TAG_SUBJECT_DISTANCE_RANGE),
|
|
97
|
+
arrayOf("int", ExifInterface.TAG_SUBJECT_LOCATION),
|
|
98
|
+
arrayOf("string", ExifInterface.TAG_USER_COMMENT),
|
|
99
|
+
arrayOf("int", ExifInterface.TAG_WHITE_BALANCE),
|
|
100
|
+
arrayOf("int", ExifInterface.TAG_GPS_ALTITUDE_REF),
|
|
101
|
+
arrayOf("string", ExifInterface.TAG_GPS_AREA_INFORMATION),
|
|
102
|
+
arrayOf("double", ExifInterface.TAG_GPS_DOP),
|
|
103
|
+
arrayOf("string", ExifInterface.TAG_GPS_DATESTAMP),
|
|
104
|
+
arrayOf("double", ExifInterface.TAG_GPS_DEST_BEARING),
|
|
105
|
+
arrayOf("string", ExifInterface.TAG_GPS_DEST_BEARING_REF),
|
|
106
|
+
arrayOf("double", ExifInterface.TAG_GPS_DEST_DISTANCE),
|
|
107
|
+
arrayOf("string", ExifInterface.TAG_GPS_DEST_DISTANCE_REF),
|
|
108
|
+
arrayOf("double", ExifInterface.TAG_GPS_DEST_LATITUDE),
|
|
109
|
+
arrayOf("string", ExifInterface.TAG_GPS_DEST_LATITUDE_REF),
|
|
110
|
+
arrayOf("double", ExifInterface.TAG_GPS_DEST_LONGITUDE),
|
|
111
|
+
arrayOf("string", ExifInterface.TAG_GPS_DEST_LONGITUDE_REF),
|
|
112
|
+
arrayOf("int", ExifInterface.TAG_GPS_DIFFERENTIAL),
|
|
113
|
+
arrayOf("string", ExifInterface.TAG_GPS_H_POSITIONING_ERROR),
|
|
114
|
+
arrayOf("double", ExifInterface.TAG_GPS_IMG_DIRECTION),
|
|
115
|
+
arrayOf("string", ExifInterface.TAG_GPS_IMG_DIRECTION_REF),
|
|
116
|
+
arrayOf("string", ExifInterface.TAG_GPS_LATITUDE_REF),
|
|
117
|
+
arrayOf("string", ExifInterface.TAG_GPS_LONGITUDE_REF),
|
|
118
|
+
arrayOf("string", ExifInterface.TAG_GPS_MAP_DATUM),
|
|
119
|
+
arrayOf("string", ExifInterface.TAG_GPS_MEASURE_MODE),
|
|
120
|
+
arrayOf("string", ExifInterface.TAG_GPS_PROCESSING_METHOD),
|
|
121
|
+
arrayOf("string", ExifInterface.TAG_GPS_SATELLITES),
|
|
122
|
+
arrayOf("double", ExifInterface.TAG_GPS_SPEED),
|
|
123
|
+
arrayOf("string", ExifInterface.TAG_GPS_SPEED_REF),
|
|
124
|
+
arrayOf("string", ExifInterface.TAG_GPS_STATUS),
|
|
125
|
+
arrayOf("string", ExifInterface.TAG_GPS_TIMESTAMP),
|
|
126
|
+
arrayOf("double", ExifInterface.TAG_GPS_TRACK),
|
|
127
|
+
arrayOf("string", ExifInterface.TAG_GPS_TRACK_REF),
|
|
128
|
+
arrayOf("string", ExifInterface.TAG_GPS_VERSION_ID),
|
|
129
|
+
arrayOf("string", ExifInterface.TAG_INTEROPERABILITY_INDEX),
|
|
130
|
+
arrayOf("int", ExifInterface.TAG_THUMBNAIL_IMAGE_LENGTH),
|
|
131
|
+
arrayOf("int", ExifInterface.TAG_THUMBNAIL_IMAGE_WIDTH),
|
|
132
|
+
arrayOf("int", ExifInterface.TAG_DNG_VERSION),
|
|
133
|
+
arrayOf("int", ExifInterface.TAG_DEFAULT_CROP_SIZE),
|
|
134
|
+
arrayOf("int", ExifInterface.TAG_ORF_PREVIEW_IMAGE_START),
|
|
135
|
+
arrayOf("int", ExifInterface.TAG_ORF_PREVIEW_IMAGE_LENGTH),
|
|
136
|
+
arrayOf("int", ExifInterface.TAG_ORF_ASPECT_FRAME),
|
|
137
|
+
arrayOf("int", ExifInterface.TAG_RW2_SENSOR_BOTTOM_BORDER),
|
|
138
|
+
arrayOf("int", ExifInterface.TAG_RW2_SENSOR_LEFT_BORDER),
|
|
139
|
+
arrayOf("int", ExifInterface.TAG_RW2_SENSOR_RIGHT_BORDER),
|
|
140
|
+
arrayOf("int", ExifInterface.TAG_RW2_SENSOR_TOP_BORDER),
|
|
141
|
+
arrayOf("int", ExifInterface.TAG_RW2_ISO)
|
|
142
|
+
)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package com.exify
|
|
2
|
+
|
|
3
|
+
import androidx.exifinterface.media.ExifInterface
|
|
4
|
+
import com.facebook.react.bridge.Arguments
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import java.io.InputStream
|
|
7
|
+
|
|
8
|
+
object ExifyUtils {
|
|
9
|
+
@JvmStatic
|
|
10
|
+
fun formatTags(exif: ExifInterface): ReadableMap {
|
|
11
|
+
val tags = Arguments.createMap()
|
|
12
|
+
|
|
13
|
+
for ((type, tag) in EXIFY_TAGS) {
|
|
14
|
+
val attribute = exif.getAttribute(tag)
|
|
15
|
+
if (attribute != null && attribute != "") {
|
|
16
|
+
when (type) {
|
|
17
|
+
"string" -> tags.putString(tag, attribute)
|
|
18
|
+
"int" -> tags.putInt(tag, exif.getAttributeInt(tag, 0))
|
|
19
|
+
"double" -> tags.putDouble(tag, exif.getAttributeDouble(tag, 0.0))
|
|
20
|
+
"array" -> {
|
|
21
|
+
val array = Arguments.createArray()
|
|
22
|
+
exif.getAttributeRange(tag)?.forEach { value ->
|
|
23
|
+
array.pushDouble(value.toDouble())
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (array.size() > 0) tags.putArray(tag, array)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// GPS
|
|
33
|
+
exif.latLong?.let {
|
|
34
|
+
tags.putDouble(ExifInterface.TAG_GPS_ALTITUDE, exif.getAltitude(0.0))
|
|
35
|
+
tags.putDouble(ExifInterface.TAG_GPS_LATITUDE, it[0])
|
|
36
|
+
tags.putDouble(ExifInterface.TAG_GPS_LONGITUDE, it[1])
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return tags
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Created by Jovanni Lo (@lodev09)
|
|
4
|
+
* Copyright 2024
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <React/RCTBridgeModule.h>
|
|
11
|
+
#import <React/RCTViewManager.h>
|
package/ios/Exify.mm
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Created by Jovanni Lo (@lodev09)
|
|
4
|
+
* Copyright 2024
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <React/RCTBridgeModule.h>
|
|
11
|
+
|
|
12
|
+
@interface RCT_EXTERN_MODULE(Exify, NSObject)
|
|
13
|
+
|
|
14
|
+
RCT_EXTERN_METHOD(readAsync:(NSString*)uri
|
|
15
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
16
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
17
|
+
|
|
18
|
+
RCT_EXTERN_METHOD(writeAsync:(NSString*)uri
|
|
19
|
+
withExif:(NSDictionary*)exif
|
|
20
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
21
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
22
|
+
|
|
23
|
+
+ (BOOL)requiresMainQueueSetup
|
|
24
|
+
{
|
|
25
|
+
return NO;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@end
|