> For the complete documentation index, see [llms.txt](https://docs.appmachine.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appmachine.com/developers/javascript/sdk/media.md).

# 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>
