react-native-capture-studio 0.1.0 → 0.1.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.
|
@@ -25,7 +25,4 @@ target_link_libraries(
|
|
|
25
25
|
reactnative
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
if(COMMAND target_compile_reactnative_options)
|
|
30
|
-
target_compile_reactnative_options(react_codegen_RNCaptureStudioSpec PRIVATE)
|
|
31
|
-
endif()
|
|
28
|
+
target_compile_reactnative_options(react_codegen_RNCaptureStudioSpec PRIVATE)
|
|
@@ -87,6 +87,17 @@ object ImageProcessor {
|
|
|
87
87
|
useJpeg = compressJpeg
|
|
88
88
|
)
|
|
89
89
|
|
|
90
|
+
// 5. Reset EXIF orientation since pixels are already rotated
|
|
91
|
+
if (orientation != ExifInterface.ORIENTATION_NORMAL &&
|
|
92
|
+
orientation != ExifInterface.ORIENTATION_UNDEFINED) {
|
|
93
|
+
val newExif = ExifInterface(imagePath)
|
|
94
|
+
newExif.setAttribute(
|
|
95
|
+
ExifInterface.TAG_ORIENTATION,
|
|
96
|
+
ExifInterface.ORIENTATION_NORMAL.toString()
|
|
97
|
+
)
|
|
98
|
+
newExif.saveAttributes()
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
watermarkedBitmap.recycle()
|
|
91
102
|
|
|
92
103
|
Log.d(TAG, "Successfully processed: $imagePath")
|
|
@@ -94,18 +105,29 @@ object ImageProcessor {
|
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
/**
|
|
97
|
-
* Rotate bitmap based on EXIF orientation.
|
|
108
|
+
* Rotate and/or flip bitmap based on EXIF orientation.
|
|
109
|
+
* Handles all 8 EXIF orientation cases including mirrored variants
|
|
110
|
+
* produced by front-facing (selfie) cameras.
|
|
98
111
|
*/
|
|
99
112
|
private fun rotateBitmapIfNeeded(bitmap: Bitmap, orientation: Int): Bitmap {
|
|
100
|
-
val
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ExifInterface.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
val matrix = Matrix()
|
|
114
|
+
|
|
115
|
+
when (orientation) {
|
|
116
|
+
ExifInterface.ORIENTATION_NORMAL -> return bitmap
|
|
117
|
+
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.postScale(-1f, 1f)
|
|
118
|
+
ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f)
|
|
119
|
+
ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.postScale(1f, -1f)
|
|
120
|
+
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
|
121
|
+
matrix.postRotate(90f)
|
|
122
|
+
matrix.postScale(-1f, 1f)
|
|
123
|
+
}
|
|
124
|
+
ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f)
|
|
125
|
+
ExifInterface.ORIENTATION_TRANSVERSE -> {
|
|
126
|
+
matrix.postRotate(-90f)
|
|
127
|
+
matrix.postScale(-1f, 1f)
|
|
128
|
+
}
|
|
129
|
+
ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f)
|
|
130
|
+
else -> return bitmap
|
|
109
131
|
}
|
|
110
132
|
|
|
111
133
|
return Bitmap.createBitmap(
|
|
@@ -16,7 +16,7 @@ let package = Package(
|
|
|
16
16
|
targets: ["ReactAppDependencyProvider"]),
|
|
17
17
|
],
|
|
18
18
|
dependencies: [
|
|
19
|
-
.package(name: "React", path: "
|
|
19
|
+
.package(name: "React", path: "../../../../../../node_modules/react-native")
|
|
20
20
|
],
|
|
21
21
|
targets: [
|
|
22
22
|
// Targets are the basic building blocks of a package, defining a module or a test suite.
|
package/package.json
CHANGED