Skip to content

Commit 2a3dfe4

Browse files
fix: remove slice logic from js side
1 parent 66961eb commit 2a3dfe4

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

android/src/main/java/com/imageprocessingsdk/ImageUtils.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
import android.content.ContentResolver
12
import android.graphics.Bitmap
23
import android.graphics.BitmapFactory
34
import android.graphics.Matrix
45
import android.media.ExifInterface
5-
6+
import android.net.Uri
7+
68
object ImageUtils {
79

8-
fun getBitmap(filePath: String, isMutable: Boolean): Bitmap {
9-
val exifInterface = ExifInterface(filePath)
10+
fun getBitmap(originalfilePath: String, isMutable: Boolean): Bitmap {
11+
val uri = Uri.parse(originalfilePath)
12+
val filePath:String?
13+
val scheme = uri.scheme
14+
if (scheme != null && scheme == ContentResolver.SCHEME_CONTENT) {
15+
filePath = uri.path
16+
} else if (scheme == null || scheme == ContentResolver.SCHEME_FILE) {
17+
filePath= uri.path;
18+
} else {
19+
throw UnsupportedOperationException("Unsupported scheme: " + uri.scheme)
20+
}
21+
val exifInterface = ExifInterface(filePath!!)
1022
val orientation = exifInterface.getRotationDegrees()
1123

1224
val bmpOptions = BitmapFactory.Options()

src/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ export function isImageBlurred(
1616
return new Promise((resolve, reject) => {
1717
if (validateImageUrl(imageUrl)) {
1818
if (validateImageExtension(imageUrl)) {
19-
resolve(
20-
ImageProcessingSDK.isImageBlurred(imageUrl.slice(8), blurThreshold)
21-
);
19+
resolve(ImageProcessingSDK.isImageBlurred(imageUrl, blurThreshold));
2220
} else {
2321
reject(new Error(JSON.stringify(ERROR_CODES.ERR002)));
2422
}

0 commit comments

Comments
 (0)