## Pet Image Resource Import

<div style="display: flex; align-items: center; justify-content: flex-start; margin-top: 20px;">
<img alt="Pet Image Quality Detection" src="https://images.tuyacn.com/rms-static/83865770-564f-11f0-9f57-5d628208d2a7-1751355995751.jpg?tyName=select_image_2.jpg" width="250" style="margin-right: 10px;">
</div>

### Feature Introduction

The initialization and import of pet image resources rely on the following two key capabilities:

1. Image Selection

   - [chooseImage](/en/miniapp/develop/ray/api/media/image/chooseImage): Supports end-users in selecting images from the local gallery or using the camera to take photos.

2. Image Compression

   - [resizeImage](/en/miniapp/develop/ray/api/media/image/resizeImage): Compresses images by first cropping them to the target dimensions while maintaining the original aspect ratio, then performing quality compression based on file size limits.

### Interaction Flow

```mermaid
sequenceDiagram
    participant User
    participant Panel
    participant System Gallery
    participant Image Processor

    rect rgb(200, 230, 255)
        Note over User,Panel: Image Selection Phase
        User ->> Panel: Click "Create Pet Profile"
        Panel ->> System Gallery: chooseImage()
        System Gallery ->> User: Gallery interface appears
        User ->> System Gallery: Select pet image
        System Gallery -->> Panel: Return list of original image URIs
    end

    rect rgb(200, 255, 225)
        Note over Panel,Image Processor: Image Processing Phase
        Panel ->> Image Processor: resizeImage(original URI)
        Image Processor ->> Image Processor: 1. Copy to app cache
        Image Processor ->> Image Processor: 2. Compress to specified size (e.g., 800x800)
        Image Processor -->> Panel: Return processed temporary URI
    end

    rect rgb(230, 200, 255)
        Note over Panel,User: Result Return Phase
        Panel ->> Panel: Generate cache address list
        Panel ->> User: Display compressed preview images
    end
```

### Notes

- 1. When using the resizeImage API, the parameter maxFileSize is in bytes. Please pay attention to unit conversion when limiting the maximum image size.
