# Camera

### Required Phonegap plugins

cordova-plugin-camera

## API Documentation

### Method Summary

#### getPicture

Take (using camera) or get an image file from the device's default gallery.

**Params**

| Type     | Name            | Summary             | Required |
| -------- | --------------- | ------------------- | -------- |
| Function | successCallback | on success callback | Optional |
| Function | errorCallback   | on error callback   | Optional |
| Object   | options         | Options object      | Optional |

The options object's parameters can be aquired from the [cordova-plugin-camera](https://github.com/apache/cordova-plugin-camera) site.

## Example Usage

```javascript
var options = {
  quality: 50,
  destinationType: 0,
  sourceType: 1,
  correctOrientation: true
}

/**
 * Hook up to a button or element with an onAction event to start the camera
 * @properties={typeid:24,uuid:"8EEAFB0D-133F-4009-9C41-83B8A890D19B"}
 */
function onAction$takePicture() {
    plugins.svyphonegapCamera.getPicture(getPicSuccess, getPicFail, options);
}

/**
 * Callback when picture received successfully
 * @properties={typeid:24,uuid:"8EEAFB0D-133F-4009-9C41-83B8A890D19B"}
 */
function getPicFail(err) {
	//failed to get picture	
}

 /**
 * Callback when picture received successfully
 * @properties={typeid:24,uuid:"8EEAFB0D-133F-4009-9C41-83B8A890D19B"}
 */
function getPicSuccess(res) {
	//display the image.
	elements.contact_photo.imageURL = '';
	elements.contact_photo.text = '<img src="data:image/png;base64,' + res + '"/>'
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/guides/develop/programming-guide/extensions/modules/svyphonegap/camera.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
