---
name: "enhanceClarityForImage"
mode: "kit"
versionRequirements:
  - { name: "AIKit", version: "1.4.1" }
  - { name: "@ray-js/ray", version: "1.7.37" }
platform:
  - "iOS"
  - "Android"
async: true
title: "enhanceClarityForImage"
---

## enhanceClarityForImage

> [VERSION] AIKit >= 1.4.1 | @ray-js/ray >= 1.7.37

> [PLATFORM] iOS, Android

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

### Description

Image clarity enhancement processing

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `trace_id` | `string` | Yes | - | `2.1.0` | Link ID |
| `device_id` | `string` | Yes | - | `2.1.0` | Device ID |
| `scene_type` | `string` | Yes | - | `2.1.0` | Business type |
| `devId` | `string` | Yes | - | `2.0.1` | Device ID |
| `inputImagePath` | `string` | Yes | - | `1.4.1` | Image input path |
| `outputImagePath` | `string` | Yes | - | `1.4.1` | Image output path |
| `enhanceOutputResolution` | `1 \| 2 \| 3` | No | `1` | `1.4.1` | Desired output image resolution Default maximum output is 1080p; if lower than 1080p, the output follows the input size |
| `enhanceType` | `1 \| 2 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8` | No | `1` | `1.4.1` | Image enhancement type |
| `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 |
| --- | --- | --- | --- |
| `outputImagePath` | `string` | `1.4.1` | Image URL |
| `enhanceSuccess` | `boolean` | `1.4.1` | Whether processing succeeded |
| `enhanceFaileReason` | `string` | `1.4.1` | Failure reason |

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


### Valid Values

##### `enhanceOutputResolution` valid values

| Value | Description |
| --- | --- |
| `1` | Native size |
| `2` | 640 |
| `3` | 720 |

##### `enhanceType` valid values

| Value | Description |
| --- | --- |
| `1` | No action, default |
| `2` | Noise reduction |
| `3` | Low-light enhancement |
| `4` | Super-resolution |
| `5` | Noise reduction + low-light enhancement |
| `6` | Noise reduction + super-resolution |
| `7` | Low-light enhancement + super-resolution |
| `8` | Noise reduction + low-light enhancement + super-resolution |


### Examples

#### Basic usage

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

const { enhanceClarityForImage } = ai;

enhanceClarityForImage({
  trace_id: 'example',
  device_id: 'device_001',
  scene_type: 'example',
  devId: 'device_001',
  inputImagePath: 'example',
  outputImagePath: 'example',
  success: (result) => {
    console.log('enhanceClarityForImage success', result);
  },
  fail: (error) => {
    console.log('enhanceClarityForImage fail', error.errorMsg);
  },
});
```
