camera.getPicture - base 64 option & performance question

21 views
Skip to first unread message

gkatz

unread,
Apr 19, 2016, 5:47:52 AM4/19/16
to phonegap
Hi all;
there is a specific warning about the performance of base64 encoding when using getPicture with the base 64 option. here is whats written in the docs:
"Encoding such images using Base64 has caused memory issues on many newer devices. Therefore, using FILE_URI as the 'Camera.destinationType' is highly recommended."
assuming I need to send a picture that resides in the phone's gallery to a remote server, what will then my best option be? I mean, in order to send a picture I assume need to load the image and send it to the remote server, so isn't base64 as good as any other option (using gile uri I still have to load the complete image and send it)?
thanks for your help!

jcesarmobile

unread,
Apr 19, 2016, 10:44:09 AM4/19/16
to phonegap
When you use base64, the java part of the plugin have to pass the base64 string from java to javascript
When you use file_uri and file-transfer plugin to upload, the java part read the file from the url and uploads it, so you avoid passing it from java to javascript.

gkatz

unread,
Apr 20, 2016, 3:42:05 AM4/20/16
to phonegap
@jcesarmobile thanks for your answer
I am developing a chat app, it is based on web sockets. I would still like to base64 the uploaded images. whats a good way to tackle this? lets assume I want to transcode the picture from the phone's gallery to something that will garantuee the picture is small in size (for example limit the image size to 1M).
are there phonegap APIs to support such a behavior?
thanks

jcesarmobile

unread,
Apr 20, 2016, 8:37:44 AM4/20/16
to phonegap
The camera plugin allows you to choose the image size in pixels (keeping aspect ratio), not in disk space size, but you can try a few resolutions until you find the one that suits your needs
Reply all
Reply to author
Forward
0 new messages