Repository: cordova-plugin-camera Updated Branches: refs/heads/master 76c129c95 -> 826aca352
CB-10756: Adding sterner warnings about DATA_URL This closes #193 Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/826aca35 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/826aca35 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/826aca35 Branch: refs/heads/master Commit: 826aca3524be7ffd98587b7eed297101dbc17903 Parents: 76c129c Author: Richard Knoll <richard.b.kn...@gmail.com> Authored: Thu Mar 10 11:55:31 2016 -0800 Committer: Richard Knoll <richard.b.kn...@gmail.com> Committed: Mon Mar 14 10:39:20 2016 -0700 ---------------------------------------------------------------------- README.md | 58 ++++++++++++++++++++++----------------------- jsdoc2md/TEMPLATE.md | 26 ++++++++++++-------- www/CameraConstants.js | 2 +- 3 files changed, 46 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/826aca35/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index e71e364..6d175f0 100644 --- a/README.md +++ b/README.md @@ -73,20 +73,20 @@ Documentation consists of template and API docs produced from the plugin JS code * [camera](#module_camera) - * [.getPicture(successCallback, errorCallback, options)](#module_camera.getPicture) - * [.cleanup()](#module_camera.cleanup) - * [.onError](#module_camera.onError) : <code>function</code> - * [.onSuccess](#module_camera.onSuccess) : <code>function</code> - * [.CameraOptions](#module_camera.CameraOptions) : <code>Object</code> + * [.getPicture(successCallback, errorCallback, options)](#module_camera.getPicture) + * [.cleanup()](#module_camera.cleanup) + * [.onError](#module_camera.onError) : <code>function</code> + * [.onSuccess](#module_camera.onSuccess) : <code>function</code> + * [.CameraOptions](#module_camera.CameraOptions) : <code>Object</code> * [Camera](#module_Camera) - * [.DestinationType](#module_Camera.DestinationType) : <code>enum</code> - * [.EncodingType](#module_Camera.EncodingType) : <code>enum</code> - * [.MediaType](#module_Camera.MediaType) : <code>enum</code> - * [.PictureSourceType](#module_Camera.PictureSourceType) : <code>enum</code> - * [.PopoverArrowDirection](#module_Camera.PopoverArrowDirection) : <code>enum</code> - * [.Direction](#module_Camera.Direction) : <code>enum</code> + * [.DestinationType](#module_Camera.DestinationType) : <code>enum</code> + * [.EncodingType](#module_Camera.EncodingType) : <code>enum</code> + * [.MediaType](#module_Camera.MediaType) : <code>enum</code> + * [.PictureSourceType](#module_Camera.PictureSourceType) : <code>enum</code> + * [.PopoverArrowDirection](#module_Camera.PopoverArrowDirection) : <code>enum</code> + * [.Direction](#module_Camera.Direction) : <code>enum</code> * [CameraPopoverHandle](#module_CameraPopoverHandle) * [CameraPopoverOptions](#module_CameraPopoverOptions) @@ -249,7 +249,7 @@ Optional parameters to customize the camera settings. | Name | Type | Default | Description | | --- | --- | --- | --- | -| DATA_URL | <code>number</code> | <code>0</code> | Return base64 encoded string | +| DATA_URL | <code>number</code> | <code>0</code> | Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible | | FILE_URI | <code>number</code> | <code>1</code> | Return file uri (content://media/external/images/media/2 for Android) | | NATIVE_URI | <code>number</code> | <code>2</code> | Return native uri (eg. asset-library://... for iOS) | @@ -314,13 +314,7 @@ Matches iOS UIPopoverArrowDirection constants to specify arrow location on popov <a name="module_CameraPopoverOptions"></a> ## CameraPopoverOptions -iOS-only parameters that specify the anchor element location and arrow -direction of the popover when selecting images from an iPad's library -or album. -Note that the size of the popover may change to adjust to the -direction of the arrow and orientation of the screen. Make sure to -account for orientation changes when specifying the anchor element -location. +iOS-only parameters that specify the anchor element location and arrow direction of the popover when selecting images from an iPad's library or album. Note that the size of the popover may change to adjust to the direction of the arrow and orientation of the screen. Make sure to account for orientation changes when specifying the anchor element location. | Param | Type | Default | Description | @@ -363,29 +357,35 @@ window.onorientationchange = function() { #### Example <a name="camera-getPicture-examples"></a> -Take a photo and retrieve it as a Base64-encoded image: +Take a photo and retrieve the image's file location: navigator.camera.getPicture(onSuccess, onFail, { quality: 50, - destinationType: Camera.DestinationType.DATA_URL - }); + destinationType: Camera.DestinationType.FILE_URI }); - function onSuccess(imageData) { + function onSuccess(imageURI) { var image = document.getElementById('myImage'); - image.src = "data:image/jpeg;base64," + imageData; + image.src = imageURI; } function onFail(message) { alert('Failed because: ' + message); } -Take a photo and retrieve the image's file location: +Take a photo and retrieve it as a Base64-encoded image: - navigator.camera.getPicture(onSuccess, onFail, { quality: 50, - destinationType: Camera.DestinationType.FILE_URI }); + /** + * Warning: Using DATA_URL is not recommended! The DATA_URL destination + * type is very memory intensive, even with a low quality setting. Using it + * can result in out of memory errors and application crashes. Use FILE_URI + * or NATIVE_URI instead. + */ + navigator.camera.getPicture(onSuccess, onFail, { quality: 25, + destinationType: Camera.DestinationType.DATA_URL + }); - function onSuccess(imageURI) { + function onSuccess(imageData) { var image = document.getElementById('myImage'); - image.src = imageURI; + image.src = "data:image/jpeg;base64," + imageData; } function onFail(message) { http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/826aca35/jsdoc2md/TEMPLATE.md ---------------------------------------------------------------------- diff --git a/jsdoc2md/TEMPLATE.md b/jsdoc2md/TEMPLATE.md index 9260a3c..687b0fd 100644 --- a/jsdoc2md/TEMPLATE.md +++ b/jsdoc2md/TEMPLATE.md @@ -34,29 +34,35 @@ the system's image library. #### Example <a name="camera-getPicture-examples"></a> -Take a photo and retrieve it as a Base64-encoded image: +Take a photo and retrieve the image's file location: navigator.camera.getPicture(onSuccess, onFail, { quality: 50, - destinationType: Camera.DestinationType.DATA_URL - }); + destinationType: Camera.DestinationType.FILE_URI }); - function onSuccess(imageData) { + function onSuccess(imageURI) { var image = document.getElementById('myImage'); - image.src = "data:image/jpeg;base64," + imageData; + image.src = imageURI; } function onFail(message) { alert('Failed because: ' + message); } -Take a photo and retrieve the image's file location: +Take a photo and retrieve it as a Base64-encoded image: - navigator.camera.getPicture(onSuccess, onFail, { quality: 50, - destinationType: Camera.DestinationType.FILE_URI }); + /** + * Warning: Using DATA_URL is not recommended! The DATA_URL destination + * type is very memory intensive, even with a low quality setting. Using it + * can result in out of memory errors and application crashes. Use FILE_URI + * or NATIVE_URI instead. + */ + navigator.camera.getPicture(onSuccess, onFail, { quality: 25, + destinationType: Camera.DestinationType.DATA_URL + }); - function onSuccess(imageURI) { + function onSuccess(imageData) { var image = document.getElementById('myImage'); - image.src = imageURI; + image.src = "data:image/jpeg;base64," + imageData; } function onFail(message) { http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/826aca35/www/CameraConstants.js ---------------------------------------------------------------------- diff --git a/www/CameraConstants.js b/www/CameraConstants.js index c2bbbf5..f4b0694 100644 --- a/www/CameraConstants.js +++ b/www/CameraConstants.js @@ -27,7 +27,7 @@ module.exports = { * @enum {number} */ DestinationType:{ - /** Return base64 encoded string */ + /** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */ DATA_URL: 0, /** Return file uri (content://media/external/images/media/2 for Android) */ FILE_URI: 1, --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org