---
name: "getImageInfo"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.4.3" }
  - { name: "@ray-js/ray", version: "0.5.9" }
platform:
  - "iOS"
  - "Android"
async: true
---

## getImageInfo

> [VERSION] BaseKit >= 2.4.3 | @ray-js/ray >= 0.5.9

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Get image information

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `src` | `string` | Yes | - | `2.4.3` | Image path; supports network and local paths |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `width` | `number` | `3.2.6` | Original image width, in px. Ignoring rotation. |
| `height` | `number` | `3.2.6` | Original image height, in px. Ignoring rotation. |
| `orientation` | `string` | `3.2.6` | Device orientation at capture Valid values	Description up	Default orientation (phone held horizontally), corresponds to 1 in Exif; or no orientation info. up-mirrored	Same as up, but mirrored; corresponds to 2 in Exif down	Rotated 180°, corresponds to 3 in Exif down-mirrored	Same as down, but mirrored; corresponds to 4 in Exif left-mirrored	Same as left, but mirrored; corresponds to 5 in Exif right	Rotated 90° clockwise, corresponds to 6 in Exif right-mirrored	Same as right, but mirrored; corresponds to 7 in Exif left	Rotated 90° counterclockwise, corresponds to 8 in Exif |
| `type` | `string` | `3.2.6` | Image format. Valid values	Description unknown	Unknown format jpeg	JPEG compressed format png	PNG compressed format gif	GIF compressed format tiff	TIFF compressed format |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Examples

#### Demo

```tsx
import { getImageInfo } from '@ray-js/ray'

// Get image info: src supports network/local paths; using a network image here
getImageInfo({
  src: "https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/ttttestfile/test_image.jpg",
  success: data => console.log("Width/height/format/orientation:", data.width, data.height, data.type, data.orientation),
  fail: error => console.error(error),
});
```
