1# Image 2 3The **Image** component is usually used to display images in applications. It supports images in PNG, JPG, JPEG, BMP, SVG, WEBP, GIF, or HEIF format from the following data sources: [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7), [ResourceStr](ts-types.md#resourcestr), or [DrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#drawabledescriptor). 4 5> **NOTE** 6> 7> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8> 9> To use shortcut keys to copy the **Image** component, the component must be [in focus](../../../ui/arkts-common-events-focus-event.md#setting-whether-a-component-is-focusable). By default, the **Image** component is not focusable. To enable it to gain focus, set both the [focusable](ts-universal-attributes-focus.md#focusable) and [focusOnTouch](ts-universal-attributes-focus.md#focusontouch9) attributes to **true**. 10> 11> For SVG images, only the following tags are included in the supported list: **svg**, **rect**, **circle**, **ellipse**, **path**, **line**, **polyline**, **polygon**, **feFlood**, **feBlend**, **feColorMatrix**, **feGaussianBlur**, **feComposite**, **filter**, **mask**, and **use**. 12 13## Required Permissions 14 15The **ohos.permission.INTERNET** permission is required for using online images. For details about how to apply for a permission, see [Declaring Permissions](../../../security/AccessToken/declare-permissions.md). 16 17 18## Child Components 19 20Not supported 21 22 23## APIs 24 25### Image 26 27Image(src: PixelMap | ResourceStr | DrawableDescriptor) 28 29Obtains an image from the specified source for subsequent rendering and display. 30 31If the **Image** component fails to obtain the image or the obtained image size is 0, the **Image** component is automatically resized to 0 and does not follow the layout constraints of its parent component. 32 33By default, the **Image** component crops images to keep their center. For example, if the component has the same width and height, it crops any image whose width and height are different, so as to keep its center. 34 35If the **Image** component does not have its width and height set, its size adapts to that of its parent component once the image is successfully loaded. 36 37**Widget capability**: This API can be used in ArkTS widgets since API version 9. 38 39**Atomic service API**: This API can be used in atomic services since API version 11. 40 41**System capability**: SystemCapability.ArkUI.ArkUI.Full 42 43**Parameters** 44 45| Name | Type | Mandatory | Description | 46| ---- | ---------------------------------------- | ---- | ---------------------------------------- | 47| src | [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7) \| [ResourceStr](ts-types.md#resourcestr)\| [DrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | Yes | Data source of the image. Local and online sources are supported. For details about how to reference an image, see [Loading Image Resources](../../../ui/arkts-graphics-display.md#loading-image-resources).<br>1. **PixelMap**: an array of pixels storing graphical information. This type is usually used in image editing scenarios.<br>2. **ResourceStr**: a string or a **Resource** object.<br>The string format can be used to load local images and, more frequently, online images. When using an image referenced using a relative path, for example, **Image("common/test.jpg")**, the **Image** component cannot be called across bundles or modules. If an image needs to be used globally, you are advised to use the **Resource** format. The following types of strings are supported:<br>- Base64 strings in the format of data:image/[png\|jpeg\|bmp\|webp\|heif];base64,[base64 data], where *[base64 data]* is a Base64 string.<br>- Strings with the **file://** prefix, that is, [application sandbox URIs](../../apis-core-file-kit/js-apis-file-fileuri.md#constructor10): **file://\<bundleName>/\<sandboxPath>**, which are used to access the images in the **files** folder in the installation directory of the application. Ensure that the application has the read permission to the files in the specified path.<br>The **Resource** format allows for access across bundles and modules. It is recommended for accessing local images.<br>3. **DrawableDescriptor**: an object created when the passed resource ID or name belongs to a common image. If the [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12) type is passed in, the PixelMap array animation can be played.<br>**NOTE**<br>- ArkTS widgets support GIF animations, but the animations only play once on display.<br>- ArkTS widgets do not support the strings with the **http:/\/** or **file:/\/** prefix.<br>- ArkTS widgets do not support the [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7) type.<br>- When a local image is being loaded, any modification or replacement of it may cause application crash. Therefore, to overwrite an image file, delete the file first and then create one with the same name.<br>- Online images must support the RFC 9113 standard to be successfully loaded.<br>- If images to download are greater than 10 MB or in large number, consider using [HTTP](../../../network/http-request.md) to preload them to improve the image loading performance and facilitate data management on the application side.<br>- To display an SVG image that does not have the native size, you must set the width and height for the **Image** component.<br>- If an SVG image references another local image through the Image tag, the referenced image cannot be in .svg or .gif format.| 48 49### Image<sup>12+</sup> 50 51Image(src: PixelMap | ResourceStr | DrawableDescriptor | ImageContent) 52 53Obtains an image. The [ImageContent](#imagecontent12) type allows you to specify the image content. 54 55**System capability**: SystemCapability.ArkUI.ArkUI.Full 56 57**Parameters** 58 59| Name | Type | Mandatory | Description | 60| ---- | ---------------------------------------- | ---- | ---------------------------------------- | 61| src | [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7) \| [ResourceStr](ts-types.md#resourcestr)\| [DrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#drawabledescriptor)\| [ImageContent](#imagecontent12) | Yes | Data source of the image. Local and online sources are supported. For details about how to reference an image, see [Loading Image Resources](../../../ui/arkts-graphics-display.md#loading-image-resources).<br>1. **PixelMap**: an array of pixels storing graphical information. This type is usually used in image editing scenarios.<br>2. **ResourceStr**: a string or a **Resource** object.<br>The string format can be used to load local images and, more frequently, online images. When using an image referenced using a relative path, for example, **Image("common/test.jpg")**, the **Image** component cannot be called across bundles or modules. If an image needs to be used globally, you are advised to use the **Resource** format. The following types of strings are supported:<br>- Base64 strings in the format of data:image/[png\|jpeg\|bmp\|webp\|heif];base64,[base64 data], where *[base64 data]* is a Base64 string.<br>- Strings with the **file://** prefix, that is, [application sandbox URIs](../../apis-core-file-kit/js-apis-file-fileuri.md#constructor10): **file://\<bundleName>/\<sandboxPath>**, which are used to access the images in the **files** folder in the installation directory of the application. Ensure that the application has the read permission to the files in the specified path.<br>The **Resource** format allows for access across bundles and modules. It is recommended for accessing local images.<br>3. **DrawableDescriptor**: an object created when the passed resource ID or name belongs to a common image. If the [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12) type is passed in, the PixelMap array animation can be played.<br>4. [ImageContent](#imagecontent12): image content.<br>**NOTE**<br>- ArkTS widgets support GIF animations, but the animations only play once on display.<br>- ArkTS widgets do not support the strings with the **http:/\/** or **file:/\/** prefix.<br>- ArkTS widgets do not support the [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7) type.<br>- When a local image is being loaded, any modification or replacement of it may cause application crash. Therefore, to overwrite an image file, delete the file first and then create one with the same name.<br>- Online images must support the RFC 9113 standard to be successfully loaded.<br>- If images to download are greater than 10 MB or in large number, consider using [HTTP](../../../network/http-request.md) to preload them to improve the image loading performance and facilitate data management on the application side.<br>- To display an SVG image that does not have the native size, you must set the width and height for the **Image** component.<br>- If an SVG image references another local image through the Image tag, the referenced image cannot be in .svg or .gif format.| 62 63### Image<sup>12+</sup> 64 65Image(src: PixelMap | ResourceStr | DrawableDescriptor, imageAIOptions: ImageAIOptions) 66 67Obtains an image. The [imageAIOptions](ts-image-common.md#imageaioptions) parameter allows you to set AI image analysis options. 68 69**Atomic service API**: This API can be used in atomic services since API version 12. 70 71**System capability**: SystemCapability.ArkUI.ArkUI.Full 72 73**Parameters** 74 75| Name | Type | Mandatory | Description | 76| ---- | ---------------------------------------- | ---- | ---------------------------------------- | 77| src | [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7) \| [ResourceStr](ts-types.md#resourcestr)\| [DrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | Yes | Data source of the image. Local and online sources are supported. For details about how to reference an image, see [Loading Image Resources](../../../ui/arkts-graphics-display.md#loading-image-resources).<br>1. **PixelMap**: an array of pixels storing graphical information. This type is usually used in image editing scenarios.<br>2. **ResourceStr**: a string or a **Resource** object.<br>The string format can be used to load local images and, more frequently, online images. When using an image referenced using a relative path, for example, **Image("common/test.jpg")**, the **Image** component cannot be called across bundles or modules. If an image needs to be used globally, you are advised to use the **Resource** format. The following types of strings are supported:<br>- Base64 strings in the format of data:image/[png\|jpeg\|bmp\|webp\|heif];base64,[base64 data], where *[base64 data]* is a Base64 string.<br>- Strings with the **file://** prefix, that is, [application sandbox URIs](../../apis-core-file-kit/js-apis-file-fileuri.md#constructor10): **file://\<bundleName>/\<sandboxPath>**, which are used to access the images in the **files** folder in the installation directory of the application. Ensure that the application has the read permission to the files in the specified path.<br>The **Resource** format allows for access across bundles and modules. It is recommended for accessing local images.<br>3. **DrawableDescriptor**: an object created when the passed resource ID or name belongs to a common image. If the [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12) type is passed in, the PixelMap array animation can be played.<br>**NOTE**<br>- ArkTS widgets support GIF animations, but the animations only play once on display.<br>- ArkTS widgets do not support the strings with the **http:/\/** or **file:/\/** prefix.<br>- ArkTS widgets do not support the [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7) type.<br>- When a local image is being loaded, any modification or replacement of it may cause application crash. Therefore, to overwrite an image file, delete the file first and then create one with the same name.<br>- Online images must support the RFC 9113 standard to be successfully loaded.<br>- If images to download are greater than 10 MB or in large number, consider using [HTTP](../../../network/http-request.md) to preload them to improve the image loading performance and facilitate data management on the application side.<br>- To display an SVG image that does not have the native size, you must set the width and height for the **Image** component.<br>- If an SVG image references another local image through the Image tag, the referenced image cannot be in .svg or .gif format.| 78| imageAIOptions | [ImageAIOptions](ts-image-common.md#imageaioptions) | Yes | AI image analysis options. You can configure the analysis type or bind an analyzer controller through this parameter.| 79 80## Attributes 81 82For details about how to use the attributes, see [Setting Attributes](../../../ui/arkts-graphics-display.md#setting-attributes). In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 83 84### alt 85 86alt(value: string | Resource | PixelMap) 87 88Sets the placeholder image displayed during loading. 89 90This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 91 92**Widget capability**: This API can be used in ArkTS widgets since API version 9. 93 94**Atomic service API**: This API can be used in atomic services since API version 11. 95 96**System capability**: SystemCapability.ArkUI.ArkUI.Full 97 98**Parameters** 99 100| Name| Type | Mandatory| Description | 101| ------ | -------------------------------------------------------- | ---- | ------------------------------------------------------------ | 102| value | string \| [Resource](ts-types.md#resource) \| [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7)<sup>12+</sup> | Yes | Placeholder image displayed during loading. Local images (in PNG, JPG, BMP, SVG, GIF, or HEIF format) and [PixelMap](../../apis-image-kit/js-apis-image.md#pixelmap7) objects are supported, but online images are not.<br>Default value: **null**| 103 104### objectFit 105 106objectFit(value: ImageFit) 107 108Sets how the image is resized to fit its container. 109 110**Widget capability**: This API can be used in ArkTS widgets since API version 9. 111 112**Atomic service API**: This API can be used in atomic services since API version 11. 113 114**System capability**: SystemCapability.ArkUI.ArkUI.Full 115 116**Parameters** 117 118| Name| Type | Mandatory| Description | 119| ------ | ----------------------------------------- | ---- | ------------------------------------------- | 120| value | [ImageFit](ts-appendix-enums.md#imagefit) | Yes | How the image is resized to fit its container.<br>Default value: **ImageFit.Cover**| 121 122### objectRepeat 123 124objectRepeat(value: ImageRepeat) 125 126Sets how the image is repeated. When set to repeat, the image is repeated from the center to edges, and the last image will be clipped if it does not fit in the component. This attribute is not applicable to SVG images. 127 128This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 129 130**Widget capability**: This API can be used in ArkTS widgets since API version 9. 131 132**Atomic service API**: This API can be used in atomic services since API version 11. 133 134**System capability**: SystemCapability.ArkUI.ArkUI.Full 135 136**Parameters** 137 138| Name| Type | Mandatory| Description | 139| ------ | ----------------------------------------------- | ---- | ------------------------------------------------- | 140| value | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | Yes | How the image is repeated.<br>Default value: **ImageRepeat.NoRepeat**| 141 142### interpolation 143 144interpolation(value: ImageInterpolation) 145 146Sets the interpolation effect of the image, which can alleviate aliasing that occurs when the image is zoomed. This attribute is not applicable to SVG images. 147 148This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 149 150**Widget capability**: This API can be used in ArkTS widgets since API version 9. 151 152**Atomic service API**: This API can be used in atomic services since API version 11. 153 154**System capability**: SystemCapability.ArkUI.ArkUI.Full 155 156**Parameters** 157 158| Name| Type | Mandatory| Description | 159| ------ | ----------------------------------------- | ---- | --------------------------------------------------- | 160| value | [ImageInterpolation](#imageinterpolation) | Yes | Interpolation effect of the image.<br>Default value: **ImageInterpolation.Low**| 161 162### renderMode 163 164renderMode(value: ImageRenderMode) 165 166Sets the rendering mode of the image. This attribute is not applicable to SVG images. 167 168When [ColorFilter](#colorfilter9) is set, this attribute is not effective. 169 170This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 171 172**Widget capability**: This API can be used in ArkTS widgets since API version 9. 173 174**Atomic service API**: This API can be used in atomic services since API version 11. 175 176**System capability**: SystemCapability.ArkUI.ArkUI.Full 177 178**Parameters** 179 180| Name| Type | Mandatory| Description | 181| ------ | ----------------------------------- | ---- | ------------------------------------------------------------ | 182| value | [ImageRenderMode](#imagerendermode) | Yes | Rendering mode of the image, which can be **Original** or **Template** (monochrome).<br>Default value: **ImageRenderMode.Original**| 183 184### sourceSize 185 186sourceSize(value: { width: number; height: number }) 187 188Sets the decoding size of the image. This attribute works only when the target size is smaller than the source size. This attribute is not applicable to SVG images or **PixelMap** objects. 189 190This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 191 192**Widget capability**: This API can be used in ArkTS widgets since API version 9. 193 194**Atomic service API**: This API can be used in atomic services since API version 11. 195 196**System capability**: SystemCapability.ArkUI.ArkUI.Full 197 198**Parameters** 199 200| Name| Type | Mandatory| Description | 201| ------ | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 202| value | {<br>width: number,<br>height: number<br>} | Yes | Decoding size of the image. This parameter can be used to reduce the image resolution when the image display size needs to be smaller than the component size. When used together with **ImageFit.None**, it can display a small image in the component.<br>Unit: vp| 203 204### matchTextDirection 205 206matchTextDirection(value: boolean) 207 208Specifies whether to display the image in the system language direction. When **value** is set to **true**, the image is horizontally flipped in the right-to-left (RTL) language context. 209 210This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 211 212**Widget capability**: This API can be used in ArkTS widgets since API version 9. 213 214**Atomic service API**: This API can be used in atomic services since API version 11. 215 216**System capability**: SystemCapability.ArkUI.ArkUI.Full 217 218**Parameters** 219 220| Name| Type | Mandatory| Description | 221| ------ | ------- | ---- | -------------------------------------------- | 222| value | boolean | Yes | Whether to display the image in the system language direction.<br>Default value: **false**| 223 224### fitOriginalSize 225 226fitOriginalSize(value: boolean) 227 228Specifies whether to fit the component to the size of the image source when the component size is not set. 229 230This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 231 232**Widget capability**: This API can be used in ArkTS widgets since API version 9. 233 234**Atomic service API**: This API can be used in atomic services since API version 11. 235 236**System capability**: SystemCapability.ArkUI.ArkUI.Full 237 238**Parameters** 239 240| Name| Type | Mandatory| Description | 241| ------ | ------- | ---- | ------------------------------------------------ | 242| value | boolean | Yes | Whether to fit the image to the size of the image source.<br>Default value: **false**| 243 244### fillColor 245 246fillColor(value: ResourceColor) 247 248Sets the fill color to be superimposed on the image. This attribute applies only to an SVG image. Once set, the fill color will replace that of the SVG image. To set the fill color for a PNG image, use [colorFilter](#colorfilter9). 249 250This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 251 252**Widget capability**: This API can be used in ArkTS widgets since API version 9. 253 254**Atomic service API**: This API can be used in atomic services since API version 11. 255 256**System capability**: SystemCapability.ArkUI.ArkUI.Full 257 258**Parameters** 259 260| Name| Type | Mandatory| Description | 261| ------ | ------------------------------------------ | ---- | -------------- | 262| value | [ResourceColor](ts-types.md#resourcecolor) | Yes | Fill color to be superimposed on the image.| 263 264### autoResize 265 266autoResize(value: boolean) 267 268Specifies whether to resize the image source based on the size of the display area during image decoding. As downsampling images results in some loss of information, it may reduce the image quality, causing issues such as aliasing. To retain the original image quality, set **autoResize** to **false**, but this may increase the memory usage. 269 270If the original image size does not match the display size, the image may be distorted or blurred. Recommended configuration for the optimal definition: 271 272When the image is scaled down: .autoResize(false) + .interpolation(.Medium) 273 274When the image is scaled up: .interpolation(.High) 275 276This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 277 278**Widget capability**: This API can be used in ArkTS widgets since API version 9. 279 280**Atomic service API**: This API can be used in atomic services since API version 11. 281 282**System capability**: SystemCapability.ArkUI.ArkUI.Full 283 284**Parameters** 285 286| Name| Type | Mandatory| Description | 287| ------ | ------- | ---- | ------------------------------------------------------------ | 288| value | boolean | Yes | Whether to resize the image source based on the size of the display area during image decoding. This resizing can help reduce the memory usage. For example, if the size of the original image is 1920 x 1080 and the size of the display area is 200 x 200, you can set this attribute to **true** so that the image is downsampled to 200 x 200.<br>Default value: **false**| 289 290### syncLoad<sup>8+</sup> 291 292syncLoad(value: boolean) 293 294Specifies whether to load the image synchronously. When loading a small image, you are advised to set **syncLoad** to **true** so that the image loading can be quickly completed on the main thread. 295 296This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 297 298**Widget capability**: This API can be used in ArkTS widgets since API version 9. 299 300**Atomic service API**: This API can be used in atomic services since API version 11. 301 302**System capability**: SystemCapability.ArkUI.ArkUI.Full 303 304**Parameters** 305 306| Name| Type | Mandatory| Description | 307| ------ | ------- | ---- | ------------------------------------------------------------ | 308| value | boolean | Yes | Whether to load the image synchronously. By default, the image is loaded asynchronously. During synchronous loading, the UI thread is blocked and the placeholder image is not displayed.<br>Default value: **false**| 309 310### copyOption<sup>9+</sup> 311 312copyOption(value: CopyOptions) 313 314Whether the image can be copied. When **copyOption** is set to a value other than **CopyOptions.None**, the image can be copied in various manners, such as long pressing, right-clicking, or pressing Ctrl+C. SVG images cannot be copied. 315 316This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 317 318**Widget capability**: This API can be used in ArkTS widgets since API version 9. 319 320**Atomic service API**: This API can be used in atomic services since API version 11. 321 322**System capability**: SystemCapability.ArkUI.ArkUI.Full 323 324**Parameters** 325 326| Name| Type | Mandatory| Description | 327| ------ | ------------------------------------------------ | ---- | --------------------------------------------- | 328| value | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Yes | Specifies whether the image can be copied.<br>Default value: **CopyOptions.None**| 329 330### colorFilter<sup>9+</sup> 331 332colorFilter(value: ColorFilter | DrawingColorFilter) 333 334Sets the color filter for the image. 335 336When this attribute is set, [renderMode](#rendermode) is not effective. 337 338**Widget capability**: This API can be used in ArkTS widgets since API version 9. 339 340**Atomic service API**: This API can be used in atomic services since API version 11. 341 342**System capability**: SystemCapability.ArkUI.ArkUI.Full 343 344**Parameters** 345 346| Name| Type | Mandatory| Description | 347| ------ | --------------------------------------- | ---- | ------------------------------------------------------------ | 348| value | [ColorFilter](ts-types.md#colorfilter9) \| [DrawingColorFilter](../../apis-arkgraphics2d/js-apis-graphics-drawing.md#colorfilter)<sup>12+</sup> | Yes | 1. Color filter of the image. The input parameter is a 4 x 5 RGBA transformation matrix.<br>The first row of the matrix represents a vector value of R (red), the second row represents a vector value of G (green), the third row represents a vector value of B (blue), and the fourth row represents a vector value of A (alpha). The four rows represent different RGBA vector values.<br>If the matrix contains entries of 1 on the diagonal and entries of 0 in other places, the original color of the image is retained.<br> **Calculation rule:**<br>If the input filter matrix is as follows:<br><br>Wherein the color is [R, G, B, A].<br>Then the color after filtering is [R', G', B', A'].<br><br>2. The ColorFilter type of **@ohos.graphics.drawing** can be used as the input parameter since API Version 12.<br>**NOTE**<br>This parameter is not available for SVG images in API version 11 and earlier versions.<br>The DrawingColorfilter type can be used in atomic services since API version 12. The SVG image to set as the source must have the **stroke** attribute.| 349 350### draggable<sup>9+</sup> 351 352draggable(value: boolean) 353 354Specifies whether the image is draggable. This attribute cannot be used together with the [onDragStart](ts-universal-events-drag-drop.md#ondragstart) event. 355 356**Atomic service API**: This API can be used in atomic services since API version 11. 357 358**System capability**: SystemCapability.ArkUI.ArkUI.Full 359 360**Parameters** 361 362| Name| Type | Mandatory| Description | 363| ------ | ------- | ---- | ------------------------------------------------------------ | 364| value | boolean | Yes | Whether the image is draggable. The value **true** means that the image is draggable, and **false** means the opposite.<br>Default value:<br>API version 9 and earlier: **false**<br> Since API version 10: **true**| 365 366### enableAnalyzer<sup>11+</sup> 367 368enableAnalyzer(enable: boolean) 369 370Sets whether to enable the AI analyzer. This attribute cannot be used together with the [overlay](ts-universal-attributes-overlay.md) attribute. If they are set at the same time, the **CustomBuilder** attribute in **overlay** has no effect. This feature depends on device capabilities. 371 372Images to be analyzed must be static, non-vector images. That is, SVG and GIF images cannot be analyzed. [Pixel maps](../../apis-image-kit/js-apis-image.md#pixelmap7) in [RGBA_8888](../../apis-image-kit/js-apis-image.md#pixelmapformat7) format can be passed in for analysis. For details, see [Example 4](#example-4). 373 374The placeholder images (specified by **alt**) cannot be analyzed. An image can be analyzed only when **objectRepeat** is set to **ImageRepeat.NoRepeat** and [obscured](ts-universal-attributes-obscured.md) is disabled. 375 376Analysis is performed based on the complete original image. If the **clip**, **margin**, **borderRadius**, **position**, or **objectFit** attribute is set, the image is not displayed completely. If **renderMode** is used to apply a mask, analysis is still performed based on the complete original image. The **copyOption** attribute does not affect the AI analyzer. 377 378This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 379 380**Atomic service API**: This API can be used in atomic services since API version 12. 381 382**System capability**: SystemCapability.ArkUI.ArkUI.Full 383 384**Parameters** 385 386| Name| Type | Mandatory| Description | 387| ------ | ------- | ---- | ------------------------------------------------------------ | 388| enable | boolean | Yes | Whether to enable the AI analyzer. The value **true** means to enable the AI analyzer.<br>Default value: **false**| 389 390### resizable<sup>11+</sup> 391 392resizable(value: ResizableOptions) 393 394Sets the resizable image options. Resizing is effective for drag previews and placeholder images. 395 396When [ResizableOptions](#resizableoptions11) is set to a valid value, the **objectRepeat** attribute does not take effect. 397 398When the sum of the values of **top** and **bottom** is greater than the source image height, or the sum of the values of **left** and **right** is greater than the source image width, the [ResizableOptions](#resizableoptions11) attribute does not take effect. 399 400This attribute does not take effect when the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 401 402**Atomic service API**: This API can be used in atomic services since API version 12. 403 404**System capability**: SystemCapability.ArkUI.ArkUI.Full 405 406**Parameters** 407 408| Name| Type | Mandatory| Description | 409| ------ | --------------------------------------- | ---- | -------------------------------- | 410| value | [ResizableOptions](#resizableoptions11) | Yes | Resizable image options.| 411 412### privacySensitive<sup>12+</sup> 413 414privacySensitive(supported: boolean) 415 416Sets whether to secure sensitive information on widgets. 417 418**Widget capability**: This API can be used in ArkTS widgets since API version 12. 419 420**Atomic service API**: This API can be used in atomic services since API version 12. 421 422**System capability**: SystemCapability.ArkUI.ArkUI.Full 423 424**Parameters** 425 426| Name | Type | Mandatory| Description | 427| --------- | ------- | ---- | ------------------------ | 428| supported | boolean | Yes | Whether to secure sensitive information on widgets.<br>Default value: **false**.<br>If this parameter is set to **true**, the image is obscured with a translucent background.<br>**NOTE**<br>If this parameter is set to **null**, the image is not obscured.<br>Obscuring requires [widget framework support](./ts-universal-attributes-obscured.md).| 429 430### dynamicRangeMode<sup>12+</sup> 431 432dynamicRangeMode(value: DynamicRangeMode) 433 434Sets the dynamic range of the image to be displayed. 435 436<!--RP1--><!--RP1End--> 437 438**Atomic service API**: This API can be used in atomic services since API version 12. 439 440**System capability**: SystemCapability.ArkUI.ArkUI.Full 441 442**Parameters** 443 444| Name| Type | Mandatory| Description | 445| ------ | --------------------------------------- | ---- | -------------------------------- | 446| value | [DynamicRangeMode](#dynamicrangemode12-1) | Yes | Dynamic range of the image.<br>Default value: **dynamicRangeMode.Standard**| 447 448## ImageContent<sup>12+</sup> 449 450Defines the image content. 451 452| Name | Description | 453| ------ | -------------------------- | 454| EMPTY | Empty image. | 455 456## ImageInterpolation 457 458**Widget capability**: This API can be used in ArkTS widgets since API version 9. 459 460**Atomic service API**: This API can be used in atomic services since API version 11. 461 462| Name | Description | 463| ------ | -------------------------- | 464| None | Nearest neighbor interpolation. | 465| High | Cubic interpolation. This mode produces scaled images of the highest possible quality, but may require more image rendering time.| 466| Medium | MipMap interpolation. | 467| Low | Bilinear interpolation. | 468 469## ImageRenderMode 470 471**Widget capability**: This API can be used in ArkTS widgets since API version 9. 472 473**Atomic service API**: This API can be used in atomic services since API version 11. 474 475| Name | Description | 476| -------- | ------- | 477| Original | Render image pixels as they are in the original source image.| 478| Template | Render image pixels to create a monochrome template image.| 479 480## ResizableOptions<sup>11+</sup> 481 482Defines the resizable image options. 483 484**Atomic service API**: This API can be used in atomic services since API version 12. 485 486| Name | Type | Description | 487| ----- | ------------------------------------- | ---------------------------------------- | 488| slice | [EdgeWidths](#edgewidths) | Edge widths in different directions of a component.<br>**NOTE**<br>This parameter takes effect only when values of **bottom** and **right** are both greater than 0.| 489| lattice<sup>12+</sup> | [DrawingLattice](../../apis-arkgraphics2d/js-apis-graphics-drawing.md#lattice12) | Lattice object, which is used to divide the image by lattice.<br>**NOTE**<br> A lattice object can be created through the **createImageLattice** API of the **@ohos.graphics.drawing** module. The lattices on both even columns and even rows are fixed.<br>This parameter does not take effect for the [backgroundImageResizable](ts-universal-attributes-background.md#backgroundimageresizable12) API.| 490 491## EdgeWidths 492 493**Atomic service API**: This API can be used in atomic services since API version 11. 494 495| Name| Type| Mandatory| Description| 496| --------- |-----------|-----------|-----------| 497| top | [Length](ts-types.md#length) | No | Width of the top edge.<br>Default value: **0**<br>Unit: vp| 498| right | [Length](ts-types.md#length) | No | Width of the right edge.<br>Default value: **0**<br>Unit: vp| 499| bottom | [Length](ts-types.md#length) | No | Width of the bottom edge.<br>Default value: **0**<br>Unit: vp| 500| left | [Length](ts-types.md#length) | No | Width of the left edge.<br>Default value: **0**<br>Unit: vp| 501 502 503 504## DynamicRangeMode<sup>12+</sup> 505 506Describes the dynamic range of the image to be displayed. 507 508**Atomic service API**: This API can be used in atomic services since API version 12. 509 510| Name | Description | 511| ------ | -------------------------- | 512| High | Unrestricted dynamic range, which allows for the maximum brightening of an image. | 513| Constraint | Restricted dynamic range, which brightens an image within certain constraints. | 514| Standard | Standard dynamic range, which does not brighten an image. | 515 516## Events 517 518In addition to the [universal events](ts-universal-events-click.md), the following events are supported. 519 520### onComplete 521 522onComplete(callback: (event?: { width: number, height: number, componentWidth: number, componentHeight: number, loadingStatus: number,contentWidth: number, contentHeight: number, contentOffsetX: number, contentOffsetY: number }) => void) 523 524Triggered when an image is successfully loaded or decoded. The size of the loaded image is returned. 525 526This event is not triggered if the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 527 528**Widget capability**: This API can be used in ArkTS widgets since API version 9. 529 530**Atomic service API**: This API can be used in atomic services since API version 11. 531 532**System capability**: SystemCapability.ArkUI.ArkUI.Full 533 534**Parameters** 535 536| Name | Type | Mandatory| Description | 537| ---------------------------- | ------ | ---- | ------------------------------------------------------------ | 538| width | number | Yes | Width of the image.<br>Unit: pixel | 539| height | number | Yes | Height of the image.<br>Unit: pixel | 540| componentWidth | number | Yes | Width of the component.<br>Unit: pixel | 541| componentHeight | number | Yes | Height of the component.<br>Unit: pixel | 542| loadingStatus | number | Yes | Loading status of the image.<br>**NOTE**<br>If the return value is **0**, the image is successfully loaded. If the return value is **1**, the image is successfully decoded.| 543| contentWidth<sup>10+</sup> | number | Yes | Actual rendered width of the image.<br>Unit: pixel<br>**NOTE**<br>This parameter is valid only when the return value of **loadingStatus** is **1**.| 544| contentHeight<sup>10+</sup> | number | Yes | Actual rendered height of the image.<br>Unit: pixel<br>**NOTE**<br>This parameter is valid only when the return value of **loadingStatus** is **1**.| 545| contentOffsetX<sup>10+</sup> | number | Yes | Offset of the rendered content relative to the component on the x-axis.<br>Unit: pixel<br>**NOTE**<br>This parameter is valid only when the return value of **loadingStatus** is **1**.| 546| contentOffsetY<sup>10+</sup> | number | Yes | Offset of the rendered content relative to the component on the y-axis<br>Unit: pixel<br>**NOTE**<br>This parameter is valid only when the return value of **loadingStatus** is **1**.| 547 548### onError<sup>9+</sup> 549 550onError(callback: ImageErrorCallback) 551 552Triggered when an error occurs during image loading. 553 554This event is not triggered if the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 555 556**Widget capability**: This API can be used in ArkTS widgets since API version 9. 557 558**Atomic service API**: This API can be used in atomic services since API version 11. 559 560**System capability**: SystemCapability.ArkUI.ArkUI.Full 561 562**Parameters** 563 564| Name | Type | Mandatory| Description | 565| -------- | ------------------------------------------ | ---- | -------------------------- | 566| callback | [ImageErrorCallback](#imageerrorcallback9) | Yes | Triggered when an error occurs during image loading.| 567 568### onFinish 569 570onFinish(event: () => void) 571 572Triggered when the animation playback in the loaded SVG image is complete. If the animation is an infinite loop, this callback is not triggered. 573 574Only SVG images are supported. This event is not triggered if the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 575 576**Widget capability**: This API can be used in ArkTS widgets since API version 9. 577 578**Atomic service API**: This API can be used in atomic services since API version 11. 579 580**System capability**: SystemCapability.ArkUI.ArkUI.Full 581 582## ImageErrorCallback<sup>9+</sup> 583 584type ImageErrorCallback = (error: ImageError) => void 585 586Triggered when an error occurs during image loading. 587 588This event is not triggered if the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 589 590**Atomic service API**: This API can be used in atomic services since API version 11. 591 592| Name| Type | Mandatory| Description | 593| ------ | -------------------------- | ---- | ---------------------------------- | 594| error | [ImageError](#imageerror9) | Yes | Return object that triggers the callback for when an error occurs during image loading.| 595 596## ImageError<sup>9+</sup> 597 598Describes the return object that triggers the callback for when an error occurs during image loading. 599 600This event is not triggered if the parameter type of the component is [AnimatedDrawableDescriptor](../js-apis-arkui-drawableDescriptor.md#animateddrawabledescriptor12). 601 602**Atomic service API**: This API can be used in atomic services since API version 11. 603 604| Name | Type | Mandatory| Description | 605| --------------- | ------ | ---- | ------------------------- | 606| componentWidth | number | Yes | Width of the component.<br>Unit: pixel| 607| componentHeight | number | Yes | Height of the component.<br>Unit: pixel| 608| message<sup>10+</sup> | string | Yes | Error information. | 609 610## Example 611 612### Example 1 613 614This example demonstrates how to load images of basic types. 615 616```ts 617@Entry 618@Component 619struct ImageExample1 { 620 build() { 621 Column() { 622 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { 623 Row() { 624 // Load a PNG image. 625 Image($r('app.media.ic_camera_master_ai_leaf')) 626 .width(110).height(110).margin(15) 627 .overlay('png', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 628 // Load a GIF image. 629 Image($r('app.media.loading')) 630 .width(110).height(110).margin(15) 631 .overlay('gif', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 632 } 633 Row() { 634 // Load an SVG image. 635 Image($r('app.media.ic_camera_master_ai_clouded')) 636 .width(110).height(110).margin(15) 637 .overlay('svg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 638 // Load a JPG image. 639 Image($r('app.media.ic_public_favor_filled')) 640 .width(110).height(110).margin(15) 641 .overlay('jpg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 642 } 643 } 644 }.height(320).width(360).padding({ right: 10, top: 10 }) 645 } 646} 647``` 648 649 650 651### Example 2 652 653The default timeout is 5 minutes for loading online images. When using an online image, you are advised to use **alt** to configure a placeholder image displayed during loading. If more flexible network configuration is required, you can use [HTTP](../../../network/http-request.md) to send a network request, and then decode the returned data into a **PixelMap** object in the **Image** component. For details about image development, see [Introduction to Image Kit](../../../media/image/image-overview.md). 654 655The **ohos.permission.INTERNET** permission is required for using online images. For details about how to apply for a permission, see [Declaring Permissions](../../../security/AccessToken/declare-permissions.md). 656 657```ts 658@Entry 659@Component 660struct ImageExample2 { 661 build() { 662 Column({ space: 10 }) { 663 Image("https://www.example.com/xxx.png")// Enter an image URL. 664 .alt($r('app.media.LoadingProgress'))// Use alt to set a placeholder image displayed during image loading. 665 .width(375) 666 .height(300) 667 } 668 } 669} 670``` 671 672 673 674### Example 3 675 676This example shows how to add events to an image. 677 678```ts 679@Entry 680@Component 681struct ImageExample3 { 682 private imageOne: Resource = $r('app.media.earth'); 683 private imageTwo: Resource = $r('app.media.star'); 684 private imageThree: Resource = $r('app.media.moveStar'); 685 @State src: Resource = this.imageOne 686 @State src2: Resource = this.imageThree 687 build(){ 688 Column(){ 689 // Add a click event so that a specific image is loaded upon clicking. 690 Image(this.src) 691 .width(100) 692 .height(100) 693 .onClick(() => { 694 this.src = this.imageTwo 695 }) 696 697 // When the image to be loaded is in SVG format: 698 Image(this.src2) 699 .width(100) 700 .height(100) 701 .onClick(() => { 702 // Load another image when the SVG image has finished its animation. 703 this.src2 = this.imageOne 704 }) 705 }.width('100%').height('100%') 706 } 707} 708``` 709 710 711 712### Example 4 713 714In this example, the AI image analyzer is enabled for pixel maps. 715 716```ts 717import { image } from '@kit.ImageKit' 718 719@Entry 720@Component 721struct ImageExample4 { 722 @State imagePixelMap: image.PixelMap | undefined = undefined 723 private aiController: ImageAnalyzerController = new ImageAnalyzerController() 724 private options: ImageAIOptions = { 725 types: [ImageAnalyzerType.SUBJECT, ImageAnalyzerType.TEXT], 726 aiController: this.aiController 727 } 728 729 async aboutToAppear() { 730 this.imagePixelMap = await this.getPixmapFromMedia($r('app.media.app_icon')) 731 } 732 733 build() { 734 Column() { 735 Image(this.imagePixelMap, this.options) 736 .enableAnalyzer(true) 737 .width(200) 738 .height(200) 739 .margin({bottom:10}) 740 Button('getTypes') 741 .width(80) 742 .height(80) 743 .onClick(() => { 744 this.aiController.getImageAnalyzerSupportTypes() 745 }) 746 } 747 } 748 private async getPixmapFromMedia(resource: Resource) { 749 let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ 750 bundleName: resource.bundleName, 751 moduleName: resource.moduleName, 752 id: resource.id 753 }) 754 let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) 755 let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ 756 desiredPixelFormat: image.PixelMapFormat.RGBA_8888 757 }) 758 await imageSource.release() 759 return createPixelMap 760 } 761} 762``` 763 764 765 766### Example 5 767 768This example shows how to resize an image in different directions. 769 770```ts 771@Entry 772@Component 773struct Index { 774 @State top: number = 40 775 @State bottom: number = 5 776 @State left: number = 40 777 @State right: number = 10 778 779 build() { 780 Column({ space: 5 }) { 781 // Original image effect 782 Image($r("app.media.sky")) 783 .width(200).height(200) 784 .border({ width: 2, color: Color.Pink }) 785 .objectFit(ImageFit.Contain) 786 787 // Set the resizable attribute to resize the image in different directions. 788 Image($r("app.media.sky")) 789 .resizable({ 790 slice: { 791 left: this.left, 792 right: this.right, 793 top: this.top, 794 bottom: this.bottom 795 } 796 }) 797 .width(200) 798 .height(200) 799 .border({ width: 2, color: Color.Pink }) 800 .objectFit(ImageFit.Contain) 801 802 Row() { 803 Button("add top to " + this.top).fontSize(10) 804 .onClick(() => { 805 this.top += 2 806 }) 807 Button("add bottom to " + this.bottom).fontSize(10) 808 .onClick(() => { 809 this.bottom += 2 810 }) 811 } 812 813 Row() { 814 Button("add left to " + this.left).fontSize(10) 815 .onClick(() => { 816 this.left += 2 817 }) 818 Button("add right to " + this.right).fontSize(10) 819 .onClick(() => { 820 this.right += 2 821 }) 822 } 823 824 } 825 .justifyContent(FlexAlign.Start).width('100%').height('100%') 826 } 827} 828``` 829 830 831 832### Example 6 833 834This example plays an animation for the specified pixel map array. 835 836```ts 837import {AnimationOptions, AnimatedDrawableDescriptor} from '@kit.ArkUI' 838import { image } from '@kit.ImageKit' 839 840@Entry 841@Component 842struct ImageExample { 843 pixelmaps: Array<PixelMap> = []; 844 options: AnimationOptions = {duration:2000, iterations:1}; 845 @State animated: AnimatedDrawableDescriptor | undefined = undefined; 846 847 async aboutToAppear() { 848 this.pixelmaps = await this.getPixelMaps(); 849 this.animated = new AnimatedDrawableDescriptor(this.pixelmaps, this.options); 850 } 851 852 build() { 853 Column() { 854 Row() { 855 Image(this.animated) 856 .width('500px').height('500px') 857 .onFinish(() => { 858 console.info("finish") 859 }) 860 }.height('50%') 861 Row() { 862 Button('once').width(100).padding(5).onClick(() => { 863 this.options = {duration:2000, iterations:1}; 864 this.animated = new AnimatedDrawableDescriptor(this.pixelmaps, this.options); 865 }).margin(5) 866 Button('infinite').width(100).padding(5).onClick(() => { 867 this.options = {duration:2000, iterations:-1}; 868 this.animated = new AnimatedDrawableDescriptor(this.pixelmaps, this.options); 869 }).margin(5) 870 } 871 }.width('50%') 872 } 873 874 private async getPixmapListFromMedia(resource: Resource) { 875 let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ 876 bundleName: resource.bundleName, 877 moduleName: resource.moduleName, 878 id: resource.id 879 }) 880 let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) 881 let createPixelMap: Array<image.PixelMap> = await imageSource.createPixelMapList({ 882 desiredPixelFormat: image.PixelMapFormat.RGBA_8888 883 }) 884 await imageSource.release() 885 return createPixelMap 886 } 887 888 private async getPixmapFromMedia(resource: Resource) { 889 let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({ 890 bundleName: resource.bundleName, 891 moduleName: resource.moduleName, 892 id: resource.id 893 }) 894 let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength)) 895 let createPixelMap: image.PixelMap = await imageSource.createPixelMap({ 896 desiredPixelFormat: image.PixelMapFormat.RGBA_8888 897 }) 898 await imageSource.release() 899 return createPixelMap 900 } 901 902 private async getPixelMaps() { 903 let Mypixelmaps:Array<PixelMap> = await this.getPixmapListFromMedia($r('app.media.view'))// A GIF image, when processed, can generate multiple PixelMap instances. 904 Mypixelmaps.push(await this.getPixmapFromMedia($r('app.media.icon'))) // Add an image. 905 return Mypixelmaps; 906 } 907} 908``` 909 910 911 912### Example 7 913 914This example sets the color filter of the image. 915 916```ts 917import { drawing, common2D } from '@kit.ArkGraphics2D'; 918 919@Entry 920@Component 921struct ImageExample3 { 922 private imageOne: Resource = $r('app.media.1'); 923 private imageTwo: Resource = $r('app.media.2'); 924 @State src: Resource = this.imageOne 925 @State src2: Resource = this.imageTwo 926 private ColorFilterMatrix: number[] = [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0] 927 private color: common2D.Color = { alpha: 255, red: 255, green: 0, blue: 0 }; 928 @State DrawingColorFilterFirst: ColorFilter | undefined = undefined 929 @State DrawingColorFilterSecond: ColorFilter | undefined = undefined 930 @State DrawingColorFilterThird: ColorFilter | undefined = undefined 931 932 build() { 933 Column() { 934 Image(this.src) 935 .width(100) 936 .height(100) 937 .colorFilter(this.DrawingColorFilterFirst) 938 .onClick(()=>{ 939 this.DrawingColorFilterFirst = drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN); 940 }) 941 942 Image(this.src2) 943 .width(100) 944 .height(100) 945 .colorFilter(this.DrawingColorFilterSecond) 946 .onClick(()=>{ 947 this.DrawingColorFilterSecond = new ColorFilter(this.ColorFilterMatrix); 948 }) 949 950 // When the image to be loaded is in SVG format: 951 Image($r('app.media.test_self')) 952 .width(110).height(110).margin(15) 953 .colorFilter(this.DrawingColorFilterThird) 954 .onClick(()=>{ 955 this.DrawingColorFilterThird = drawing.ColorFilter.createBlendModeColorFilter(this.color, drawing.BlendMode.SRC_IN); 956 }) 957 } 958 } 959} 960``` 961 962 963### Example 8 964 965This example shows how to use **objectFit**. 966 967```ts 968@Entry 969@Component 970struct ImageExample{ 971 build() { 972 Column() { 973 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { 974 Row() { 975 // Load a PNG image. 976 Image($r('app.media.sky')) 977 .width(110).height(110).margin(15) 978 .overlay('png', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 979 .border({ width: 2, color: Color.Pink }) 980 .objectFit(ImageFit.TOP_START) 981 // Load a GIF image. 982 Image($r('app.media.loading')) 983 .width(110).height(110).margin(15) 984 .overlay('gif', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 985 .border({ width: 2, color: Color.Pink }) 986 .objectFit(ImageFit.BOTTOM_START) 987 } 988 Row() { 989 // Load an SVG image. 990 Image($r('app.media.svg')) 991 .width(110).height(110).margin(15) 992 .overlay('svg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 993 .border({ width: 2, color: Color.Pink }) 994 .objectFit(ImageFit.TOP_END) 995 // Load a JPG image. 996 Image($r('app.media.jpg')) 997 .width(110).height(110).margin(15) 998 .overlay('jpg', { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) 999 .border({ width: 2, color: Color.Pink }) 1000 .objectFit(ImageFit.CENTER) 1001 } 1002 } 1003 }.height(320).width(360).padding({ right: 10, top: 10 }) 1004 } 1005} 1006``` 1007 1008 1009