{"id":20198526,"url":"https://github.com/eclipsesource/tabris-plugin-camera","last_synced_at":"2025-04-10T10:53:32.773Z","repository":{"id":57376328,"uuid":"96298816","full_name":"eclipsesource/tabris-plugin-camera","owner":"eclipsesource","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-22T15:10:14.000Z","size":1626,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-24T09:47:06.402Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eclipsesource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-05T08:55:19.000Z","updated_at":"2020-11-28T01:22:25.000Z","dependencies_parsed_at":"2024-11-14T04:32:07.003Z","dependency_job_id":"4234ee6a-36a8-4d90-83c4-ce979e55c69e","html_url":"https://github.com/eclipsesource/tabris-plugin-camera","commit_stats":{"total_commits":510,"total_committers":94,"mean_commits":5.425531914893617,"dds":0.8568627450980393,"last_synced_commit":"07fab95e21dafdfd8ff0ad32422eae4216a79857"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipsesource%2Ftabris-plugin-camera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipsesource%2Ftabris-plugin-camera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipsesource%2Ftabris-plugin-camera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eclipsesource%2Ftabris-plugin-camera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eclipsesource","download_url":"https://codeload.github.com/eclipsesource/tabris-plugin-camera/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248204702,"owners_count":21064891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T04:32:00.993Z","updated_at":"2025-04-10T10:53:32.754Z","avatar_url":"https://github.com/eclipsesource.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: Camera\ndescription: Take pictures with the device camera.\n---\n\u003c!---\n# license: Licensed to the Apache Software Foundation (ASF) under one\n#         or more contributor license agreements.  See the NOTICE file\n#         distributed with this work for additional information\n#         regarding copyright ownership.  The ASF licenses this file\n#         to you under the Apache License, Version 2.0 (the\n#         \"License\"); you may not use this file except in compliance\n#         with the License.  You may obtain a copy of the License at\n#\n#           http://www.apache.org/licenses/LICENSE-2.0\n#\n#         Unless required by applicable law or agreed to in writing,\n#         software distributed under the License is distributed on an\n#         \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n#         KIND, either express or implied.  See the License for the\n#         specific language governing permissions and limitations\n#         under the License.\n#\n#  Modifications for Tabris.js by EclipseSource Inc.\n--\u003e\n\n# tabris-plugin-camera\n\nThis is a fork of [cordova-plugin-camera](https://github.com/apache/cordova-plugin-camera/commit/3b8f64e330df7f1b9d5088fd1a3f7f3e6193c83c), with adjustments made for compatibility with the [Tabris.js](http://tabrisjs.com/) framework.\n\nThis plugin defines a global `navigator.camera` object, which provides an API for taking pictures and for choosing images from\nthe system's image library.\n\n## Installation\n\nYou can add this to your Tabris.js project by includin the followin line in your `config.xml`:\n\n```xml\n\u003cplugin name=\"tabris-plugin-camera\" spec=\"1.0.0\" /\u003e\n```\n\nTo fetch the latest development version, use the URL of the repository:\n\n```xml\n\u003cplugin name=\"tabris-plugin-camera\" spec=\"https://github.com/eclipsesource/tabris-plugin-camera.git\" /\u003e\n```\n\n## How to Contribute\n\nContributors are welcome! And we need your contributions to keep the project moving forward. You can [report bugs](https://github.com/eclipsesource/tabris-plugin-camera/issues/new) or [contribute code](https://github.com/eclipsesource/tabris-plugin-camera/pulls).\n\nIn order for your changes to be accepted, you need to add yourself as a contributer in the license heady of every modified file.\n\n**And don't forget to test and document your code.**\n\n\n### iOS Quirks\n\nSince iOS 10 it's mandatory to add a `NSCameraUsageDescription` and `NSPhotoLibraryUsageDescription` in the info.plist.\n\n- `NSCameraUsageDescription` describes the reason that the app accesses the user’s camera.\n- `NSPhotoLibraryUsageDescription` describes the reason the app accesses the user's photo library.\n\nWhen the system prompts the user to allow access, this string is displayed as part of the dialog box.\n\nTo add this entry you can pass the following variables on plugin install.\n\n- `CAMERA_USAGE_DESCRIPTION` for `NSCameraUsageDescription`\n- `PHOTOLIBRARY_USAGE_DESCRIPTION` for `NSPhotoLibraryUsageDescription`\n\nExample:\n\n    cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION=\"your usage message\" --variable PHOTOLIBRARY_USAGE_DESCRIPTION=\"your usage message\"\n\nIf you don't pass the variable, the plugin will add an empty string as value.\n\n---\n\n# API Reference \u003ca name=\"reference\"\u003e\u003c/a\u003e\n\n\n* [camera](#module_camera)\n    * [.getPicture(successCallback, errorCallback, options)](#module_camera.getPicture)\n    * [.cleanup()](#module_camera.cleanup)\n    * [.onError](#module_camera.onError) : \u003ccode\u003efunction\u003c/code\u003e\n    * [.onSuccess](#module_camera.onSuccess) : \u003ccode\u003efunction\u003c/code\u003e\n    * [.CameraOptions](#module_camera.CameraOptions) : \u003ccode\u003eObject\u003c/code\u003e\n\n\n* [Camera](#module_Camera)\n    * [.DestinationType](#module_Camera.DestinationType) : \u003ccode\u003eenum\u003c/code\u003e\n    * [.EncodingType](#module_Camera.EncodingType) : \u003ccode\u003eenum\u003c/code\u003e\n    * [.MediaType](#module_Camera.MediaType) : \u003ccode\u003eenum\u003c/code\u003e\n    * [.PictureSourceType](#module_Camera.PictureSourceType) : \u003ccode\u003eenum\u003c/code\u003e\n    * [.PopoverArrowDirection](#module_Camera.PopoverArrowDirection) : \u003ccode\u003eenum\u003c/code\u003e\n    * [.Direction](#module_Camera.Direction) : \u003ccode\u003eenum\u003c/code\u003e\n\n* [CameraPopoverHandle](#module_CameraPopoverHandle)\n* [CameraPopoverOptions](#module_CameraPopoverOptions)\n\n---\n\n\u003ca name=\"module_camera\"\u003e\u003c/a\u003e\n\n## camera\n\u003ca name=\"module_camera.getPicture\"\u003e\u003c/a\u003e\n\n### camera.getPicture(successCallback, errorCallback, options)\nTakes a photo using the camera, or retrieves a photo from the device's\nimage gallery.  The image is passed to the success callback as a\nBase64-encoded `String`, or as the URI for the image file.\n\nThe `camera.getPicture` function opens the device's default camera\napplication that allows users to snap pictures by default - this behavior occurs,\nwhen `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`](#module_Camera.PictureSourceType).\nOnce the user snaps the photo, the camera application closes and the application is restored.\n\nIf `Camera.sourceType` is `Camera.PictureSourceType.PHOTOLIBRARY` or\n`Camera.PictureSourceType.SAVEDPHOTOALBUM`, then a dialog displays\nthat allows users to select an existing image.\n\nThe return value is sent to the [`cameraSuccess`](#module_camera.onSuccess) callback function, in\none of the following formats, depending on the specified\n`cameraOptions`:\n\n- A `String` containing the Base64-encoded photo image.\n- A `String` representing the image file location on local storage (default).\n\nYou can do whatever you want with the encoded image or URI, for\nexample:\n\n- Render the image in an `\u003cimg\u003e` tag, as in the example below\n- Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.)\n- Post the data to a remote server\n\n__NOTE__: Photo resolution on newer devices is quite good. Photos\nselected from the device's gallery are not downscaled to a lower\nquality, even if a `quality` parameter is specified.  To avoid common\nmemory problems, set `Camera.destinationType` to `FILE_URI` rather\nthan `DATA_URL`.\n\n__Supported Platforms__\n\n- Android\n- iOS\n- Windows\n\nMore examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks).\n\n**Kind**: static method of \u003ccode\u003e[camera](#module_camera)\u003c/code\u003e\n\n| Param | Type | Description |\n| --- | --- | --- |\n| successCallback | \u003ccode\u003e[onSuccess](#module_camera.onSuccess)\u003c/code\u003e |  |\n| errorCallback | \u003ccode\u003e[onError](#module_camera.onError)\u003c/code\u003e |  |\n| options | \u003ccode\u003e[CameraOptions](#module_camera.CameraOptions)\u003c/code\u003e | CameraOptions |\n\n**Example**\n```js\nnavigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);\n```\n\u003ca name=\"module_camera.cleanup\"\u003e\u003c/a\u003e\n\n### camera.cleanup()\nRemoves intermediate image files that are kept in temporary storage\nafter calling [`camera.getPicture`](#module_camera.getPicture). Applies only when the value of\n`Camera.sourceType` equals `Camera.PictureSourceType.CAMERA` and the\n`Camera.destinationType` equals `Camera.DestinationType.FILE_URI`.\n\n__Supported Platforms__\n\n- iOS\n\n**Kind**: static method of \u003ccode\u003e[camera](#module_camera)\u003c/code\u003e\n**Example**\n```js\nnavigator.camera.cleanup(onSuccess, onFail);\n\nfunction onSuccess() {\n    console.log(\"Camera cleanup success.\")\n}\n\nfunction onFail(message) {\n    alert('Failed because: ' + message);\n}\n```\n\u003ca name=\"module_camera.onError\"\u003e\u003c/a\u003e\n\n### camera.onError : \u003ccode\u003efunction\u003c/code\u003e\nCallback function that provides an error message.\n\n**Kind**: static typedef of \u003ccode\u003e[camera](#module_camera)\u003c/code\u003e\n\n| Param | Type | Description |\n| --- | --- | --- |\n| message | \u003ccode\u003estring\u003c/code\u003e | The message is provided by the device's native code. |\n\n\u003ca name=\"module_camera.onSuccess\"\u003e\u003c/a\u003e\n\n### camera.onSuccess : \u003ccode\u003efunction\u003c/code\u003e\nCallback function that provides the image data.\n\n**Kind**: static typedef of \u003ccode\u003e[camera](#module_camera)\u003c/code\u003e\n\n| Param | Type | Description |\n| --- | --- | --- |\n| imageData | \u003ccode\u003estring\u003c/code\u003e | Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`](#module_camera.CameraOptions) in effect. |\n\n**Example**\n```js\n// Show image\n//\nfunction cameraCallback(imageData) {\n   var image = document.getElementById('myImage');\n   image.src = \"data:image/jpeg;base64,\" + imageData;\n}\n```\n\u003ca name=\"module_camera.CameraOptions\"\u003e\u003c/a\u003e\n\n### camera.CameraOptions : \u003ccode\u003eObject\u003c/code\u003e\nOptional parameters to customize the camera settings.\n* [Quirks](#CameraOptions-quirks)\n\n**Kind**: static typedef of \u003ccode\u003e[camera](#module_camera)\u003c/code\u003e\n**Properties**\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| quality | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e50\u003c/code\u003e | Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.) |\n| destinationType | \u003ccode\u003e[DestinationType](#module_Camera.DestinationType)\u003c/code\u003e | \u003ccode\u003eFILE_URI\u003c/code\u003e | Choose the format of the return value. |\n| sourceType | \u003ccode\u003e[PictureSourceType](#module_Camera.PictureSourceType)\u003c/code\u003e | \u003ccode\u003eCAMERA\u003c/code\u003e | Set the source of the picture. |\n| allowEdit | \u003ccode\u003eBoolean\u003c/code\u003e | \u003ccode\u003etrue\u003c/code\u003e | Allow simple editing of image before selection. |\n| encodingType | \u003ccode\u003e[EncodingType](#module_Camera.EncodingType)\u003c/code\u003e | \u003ccode\u003eJPEG\u003c/code\u003e | Choose the  returned image file's encoding. |\n| targetWidth | \u003ccode\u003enumber\u003c/code\u003e |  | Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant. |\n| targetHeight | \u003ccode\u003enumber\u003c/code\u003e |  | Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant. |\n| mediaType | \u003ccode\u003e[MediaType](#module_Camera.MediaType)\u003c/code\u003e | \u003ccode\u003ePICTURE\u003c/code\u003e | Set the type of media to select from.  Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`. |\n| correctOrientation | \u003ccode\u003eBoolean\u003c/code\u003e |  | Rotate the image to correct for the orientation of the device during capture. |\n| saveToPhotoAlbum | \u003ccode\u003eBoolean\u003c/code\u003e |  | Save the image to the photo album on the device after capture. |\n| popoverOptions | \u003ccode\u003e[CameraPopoverOptions](#module_CameraPopoverOptions)\u003c/code\u003e |  | iOS-only options that specify popover location in iPad. |\n| cameraDirection | \u003ccode\u003e[Direction](#module_Camera.Direction)\u003c/code\u003e | \u003ccode\u003eBACK\u003c/code\u003e | Choose the camera to use (front- or back-facing). |\n\n---\n\n\u003ca name=\"module_Camera\"\u003e\u003c/a\u003e\n\n## Camera\n\u003ca name=\"module_Camera.DestinationType\"\u003e\u003c/a\u003e\n\n### Camera.DestinationType : \u003ccode\u003eenum\u003c/code\u003e\nDefines the output format of `Camera.getPicture` call.\n_Note:_ On iOS passing `DestinationType.NATIVE_URI` along with\n`PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM` will\ndisable any image modifications (resize, quality change, cropping, etc.) due\nto implementation specific.\n\n**Kind**: static enum property of \u003ccode\u003e[Camera](#module_Camera)\u003c/code\u003e\n**Properties**\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| DATA_URL | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e0\u003c/code\u003e | 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 |\n| FILE_URI | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e1\u003c/code\u003e | Return file uri (content://media/external/images/media/2 for Android) |\n| NATIVE_URI | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e2\u003c/code\u003e | Return native uri (eg. asset-library://... for iOS) |\n\n\u003ca name=\"module_Camera.EncodingType\"\u003e\u003c/a\u003e\n\n### Camera.EncodingType : \u003ccode\u003eenum\u003c/code\u003e\n**Kind**: static enum property of \u003ccode\u003e[Camera](#module_Camera)\u003c/code\u003e\n**Properties**\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| JPEG | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e0\u003c/code\u003e | Return JPEG encoded image |\n| PNG | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e1\u003c/code\u003e | Return PNG encoded image |\n\n\u003ca name=\"module_Camera.MediaType\"\u003e\u003c/a\u003e\n\n### Camera.MediaType : \u003ccode\u003eenum\u003c/code\u003e\n**Kind**: static enum property of \u003ccode\u003e[Camera](#module_Camera)\u003c/code\u003e\n**Properties**\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| PICTURE | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e0\u003c/code\u003e | Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType |\n| VIDEO | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e1\u003c/code\u003e | Allow selection of video only, ONLY RETURNS URL |\n| ALLMEDIA | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e2\u003c/code\u003e | Allow selection from all media types |\n\n\u003ca name=\"module_Camera.PictureSourceType\"\u003e\u003c/a\u003e\n\n### Camera.PictureSourceType : \u003ccode\u003eenum\u003c/code\u003e\nDefines the output format of `Camera.getPicture` call.\n_Note:_ On iOS passing `PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM`\nalong with `DestinationType.NATIVE_URI` will disable any image modifications (resize, quality\nchange, cropping, etc.) due to implementation specific.\n\n**Kind**: static enum property of \u003ccode\u003e[Camera](#module_Camera)\u003c/code\u003e\n**Properties**\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| PHOTOLIBRARY | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e0\u003c/code\u003e | Choose image from the device's photo library (same as SAVEDPHOTOALBUM for Android) |\n| CAMERA | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e1\u003c/code\u003e | Take picture from camera |\n| SAVEDPHOTOALBUM | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e2\u003c/code\u003e | Choose image only from the device's Camera Roll album (same as PHOTOLIBRARY for Android) |\n\n\u003ca name=\"module_Camera.PopoverArrowDirection\"\u003e\u003c/a\u003e\n\n### Camera.PopoverArrowDirection : \u003ccode\u003eenum\u003c/code\u003e\nMatches iOS UIPopoverArrowDirection constants to specify arrow location on popover.\n\n**Kind**: static enum property of \u003ccode\u003e[Camera](#module_Camera)\u003c/code\u003e\n**Properties**\n\n| Name | Type | Default |\n| --- | --- | --- |\n| ARROW_UP | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e1\u003c/code\u003e |\n| ARROW_DOWN | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e2\u003c/code\u003e |\n| ARROW_LEFT | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e4\u003c/code\u003e |\n| ARROW_RIGHT | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e8\u003c/code\u003e |\n| ARROW_ANY | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e15\u003c/code\u003e |\n\n\u003ca name=\"module_Camera.Direction\"\u003e\u003c/a\u003e\n\n### Camera.Direction : \u003ccode\u003eenum\u003c/code\u003e\n**Kind**: static enum property of \u003ccode\u003e[Camera](#module_Camera)\u003c/code\u003e\n**Properties**\n\n| Name | Type | Default | Description |\n| --- | --- | --- | --- |\n| BACK | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e0\u003c/code\u003e | Use the back-facing camera |\n| FRONT | \u003ccode\u003enumber\u003c/code\u003e | \u003ccode\u003e1\u003c/code\u003e | Use the front-facing camera |\n\n---\n\n\u003ca name=\"module_CameraPopoverOptions\"\u003e\u003c/a\u003e\n\n## CameraPopoverOptions\niOS-only parameters that specify the anchor element location and arrow\ndirection of the popover when selecting images from an iPad's library\nor album.\nNote that the size of the popover may change to adjust to the\ndirection of the arrow and orientation of the screen.  Make sure to\naccount for orientation changes when specifying the anchor element\nlocation.\n\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| [x] | \u003ccode\u003eNumber\u003c/code\u003e | \u003ccode\u003e0\u003c/code\u003e | x pixel coordinate of screen element onto which to anchor the popover. |\n| [y] | \u003ccode\u003eNumber\u003c/code\u003e | \u003ccode\u003e32\u003c/code\u003e | y pixel coordinate of screen element onto which to anchor the popover. |\n| [width] | \u003ccode\u003eNumber\u003c/code\u003e | \u003ccode\u003e320\u003c/code\u003e | width, in pixels, of the screen element onto which to anchor the popover. |\n| [height] | \u003ccode\u003eNumber\u003c/code\u003e | \u003ccode\u003e480\u003c/code\u003e | height, in pixels, of the screen element onto which to anchor the popover. |\n| [arrowDir] | \u003ccode\u003e[PopoverArrowDirection](#module_Camera.PopoverArrowDirection)\u003c/code\u003e | \u003ccode\u003eARROW_ANY\u003c/code\u003e | Direction the arrow on the popover should point. |\n\n---\n\n\u003ca name=\"module_CameraPopoverHandle\"\u003e\u003c/a\u003e\n\n## CameraPopoverHandle\nA handle to an image picker popover.\n\n__Supported Platforms__\n\n- iOS\n\n**Example**\n```js\nnavigator.camera.getPicture(onSuccess, onFail,\n{\n    destinationType: Camera.DestinationType.FILE_URI,\n    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,\n    popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)\n});\n\n// Reposition the popover if the orientation changes.\nwindow.onorientationchange = function() {\n    var cameraPopoverHandle = new CameraPopoverHandle();\n    var cameraPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY);\n    cameraPopoverHandle.setPosition(cameraPopoverOptions);\n}\n```\n---\n\n\n## `camera.getPicture` Errata\n\n#### Example \u003ca name=\"camera-getPicture-examples\"\u003e\u003c/a\u003e\n\nTake a photo and retrieve the image's file location:\n\n    navigator.camera.getPicture(onSuccess, onFail, { quality: 50,\n        destinationType: Camera.DestinationType.FILE_URI });\n\n    function onSuccess(imageURI) {\n        var image = document.getElementById('myImage');\n        image.src = imageURI;\n    }\n\n    function onFail(message) {\n        console.log('Failed because: ' + message);\n    }\n\nTake a photo and retrieve it as a Base64-encoded image:\n\n    /**\n     * Warning: Using DATA_URL is not recommended! The DATA_URL destination\n     * type is very memory intensive, even with a low quality setting. Using it\n     * can result in out of memory errors and application crashes. Use FILE_URI\n     * or NATIVE_URI instead.\n     */\n    navigator.camera.getPicture(onSuccess, onFail, { quality: 25,\n        destinationType: Camera.DestinationType.DATA_URL\n    });\n\n    function onSuccess(imageData) {\n        var image = document.getElementById('myImage');\n        image.src = \"data:image/jpeg;base64,\" + imageData;\n    }\n\n    function onFail(message) {\n        console.log('Failed because: ' + message);\n    }\n\n#### Preferences (iOS)\n\n-  __CameraUsesGeolocation__ (boolean, defaults to false). For capturing JPEGs, set to true to get geolocation data in the EXIF header. This will trigger a request for geolocation permissions if set to true.\n\n        \u003cpreference name=\"CameraUsesGeolocation\" value=\"false\" /\u003e\n\n#### Android Quirks\n\nAndroid uses intents to launch the camera activity on the device to capture\nimages, and on phones with low memory, the Cordova activity may be killed.  In this\nscenario, the result from the plugin call will be delivered via the resume event.\nSee [the Android Lifecycle guide][android_lifecycle]\nfor more information. The `pendingResult.result` value will contain the value that\nwould be passed to the callbacks (either the URI/URL or an error message). Check\nthe `pendingResult.pluginStatus` to determine whether or not the call was\nsuccessful.\n\n\n## `CameraOptions` Errata \u003ca name=\"CameraOptions-quirks\"\u003e\u003c/a\u003e\n\n#### Android Quirks\n\n- Any `cameraDirection` value results in a back-facing photo.\n\n- **`allowEdit` is unpredictable on Android and it should not be used!** The Android implementation of this plugin tries to find and use an application on the user's device to do image cropping. The plugin has no control over what application the user selects to perform the image cropping and it is very possible that the user could choose an incompatible option and cause the plugin to fail. This sometimes works because most devices come with an application that handles cropping in a way that is compatible with this plugin (Google Plus Photos), but it is unwise to rely on that being the case. If image editing is essential to your application, consider seeking a third party library or plugin that provides its own image editing utility for a more robust solution.\n\n- `Camera.PictureSourceType.PHOTOLIBRARY` and `Camera.PictureSourceType.SAVEDPHOTOALBUM` both display the same photo album.\n\n- Ignores the `encodingType` parameter if the image is unedited (i.e. `quality` is 100, `correctOrientation` is false, and no `targetHeight` or `targetWidth` are specified). The `CAMERA` source will always return the JPEG file given by the native camera and the `PHOTOLIBRARY` and `SAVEDPHOTOALBUM` sources will return the selected file in its existing encoding.\n\n#### iOS Quirks\n\n- When using `destinationType.FILE_URI`, photos are saved in the application's temporary directory. The contents of the application's temporary directory is deleted when the application ends.\n\n- When using `destinationType.NATIVE_URI` and `sourceType.CAMERA`, photos are saved in the saved photo album regardless on the value of `saveToPhotoAlbum` parameter.\n\n- When using `destinationType.NATIVE_URI` and `sourceType.PHOTOLIBRARY` or `sourceType.SAVEDPHOTOALBUM`, all editing options are ignored and link is returned to original picture.\n\n## Sample: Take Pictures, Select Pictures from the Picture Library, and Get Thumbnails \u003ca name=\"sample\"\u003e\u003c/a\u003e\n\nThe Camera plugin allows you to do things like open the device's Camera app and take a picture, or open the file picker and select one. The code snippets in this section demonstrate different tasks including:\n\n* Open the Camera app and [take a Picture](#takePicture)\n* Take a picture and [return thumbnails](#getThumbnails) (resized picture)\n* Take a picture and [generate a FileEntry object](#convert)\n* [Select a file](#selectFile) from the picture library\n* Select a JPEG image and [return thumbnails](#getFileThumbnails) (resized image)\n* Select an image and [generate a FileEntry object](#convert)\n\n## Take a Picture \u003ca name=\"takePicture\"\u003e\u003c/a\u003e\n\nBefore you can take a picture, you need to set some Camera plugin options to pass into the Camera plugin's `getPicture` function. Here is a common set of recommendations. In this example, you create the object that you will use for the Camera options, and set the `sourceType` dynamically to support both the Camera app and the file picker.\n\n```js\nfunction setOptions(srcType) {\n    var options = {\n        // Some common settings are 20, 50, and 100\n        quality: 50,\n        destinationType: Camera.DestinationType.FILE_URI,\n        // In this app, dynamically set the picture source, Camera or photo gallery\n        sourceType: srcType,\n        encodingType: Camera.EncodingType.JPEG,\n        mediaType: Camera.MediaType.PICTURE,\n        allowEdit: true,\n        correctOrientation: true  //Corrects Android orientation quirks\n    }\n    return options;\n}\n```\n\nYou take a picture by passing in the options object to `getPicture`, which takes a CameraOptions object as the third argument. When you call `setOptions`, pass `Camera.PictureSourceType.CAMERA` as the picture source.\n\n```js\nfunction openCamera(selection) {\n\n    var srcType = Camera.PictureSourceType.CAMERA;\n    var options = setOptions(srcType);\n    var func = createNewFileEntry;\n\n    navigator.camera.getPicture(function cameraSuccess(imageUri) {\n\n        displayImage(imageUri);\n        // You may choose to copy the picture, save it somewhere, or upload.\n        func(imageUri);\n\n    }, function cameraError(error) {\n        console.debug(\"Unable to obtain picture: \" + error, \"app\");\n\n    }, options);\n}\n```\n\nOnce you take the picture, you can display it or do something else. In this example, call the app's `displayImage` function from the preceding code.\n\n```js\nfunction displayImage(imgUri) {\n\n    var elem = document.getElementById('imageFile');\n    elem.src = imgUri;\n}\n```\n\nTo display the image on some platforms, you might need to include the main part of the URI in the Content-Security-Policy `\u003cmeta\u003e` element in index.html. For example, on Windows 10, you can include `ms-appdata:` in your `\u003cmeta\u003e` element. Here is an example.\n\n```html\n\u003cmeta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self' data: gap: ms-appdata: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *\"\u003e\n```\n\n## Take a Picture and Return Thumbnails (Resize the Picture) \u003ca name=\"getThumbnails\"\u003e\u003c/a\u003e\n\nTo get smaller images, you can return a resized image by passing both `targetHeight` and `targetWidth` values with your CameraOptions object. In this example, you resize the returned image to fit in a 100px by 100px box (the aspect ratio is maintained, so 100px is either the height or width, whichever is greater in the source).\n\n```js\nfunction openCamera(selection) {\n\n    var srcType = Camera.PictureSourceType.CAMERA;\n    var options = setOptions(srcType);\n    var func = createNewFileEntry;\n\n    if (selection == \"camera-thmb\") {\n        options.targetHeight = 100;\n        options.targetWidth = 100;\n    }\n\n    navigator.camera.getPicture(function cameraSuccess(imageUri) {\n\n        // Do something\n\n    }, function cameraError(error) {\n        console.debug(\"Unable to obtain picture: \" + error, \"app\");\n\n    }, options);\n}\n```\n\n## Select a File from the Picture Library \u003ca name=\"selectFile\"\u003e\u003c/a\u003e\n\nWhen selecting a file using the file picker, you also need to set the CameraOptions object. In this example, set the `sourceType` to `Camera.PictureSourceType.SAVEDPHOTOALBUM`. To open the file picker, call `getPicture` just as you did in the previous example, passing in the success and error callbacks along with CameraOptions object.\n\n```js\nfunction openFilePicker(selection) {\n\n    var srcType = Camera.PictureSourceType.SAVEDPHOTOALBUM;\n    var options = setOptions(srcType);\n    var func = createNewFileEntry;\n\n    navigator.camera.getPicture(function cameraSuccess(imageUri) {\n\n        // Do something\n\n    }, function cameraError(error) {\n        console.debug(\"Unable to obtain picture: \" + error, \"app\");\n\n    }, options);\n}\n```\n\n## Select an Image and Return Thumbnails (resized images) \u003ca name=\"getFileThumbnails\"\u003e\u003c/a\u003e\n\nResizing a file selected with the file picker works just like resizing using the Camera app; set the `targetHeight` and `targetWidth` options.\n\n```js\nfunction openFilePicker(selection) {\n\n    var srcType = Camera.PictureSourceType.SAVEDPHOTOALBUM;\n    var options = setOptions(srcType);\n    var func = createNewFileEntry;\n\n    if (selection == \"picker-thmb\") {\n        // To downscale a selected image,\n        // Camera.EncodingType (e.g., JPEG) must match the selected image type.\n        options.targetHeight = 100;\n        options.targetWidth = 100;\n    }\n\n    navigator.camera.getPicture(function cameraSuccess(imageUri) {\n\n        // Do something with image\n\n    }, function cameraError(error) {\n        console.debug(\"Unable to obtain picture: \" + error, \"app\");\n\n    }, options);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipsesource%2Ftabris-plugin-camera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feclipsesource%2Ftabris-plugin-camera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feclipsesource%2Ftabris-plugin-camera/lists"}