Comments (5)
@MarioUnlam thanks for the information on the library and great that you have a working solution for your problem. We trying to avoid Expo since this creates some big dependencies and gave us some issues with the most recent react native version in the past. For anyone else having this problem, I think I found a solution:
Read the rotation of the image with react-native-image-size in react native:
const {width, height, rotation} = await ImageSize.getSize(uri);
If there is a rotation, flip the passed height / width and offset.x/offset.y to ImageEditor
offset = { x: offset.x, y: offset.y };
size = { height: size.width, width: size.height }
const cropData = { offset, size, displaySize: size };
const croppedImageUri = await ImageEditor.cropImage(source.uri, cropData);
from react-native-image-editor.
We ran into this same issue, thank you for your details. What library are you using to resize and remove EXIF Data? I don't think it's consistent on each platform, because our Samsung S22 (Android 12) shows this problem whereas a POCO M3 (Android 11) works with no issues. I tried to rotate the image in the Java Source using the given EXIF information, it worked, but whenever I needed to zoom in on the image it was giving me the wrong area of the image.. Here is the code I have used to get the orientation..
public int getOrientationDegree() {
try {
InputStream inputStream = openBitmapInputStream();
@SuppressLint("NewApi") final ExifInterface exifInterface = new ExifInterface(inputStream);
final int attributeInt = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
switch (attributeInt) {
case ExifInterface.ORIENTATION_ROTATE_90:
return 90;
case ExifInterface.ORIENTATION_ROTATE_180:
return 180;
case ExifInterface.ORIENTATION_ROTATE_270:
return 270;
}
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
public static Bitmap rotateBitmap(Bitmap bitmap, int degree) {
if (degree == 0 || bitmap == null) {
return bitmap;
}
final Matrix matrix = new Matrix();
matrix.setRotate(degree, bitmap.getWidth() / 2, bitmap.getHeight() / 2);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
from react-native-image-editor.
@joshke Some people suggested using react-native-image-resizer to create a copy of the image, without the EXIF, but in my tests this pretty much doubled the processing time of the image, which is barely acceptable. If this behavior is not consistent on each platform, that's a big problem. There's no way to tell if the image will be cropped correctly, in both cases the exif data is the same, but the library handles it differently.
from react-native-image-editor.
@joshke I ended up switching to expo-image-manipulator, which allows me to resize, crop, rotate and flip images in a single function call, and it seems to take into account the EXIF data, even in my old Android phone (which had problems with react-native-image-editor). If your project is react-native-cli, with a few steps you can turn it into a "bare expo" project, allowing you to use expo libraries without changing the way you compile. I also had to add android:largeHeap="true" to my AndroidManifest.xml for it to work, as explained here: bamlab/react-native-image-resizer#235. Hope it helps.
from react-native-image-editor.
It should be fixed in the 4.0.0
release.
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
- 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.