Comments (19)
I created a patch that fixes the issue, I am not sure why decodeRegion does not give out mime type, but it well could be an issue with the underlying vendor implementation, and am not sure if decodeRegion is guaranteed to fill outMimeType always.
If mime type is null, we fall back to the normal way of reading the mime type, so this patch is quite safe and will affect only people who have problems.
This patch was done for 2.3.0 version for @react-native-community/image-editor, using patch-package.
diff --git a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java
index c053ab4..f40883c 100644
--- a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java
+++ b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java
@@ -255,6 +255,23 @@ public class ImageEditorModule extends ReactContextBaseJavaModule {
return stream;
}
+ private String getMimeType() throws IOException {
+
+ BitmapFactory.Options outOptions = new BitmapFactory.Options();
+ outOptions.inJustDecodeBounds = true;
+
+ InputStream inputStream = openBitmapInputStream();
+
+ try {
+ BitmapFactory.decodeStream(inputStream, null, outOptions);
+ return outOptions.outMimeType;
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ }
+
@Override
protected void doInBackgroundGuarded(Void... params) {
try {
@@ -272,7 +289,11 @@ public class ImageEditorModule extends ReactContextBaseJavaModule {
String mimeType = outOptions.outMimeType;
if (mimeType == null || mimeType.isEmpty()) {
- throw new IOException("Could not determine MIME type");
+ mimeType = getMimeType();
+
+ if (mimeType == null || mimeType.isEmpty()) {
+ throw new IOException("Could not determine MIME type");
+ }
}
File tempFile = createTempFile(mContext, mimeType);
from react-native-image-editor.
Any update on this?
from react-native-image-editor.
I am also facing this error - are there any plans to solve this one?
from react-native-image-editor.
I'm also seeing this issue, and having several users with the Samsung Galaxy A41 on Android 10 struggling with this.
from react-native-image-editor.
We also see these errors in our error loggings. Can we expect a fix any time soon?
from react-native-image-editor.
Any suggestions?
from react-native-image-editor.
Hoping for a fix soon!
This is happening on the Redmi Note 8 as well, running Android 10.
(https://user-images.githubusercontent.com/2827275/101670290-e17d2c80-3a4a-11eb-9757-02e56ff94322.jpg)
from react-native-image-editor.
Also happening with several users using brand new Samsung Core A01, Android 10 (Go Edition)
from react-native-image-editor.
Bump. Any updates?
from react-native-image-editor.
Same error here, affecting A31 Android10
from react-native-image-editor.
from react-native-image-editor.
@ChrisEelmaa Did you make a PR for the patch? It can be usefull
from react-native-image-editor.
Any plans to marge @ChrisEelmaa suggestion? it seems to work well.
from react-native-image-editor.
from react-native-image-editor.
how can i install that patch? i don't know, can you guide me?
I created a patch that fixes the issue, I am not sure why decodeRegion does not give out mime type, but it well could be an issue with the underlying vendor implementation, and am not sure if decodeRegion is guaranteed to fill outMimeType always.
If mime type is null, we fall back to the normal way of reading the mime type, so this patch is quite safe and will affect only people who have problems.
This patch was done for 2.3.0 version for @react-native-community/image-editor, using patch-package.
diff --git a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java index c053ab4..f40883c 100644 --- a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java +++ b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java @@ -255,6 +255,23 @@ public class ImageEditorModule extends ReactContextBaseJavaModule { return stream; } + private String getMimeType() throws IOException { + + BitmapFactory.Options outOptions = new BitmapFactory.Options(); + outOptions.inJustDecodeBounds = true; + + InputStream inputStream = openBitmapInputStream(); + + try { + BitmapFactory.decodeStream(inputStream, null, outOptions); + return outOptions.outMimeType; + } finally { + if (inputStream != null) { + inputStream.close(); + } + } + } + @Override protected void doInBackgroundGuarded(Void... params) { try { @@ -272,7 +289,11 @@ public class ImageEditorModule extends ReactContextBaseJavaModule { String mimeType = outOptions.outMimeType; if (mimeType == null || mimeType.isEmpty()) { - throw new IOException("Could not determine MIME type"); + mimeType = getMimeType(); + + if (mimeType == null || mimeType.isEmpty()) { + throw new IOException("Could not determine MIME type"); + } } File tempFile = createTempFile(mContext, mimeType);
from react-native-image-editor.
how can i install that patch? i don't know, can you guide me?
@ducanh261101a you can try https://www.npmjs.com/package/patch-package
from react-native-image-editor.
I created a patch that fixes the issue, I am not sure why decodeRegion does not give out mime type, but it well could be an issue with the underlying vendor implementation, and am not sure if decodeRegion is guaranteed to fill outMimeType always.
If mime type is null, we fall back to the normal way of reading the mime type, so this patch is quite safe and will affect only people who have problems.
This patch was done for 2.3.0 version for @react-native-community/image-editor, using patch-package.
diff --git a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java index c053ab4..f40883c 100644 --- a/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java +++ b/node_modules/@react-native-community/image-editor/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java @@ -255,6 +255,23 @@ public class ImageEditorModule extends ReactContextBaseJavaModule { return stream; } + private String getMimeType() throws IOException { + + BitmapFactory.Options outOptions = new BitmapFactory.Options(); + outOptions.inJustDecodeBounds = true; + + InputStream inputStream = openBitmapInputStream(); + + try { + BitmapFactory.decodeStream(inputStream, null, outOptions); + return outOptions.outMimeType; + } finally { + if (inputStream != null) { + inputStream.close(); + } + } + } + @Override protected void doInBackgroundGuarded(Void... params) { try { @@ -272,7 +289,11 @@ public class ImageEditorModule extends ReactContextBaseJavaModule { String mimeType = outOptions.outMimeType; if (mimeType == null || mimeType.isEmpty()) { - throw new IOException("Could not determine MIME type"); + mimeType = getMimeType(); + + if (mimeType == null || mimeType.isEmpty()) { + throw new IOException("Could not determine MIME type"); + } } File tempFile = createTempFile(mContext, mimeType);
Thanks it is working
from react-native-image-editor.
any update on this issue?
from react-native-image-editor.
Fixed in 4.0.0
from react-native-image-editor.
Related Issues (20)
- Please publish the latest build from Github, onto npm! HOT 2
- iOS compilation failures after Expo SDK 44/RN 0.64.3 upgrade HOT 3
- Why i can't install this library? HOT 6
- I am trying to use Image editor library of react native but whenever I install this library I am unable to make my build to start my app locally can you help me ?? HOT 2
- Inconsistent handling of EXIF between Android and iOS HOT 5
- run-ios fail HOT 9
- Not compatible with react 18 HOT 4
- Is this discontinued? HOT 1
- remove jcenter for android build.gradle HOT 1
- call to undeclared function 'RCTTransformFromTargetRect'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] CGAffineTransform transform = RCTTransformFromTargetRect(image.size, targetRect); HOT 1
- [4.x] Release plan HOT 1
- Prompt error that ' Error: Requiring module "src/component/index.tsx", which threw an exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNCImageEditor' could not be found. Verify that a module by this name is registered in the native binary' in IOS
- getting error in some android devices when cropping the images HOT 4
- Prompt error that ' Error: Requiring module "src/component/index.tsx", which threw an exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNCImageEditor' could not be found. Verify that a module by this name is registered in the native binary'only happen in IOS HOT 4
- Incorrect scaling on Android HOT 6
- Offset not correct in some Android devices HOT 10
- Library support for New Architecture + Bridgeless HOT 2
- Prompt error that ' Error: Requiring module "src/component/index.tsx", which threw an exception: Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNCImageEditor' could not be found. Verify that a module by this name is registered in the native binary'only happen in IOS HOT 3
- not working with react-native-image-crop-picker, pickedImage.path or pickedImage.sourceURL
- install error usning npm@7 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-image-editor.