# Media

## Select or take a picture[​](https://docs.appmachine.com/libraries/javascript/sdk/api/media#select-or-take-a-picture) <a href="#select-or-take-a-picture" id="select-or-take-a-picture"></a>

Ask the user to open the camera to take a picture or select a picture from the gallery.

```javascript
import { pickImage } from '@myjsblock/sdk'

const image = await pickImage();

console.log(image); // Prints base64 result of image
```

#### Arguments[​](https://docs.appmachine.com/libraries/javascript/sdk/api/media#arguments) <a href="#arguments" id="arguments"></a>

<table><thead><tr><th width="225">Name</th><th width="101">Type</th><th width="103">Required</th><th width="91">Default</th><th>Notes</th></tr></thead><tbody><tr><td><code>maxHeight</code></td><td><em>number</em></td><td></td><td>-</td><td></td></tr><tr><td><code>maxWidth</code></td><td><em>number</em></td><td></td><td>-</td><td></td></tr><tr><td><code>quality</code></td><td><em>number</em></td><td></td><td>-</td><td>Value between 1 and 100, controls compression level</td></tr><tr><td><code>showCameraOption</code></td><td><em>boolean</em></td><td></td><td>-</td><td></td></tr><tr><td><code>showGalleryOption</code></td><td><em>boolean</em></td><td></td><td>-</td><td></td></tr></tbody></table>

#### Errors[​](https://docs.appmachine.com/libraries/javascript/sdk/api/media#errors) <a href="#errors" id="errors"></a>

Here is a list of errors that can be thrown when calling this function in addition to [generic errors](/developers/javascript/sdk/core.md#generic-errors):

| Error Code            | Description                                                                                             |
| --------------------- | ------------------------------------------------------------------------------------------------------- |
| `OPERATION_CANCELLED` | The user cancelled the operation.                                                                       |
| `UNKNOWN_ERROR`       | An error occurred while opening the camera or gallery, for example, the user may have denied permission |

<br>


---

# 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.appmachine.com/developers/javascript/sdk/media.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.
