react-native-image-resizer
                                
                                 react-native-image-resizer copied to clipboard
                                
                                    react-native-image-resizer copied to clipboard
                            
                            
                            
                        Bitmap.getWidth() on null object Refference
Hi,
I got this error when createResizedImage

and my code:
ImageResizer.createResizedImage(source.uri, 800, 600, 'JPEG', 80) {....}
where source.uri is from ImagePicker.
Thanks
I am running into the same issue.
I'm getting the problem too, but I assume your source.uri is wrong as well as mine. Will test if it's null, because I'm inputing a base64 string as the image.
same here, some time image resize successfully, so not sure what went wrong

I got same issue.It's work on iOS,but not work on Android.
"dependencies": { "base-64": "^0.1.0", "react": "15.3.2", "react-native": "0.36.0", "react-native-device-info": "^0.9.6", "react-native-image-picker": "^0.22.12", "realm": "^0.14.3" },

Here is the log:
11-01 15:34:51.516 27082-27099/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.engineertools_rn, PID: 27082 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at fr.bamlab.rnimageresizer.ImageResizer.rotateImage(ImageResizer.java:63) at fr.bamlab.rnimageresizer.ImageResizer.createResizedImage(ImageResizer.java:231) at fr.bamlab.rnimageresizer.ImageResizerModule.createResizedImageWithExceptions(ImageResizerModule.java:49) at fr.bamlab.rnimageresizer.ImageResizerModule.createResizedImage(ImageResizerModule.java:37) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318) at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) at android.os.Looper.loop(Looper.java:148) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) at java.lang.Thread.run(Thread.java:818)
[Android]
It seems happened on Bitmap scaledImage = ImageResizer.resizeImage(sourceImage, newWidth, newHeight); return null,and then call rotatedImage = ImageResizer.rotateImage(scaledImage, rotation);
I think it happens when imagePath is a url,not a file path(sourceImage = BitmapFactory.decodeFile(imagePath, options); )
maybe..?!?
(And it won't happen on iOS)
[http://stackoverflow.com/questions/8992964/android-load-from-url-to-bitmap](a way to load image from url.)
It not work on base64?
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: data:image/jpeg;base64,/9j/4TaJRXhpZgAATU0AKgAAAAg ...
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
                                                       at fr.bamlab.rnimageresizer.ImageResizer.rotateImage(ImageResizer.java:63)
                                                       at fr.bamlab.rnimageresizer.ImageResizer.createResizedImage(ImageResizer.java:231)
                                                       at fr.bamlab.rnimageresizer.ImageResizerModule.createResizedImageWithExceptions(ImageResizerModule.java:49)
Hey guys, thanks for reporting this issue! It would be awesome if you could make a sample project (use this one: https://github.com/bamlab/react-native-image-resizer/tree/master/example) and tell what to do next (for example: run react-native run-android, click there and boom!) to reproduce the bug. It would speed up the bug hunt a lot for me!
I'll be happy to fix the issue then! :D
cc @dyguests @leoabacade @Monte9 @mafelix @feriyalsusanto
@4ian Aleady fixed.The newest code can resize a base64 uri,
ImageResizer.loadBitmapFromBase64(imagePath);
But the published lib on npm("react-native-image-resizer": "0.0.11") can not resize a base64 uri.
Waiting for the new publish version.
(anyway to add something like loadBitmapFromUrl(???))
Thanks.....
:)
Oops I totally forgot that latest changes were not published on npm. That's fixed with version 0.0.12 :) I'll close the issue if someone can confirm that it's working with this new version.
Not tested with base64, but still happening for URIs on some devices, but its happening randomly, sometimes it works 10x in row and then crash
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed. Thank you for your contributions.