wymsee / cordova-imagePicker

Cordova Plugin For Multiple Image Selection
MIT License
407 stars 858 forks source link

Output type option - File URI or Base64 Encoded String #65

Open rabeyta opened 9 years ago

rabeyta commented 9 years ago

I added an outputType parameter to the input options that will dictate whether an array of File URIs or Base64 encoded strings are returned from the image picker.

arvindr21 commented 9 years ago

+1

lamson-dev commented 9 years ago

I just tried this pull request. It works great on iOS emulator, but base64 output type does not work on my Android device some how. Could someone please double check?

rabeyta commented 9 years ago

@lamson Do you have any error messages or logs? I have verified this PR with my ionic app. The same JS code (expecting base64 strings) works in both iOS simulator (8.3) and the Android emulator (4.4.2) without any code changes. If you have any specific steps or debug messages to share I would appreciate them. They would help in troubleshooting your issue. Thanks!

lamson-dev commented 8 years ago

@rabeyta I tried adb logcat and found this error "FAILED BINDER TRANSACTION !!!" I ran it on my Nexus 5, after selecting photos, clicking Ok doesn't close the image picker and gets stuck there some how. I found this thread on SO http://stackoverflow.com/questions/3528735/failed-binder-transaction

Here is my cordova-image-picker options: options = { maximumImagesCount: 10, width: 1000, height: 1000, };

I tried to reduce width/height to 500, and suddenly it works if 1 image is selected. More than 1 image selected would crash my app some how. Changing width/height to 200 let me select ~5-6 images, then my app crashes if more images are selected

Do you have any ideas?

rabeyta commented 8 years ago

@lamson Sorry for the delay. With the options you have selected, you are not actually using the Base64Encoding that this pull request adds. You are using the base plugin. Adding outputType: 1 to your options would have the files returned as base64 Encoded strings.

When i use this plugin in my application, i do not set width / heights and I usually limit it to around 5 images. I can try more later today or tomorrow and see the behavior. I am then resizing the output myself to one of two different sizes based on the needs and flow in my application (thumbnail / reduced image or both).

The problem you are having sounds like it is in the underlining plugin. I will try to test some more and get back to you. I usually am testing on iOS though as that is my primary target at this time.

lamson-dev commented 8 years ago

@rabeyta Sorry I forgot to include the outputType: 1 param to the comment. I actually had that added in my code. Again, it's an Android issue, it works great on iOS! Thanks for adding this PR and looking into the problems!

rabeyta commented 8 years ago

@lamson After doing some research and testing, I was able to validate the behavior you are seeing with the 'FAILED BINDER TRANSACTION'. I never ran into this as I am only focusing on iOS and limiting the number of photos selected at a time.

This post on SO (2011) and many others mention a 1MB bundle limit. When you exceed the limit then you are shown the 'failed binder transaction' error. http://stackoverflow.com/questions/7888890/failed-binder-transaction-on-widget-update

The reason we hit this limit is the Base64Encoded images combined are exceeding the limit. The actual resized images are being returned and not a string with the path to them. When you select the default outputType, only the file paths are returned which shouldn't exceed this limit.

candelibas commented 7 years ago

Any progress?