1# @ohos.multimedia.image (Image Processing)
2
3The **Image** module provides APIs for image processing. You can use the APIs to create a **PixelMap** object with specified properties or read pixels of an image (or even in a region of an image).
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> - Since API version 12, the APIs of this module are supported in ArkTS widgets.
10
11## Modules to Import
12
13```ts
14import { image } from '@kit.ImageKit';
15```
16
17## image.createPicture<sup>13+</sup>
18
19createPicture(mainPixelmap : PixelMap): Picture
20
21Creates a **Picture** object based on a main PixelMap.
22
23**System capability**: SystemCapability.Multimedia.Image.Core
24
25**Parameters**
26
27| Name      | Type               | Mandatory| Description            |
28| ------------ | ------------------- | ---- | ---------------- |
29| mainPixelmap | [PixelMap](#pixelmap7) | Yes  | Main PixelMap.|
30
31**Return value**
32
33| Type              | Description             |
34| ------------------ | ----------------- |
35| [Picture](#picture13) | **Picture** object.|
36
37**Error codes**
38
39For details about the error codes, see [Image Error Codes](errorcode-image.md).
40
41| ID| Error Message                                                    |
42| -------- | ------------------------------------------------------------ |
43| 401      | Parameter error.Possible causes:1.Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
44
45**Example**
46
47```ts
48import { image } from '@kit.ImageKit';
49
50async function CreatePicture() {
51  const context = getContext();
52  const resourceMgr = context.resourceManager;
53  const rawFile = await resourceMgr.getRawFileContent("test.jpg");
54  let ops: image.SourceOptions = {
55    sourceDensity: 98,
56  }
57  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
58  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
59  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
60  if (pictureObj != null) {
61    console.info('Create picture succeeded');
62  } else {
63    console.info('Create picture failed');
64  }
65}
66```
67
68## image.createPictureFromParcel<sup>13+</sup>
69
70createPictureFromParcel(sequence: rpc.MessageSequence): Picture
71
72Creates a **Picture** object from a **MessageSequence** object.
73
74**System capability**: SystemCapability.Multimedia.Image.Core
75
76**Parameters**
77
78| Name  | Type                                                               | Mandatory| Description                                |
79| -------- | ------------------------------------------------------------------- | ---- | ------------------------------------ |
80| sequence | [rpc.MessageSequence](../apis-ipc-kit/js-apis-rpc.md#messagesequence9) | Yes  | **MessageSequence** object that stores the **Picture** information.|
81
82**Return value**
83
84| Type              | Description             |
85| ------------------ | ----------------- |
86| [Picture](#picture13) | **Picture** object.|
87
88**Error codes**
89
90For details about the error codes, see [Image Error Codes](errorcode-image.md).
91
92| ID| Error Message                                                    |
93| -------- | ------------------------------------------------------------ |
94| 401      | Parameter error.Possible causes:1.Mandatory parameters are left unspecified.2.Incorrect parameter types.3.Parameter verification failed. |
95| 62980097 | IPC error.                                                   |
96
97**Example**
98
99```ts
100import { rpc } from '@kit.IPCKit';
101import { BusinessError } from '@kit.BasicServicesKit';
102import { image } from '@kit.ImageKit';
103
104class MySequence implements rpc.Parcelable {
105  picture: image.Picture | null = null;
106  constructor(conPicture: image.Picture) {
107    this.picture = conPicture;
108  }
109  marshalling(messageSequence: rpc.MessageSequence) {
110    if(this.picture != null) {
111      this.picture.marshalling(messageSequence);
112      console.info('Marshalling success !');
113      return true;
114    } else {
115      console.info('Marshalling failed !');
116      return false;
117    }
118  }
119  unmarshalling(messageSequence : rpc.MessageSequence) {
120    this.picture = image.createPictureFromParcel(messageSequence);
121    this.picture.getMainPixelmap().getImageInfo().then((imageInfo : image.ImageInfo) => {
122      console.info('Unmarshalling to get mainPixelmap information height:' + imageInfo.size.height + ' width:' + imageInfo.size.width);
123    }).catch((error: BusinessError) => {
124      console.error('Unmarshalling failed error.code: ${error.code} ,error.message: ${error.message}');
125    });
126    return true;
127  }
128}
129
130async function Marshalling_UnMarshalling() {
131  const context = getContext();
132  const resourceMgr = context.resourceManager;
133  const rawFile = await resourceMgr.getRawFileContent("test.jpg");
134  let ops: image.SourceOptions = {
135    sourceDensity: 98,
136  }
137  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
138  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
139  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
140  if (pictureObj != null) {
141    let parcelable: MySequence = new MySequence(pictureObj);
142    let data: rpc.MessageSequence = rpc.MessageSequence.create();
143    // marshalling
144    data.writeParcelable(parcelable);
145    let ret: MySequence = new MySequence(pictureObj);
146    // unmarshalling
147    data.readParcelable(ret);
148  } else {
149    console.info('PictureObj is null');
150  }
151}
152```
153
154## image.createPixelMap<sup>8+</sup>
155
156createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<PixelMap>
157
158Creates a **PixelMap** object with the default BGRA_8888 format and specified pixel properties. This API uses a promise to return the result.
159
160**System capability**: SystemCapability.Multimedia.Image.Core
161
162**Parameters**
163
164| Name | Type                                            | Mandatory| Description                                                            |
165| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- |
166| colors  | ArrayBuffer                                      | Yes  | Buffer for storing the pixel data. It is used to initialize the pixels of the PixelMap. Before initialization, the pixel format in the buffer must be specified by [InitializationOptions](#initializationoptions8).srcPixelFormat.<br>**NOTE**: The length of the buffer required for storing the pixel data is determined by multiplying the width, height, and the number of bytes per pixel.|
167| options | [InitializationOptions](#initializationoptions8) | Yes  | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
168
169**Return value**
170
171| Type                            | Description                                                                   |
172| -------------------------------- | ----------------------------------------------------------------------- |
173| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.<br>If the size of the created PixelMap exceeds that of the original image, the PixelMap size of the original image is returned.|
174
175**Example**
176
177```ts
178import { BusinessError } from '@kit.BasicServicesKit';
179
180async function CreatePixelMap() {
181  const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
182  let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
183  image.createPixelMap(color, opts).then((pixelMap: image.PixelMap) => {
184    console.info('Succeeded in creating pixelmap.');
185  }).catch((error: BusinessError) => {
186    console.error(`Failed to create pixelmap. code is ${error.code}, message is ${error.message}`);
187  })
188}
189```
190
191## image.createPixelMap<sup>8+</sup>
192
193createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback\<PixelMap>): void
194
195Creates a **PixelMap** object with the default BGRA_8888 format and specified pixel properties. This API uses an asynchronous callback to return the result.
196
197**System capability**: SystemCapability.Multimedia.Image.Core
198
199**Parameters**
200
201| Name  | Type                                            | Mandatory| Description                      |
202| -------- | ------------------------------------------------ | ---- | -------------------------- |
203| colors   | ArrayBuffer                                      | Yes  | Buffer for storing the pixel data. It is used to initialize the pixels of the PixelMap. Before initialization, the pixel format in the buffer must be specified by [InitializationOptions](#initializationoptions8).srcPixelFormat.<br>**NOTE**: The length of the buffer required for storing the pixel data is determined by multiplying the width, height, and the number of bytes per pixel.|
204| options  | [InitializationOptions](#initializationoptions8) | Yes  | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
205| callback | AsyncCallback\<[PixelMap](#pixelmap7)>           | Yes  | Callback used to return the result. If the operation is successful, **err** is undefined and **data** is the **PixelMap** object obtained; otherwise, **err** is an error object.|
206
207**Example**
208
209```ts
210import { BusinessError } from '@kit.BasicServicesKit';
211
212async function CreatePixelMap() {
213  const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
214  let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
215  image.createPixelMap(color, opts, (error: BusinessError, pixelMap: image.PixelMap) => {
216    if(error) {
217      console.error(`Failed to create pixelmap. code is ${error.code}, message is ${error.message}`);
218      return;
219    } else {
220      console.info('Succeeded in creating pixelmap.');
221    }
222  })
223}
224```
225
226## image.createPixelMapFromParcel<sup>11+</sup>
227
228createPixelMapFromParcel(sequence: rpc.MessageSequence): PixelMap
229
230Creates a **PixelMap** object from a **MessageSequence** object.
231
232**System capability**: SystemCapability.Multimedia.Image.Core
233
234**Parameters**
235
236| Name                | Type                                                 | Mandatory| Description                                    |
237| ---------------------- | ----------------------------------------------------- | ---- | ---------------------------------------- |
238| sequence               | [rpc.MessageSequence](../apis-ipc-kit/js-apis-rpc.md#messagesequence9) | Yes  | **MessageSequence** object that stores the **PixelMap** information.     |
239
240**Return value**
241
242| Type                            | Description                 |
243| -------------------------------- | --------------------- |
244| [PixelMap](#pixelmap7) | Returns a **PixelMap** object if the operation is successful; throws an error otherwise.|
245
246**Error codes**
247
248For details about the error codes, see [Image Error Codes](errorcode-image.md).
249
250| ID| Error Message|
251| ------- | --------------------------------------------|
252| 62980096 | Operation failed|
253| 62980097 | IPC error.|
254| 62980115 | Invalid input parameter|
255| 62980105 | Failed to get the data|
256| 62980177 | Abnormal API environment|
257| 62980178 | Failed to create the PixelMap|
258| 62980179 | Abnormal buffer size|
259| 62980180 | FD mapping failed|
260| 62980246 | Failed to read the PixelMap|
261
262**Example**
263
264```ts
265import { image } from '@kit.ImageKit';
266import { rpc } from '@kit.IPCKit';
267import { BusinessError } from '@kit.BasicServicesKit';
268
269class MySequence implements rpc.Parcelable {
270  pixel_map: image.PixelMap;
271  constructor(conPixelmap: image.PixelMap) {
272    this.pixel_map = conPixelmap;
273  }
274  marshalling(messageSequence: rpc.MessageSequence) {
275    this.pixel_map.marshalling(messageSequence);
276    return true;
277  }
278  unmarshalling(messageSequence: rpc.MessageSequence) {
279    try {
280      this.pixel_map = image.createPixelMapFromParcel(messageSequence);
281    } catch(e) {
282      let error = e as BusinessError;
283      console.error(`createPixelMapFromParcel error. code is ${error.code}, message is ${error.message}`);
284      return false;
285    }
286    return true;
287  }
288}
289async function CreatePixelMapFromParcel() {
290  const color: ArrayBuffer = new ArrayBuffer(96);
291  let bufferArr: Uint8Array = new Uint8Array(color);
292  for (let i = 0; i < bufferArr.length; i++) {
293    bufferArr[i] = 0x80;
294  }
295  let opts: image.InitializationOptions = {
296    editable: true,
297    pixelFormat: image.PixelMapFormat.BGRA_8888,
298    size: { height: 4, width: 6 },
299    alphaType: image.AlphaType.UNPREMUL
300  }
301  let pixelMap: image.PixelMap | undefined = undefined;
302  image.createPixelMap(color, opts).then((srcPixelMap: image.PixelMap) => {
303    pixelMap = srcPixelMap;
304  })
305  if (pixelMap != undefined) {
306    // Implement serialization.
307    let parcelable: MySequence = new MySequence(pixelMap);
308    let data: rpc.MessageSequence = rpc.MessageSequence.create();
309    data.writeParcelable(parcelable);
310
311    // Implement deserialization to obtain data through the RPC.
312    let ret: MySequence = new MySequence(pixelMap);
313    data.readParcelable(ret);
314
315    // Obtain the PixelMap object.
316    let unmarshPixelmap = ret.pixel_map;
317  }
318}
319```
320
321## image.createPixelMapFromSurface<sup>11+</sup>
322
323createPixelMapFromSurface(surfaceId: string, region: Region): Promise\<PixelMap>
324
325Creates a **PixelMap** object based on the surface ID and region information. The size of the region is specified by [Region](#region8).size. This API uses a promise to return the result.
326
327> **NOTE**
328>
329> The width and height of [Region](#region8).size must be the same as those of the [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).
330>
331> You need to adjust the width and height of the [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md) when switching the folded state of a foldable device.
332
333**System capability**: SystemCapability.Multimedia.Image.Core
334
335**Parameters**
336
337| Name                | Type                | Mandatory| Description                                    |
338| ---------------------- | -------------       | ---- | ---------------------------------------- |
339| surfaceId              | string              | Yes  | Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).|
340| region                 | [Region](#region8)  | Yes  | Region information.|
341
342**Return value**
343| Type                            | Description                 |
344| -------------------------------- | --------------------- |
345| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|
346
347**Error codes**
348
349For details about the error codes, see [Image Error Codes](errorcode-image.md).
350
351| ID| Error Message|
352| ------- | --------------------------------------------|
353| 62980115 | If the image parameter invalid.|
354| 62980105 | Failed to get the data|
355| 62980178 | Failed to create the PixelMap|
356
357**Example**
358
359```ts
360import { BusinessError } from '@kit.BasicServicesKit';
361
362async function CreatePixelMapFromSurface(surfaceId: string) {
363  let region: image.Region = { x: 0, y: 0, size: { height: 100, width: 100 } };
364  image.createPixelMapFromSurface(surfaceId, region).then(() => {
365    console.info('Succeeded in creating pixelmap from Surface');
366  }).catch((error: BusinessError) => {
367    console.error(`Failed to create pixelmap. code is ${error.code}, message is ${error.message}`);
368  });
369}
370```
371
372## image.createPixelMapFromSurfaceSync<sup>12+</sup>
373
374createPixelMapFromSurfaceSync(surfaceId: string, region: Region): PixelMap
375
376Creates a **PixelMap** object based on the surface ID and region information. This API returns the result synchronously. The size of the region is specified by [Region](#region8).size.
377
378> **NOTE**
379>
380> The width and height of [Region](#region8).size must be the same as those of the [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).
381>
382> You need to adjust the width and height of the [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md) when switching the folded state of a foldable device.
383
384**System capability**: SystemCapability.Multimedia.Image.Core
385
386**Parameters**
387
388| Name                | Type                | Mandatory| Description                                    |
389| ---------------------- | -------------       | ---- | ---------------------------------------- |
390| surfaceId              | string              | Yes  | Surface ID, which is obtained from [XComponent](../apis-arkui/arkui-ts/ts-basic-components-xcomponent.md).|
391| region                 | [Region](#region8)  | Yes  | Region information.|
392
393**Return value**
394| Type                            | Description                 |
395| -------------------------------- | --------------------- |
396| [PixelMap](#pixelmap7) | Returns a **PixelMap** object if the operation is successful; throws an error otherwise.|
397
398**Error codes**
399
400For details about the error codes, see [Image Error Codes](errorcode-image.md).
401
402| ID| Error Message|
403| ------- | --------------------------------------------|
404|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed|
405| 62980105 | Failed to get the data|
406| 62980178 | Failed to create the PixelMap|
407
408**Example**
409
410```ts
411import { BusinessError } from '@kit.BasicServicesKit';
412
413async function Demo(surfaceId: string) {
414  let region: image.Region = { x: 0, y: 0, size: { height: 100, width: 100 } };
415  let pixelMap : image.PixelMap = image.createPixelMapFromSurfaceSync(surfaceId, region);
416  return pixelMap;
417}
418```
419
420## image.createPixelMapSync<sup>12+</sup>
421
422createPixelMapSync(colors: ArrayBuffer, options: InitializationOptions): PixelMap
423
424Creates a **PixelMap** object with the default BGRA_8888 format and specified pixel properties. This API returns the result synchronously.
425
426**System capability**: SystemCapability.Multimedia.Image.Core
427
428**Parameters**
429
430| Name | Type                                            | Mandatory| Description                                                            |
431| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- |
432| colors  | ArrayBuffer                                      | Yes  | Buffer for storing the pixel data. It is used to initialize the pixels of the PixelMap. Before initialization, the pixel format in the buffer must be specified by [InitializationOptions](#initializationoptions8).srcPixelFormat.<br>**NOTE**: The length of the buffer required for storing the pixel data is determined by multiplying the width, height, and the number of bytes per pixel.|
433| options | [InitializationOptions](#initializationoptions8) | Yes  | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
434
435**Return value**
436| Type                            | Description                 |
437| -------------------------------- | --------------------- |
438| [PixelMap](#pixelmap7) | Returns a **PixelMap** object if the operation is successful; throws an error otherwise.|
439
440**Error codes**
441
442For details about the error codes, see [Image Error Codes](errorcode-image.md).
443
444| ID| Error Message|
445| ------- | --------------------------------------------|
446|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed|
447
448**Example**
449
450```ts
451import { BusinessError } from '@kit.BasicServicesKit';
452
453async function CreatePixelMapSync() {
454  const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
455  let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
456  let pixelMap : image.PixelMap = image.createPixelMapSync(color, opts);
457  return pixelMap;
458}
459```
460
461## image.createPixelMapSync<sup>12+</sup>
462
463createPixelMapSync(options: InitializationOptions): PixelMap
464
465Creates a **PixelMap** object with the specified pixel properties. This API returns the result synchronously.
466
467**System capability**: SystemCapability.Multimedia.Image.Core
468
469**Parameters**
470
471| Name | Type                                            | Mandatory| Description                                                            |
472| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- |
473| options | [InitializationOptions](#initializationoptions8) | Yes  | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
474
475**Return value**
476| Type                            | Description                 |
477| -------------------------------- | --------------------- |
478| [PixelMap](#pixelmap7) | Returns a **PixelMap** object if the operation is successful; throws an error otherwise.|
479
480**Error codes**
481
482For details about the error codes, see [Image Error Codes](errorcode-image.md).
483
484| ID| Error Message|
485| ------- | --------------------------------------------|
486|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed|
487
488**Example**
489
490```ts
491import { BusinessError } from '@kit.BasicServicesKit';
492
493async function CreatePixelMapSync() {
494  let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
495  let pixelMap : image.PixelMap = image.createPixelMapSync(opts);
496  return pixelMap;
497}
498```
499
500## image.createPremultipliedPixelMap<sup>12+</sup>
501
502createPremultipliedPixelMap(src: PixelMap, dst: PixelMap, callback: AsyncCallback\<void>): void
503
504Converts a non-premultiplied alpha of a PixelMap to a premultiplied one and stores the converted data to a target PixelMap. This API uses an asynchronous callback to return the result.
505
506**System capability**: SystemCapability.Multimedia.Image.Core
507
508**Parameters**
509
510| Name  | Type                                            | Mandatory| Description                      |
511| -------- | ------------------------------------------------ | ---- | -------------------------- |
512| src | [PixelMap](#pixelmap7) | Yes  | Source **PixelMap** object.|
513| dst | [PixelMap](#pixelmap7) | Yes  | Target **PixelMap** object.|
514|callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
515
516**Error codes**
517
518For details about the error codes, see [Image Error Codes](errorcode-image.md).
519
520| ID| Error Message|
521| ------- | --------------------------------------------|
522|  401          | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed|
523|  62980103     | The image data is not supported |
524|  62980246      | Failed to read the pixelMap |
525|  62980248     | Pixelmap not allow modify |
526
527**Example**
528
529```ts
530import { BusinessError } from '@kit.BasicServicesKit';
531
532async function CreatePremultipliedPixelMap() {
533  const color: ArrayBuffer = new ArrayBuffer(16); // 16 is the size of the pixel buffer to create. The value is calculated as follows: height * width * 4.
534  let bufferArr = new Uint8Array(color);
535  for (let i = 0; i < bufferArr.length; i += 4) {
536    bufferArr[i] = 255;
537    bufferArr[i+1] = 255;
538    bufferArr[i+2] = 122;
539    bufferArr[i+3] = 122;
540  }
541  let optsForUnpre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.UNPREMUL}
542  let srcPixelmap = image.createPixelMapSync(color, optsForUnpre);
543  let optsForPre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.PREMUL}
544  let dstPixelMap = image.createPixelMapSync(optsForPre);
545  image.createPremultipliedPixelMap(srcPixelmap, dstPixelMap, (error: BusinessError) => {
546    if(error) {
547      console.error(`Failed to convert pixelmap. code is ${error.code}, message is ${error.message}`);
548      return;
549    } else {
550      console.info('Succeeded in converting pixelmap.');
551    }
552  })
553}
554```
555
556## image.createPremultipliedPixelMap<sup>12+</sup>
557
558createPremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise\<void>
559
560Converts a non-premultiplied alpha of a PixelMap to a premultiplied one and stores the converted data to a target PixelMap. This API uses a promise to return the result.
561
562**System capability**: SystemCapability.Multimedia.Image.Core
563
564**Parameters**
565
566| Name  | Type                                            | Mandatory| Description                      |
567| -------- | ------------------------------------------------ | ---- | -------------------------- |
568| src | [PixelMap](#pixelmap7) | Yes  | Source **PixelMap** object.|
569| dst | [PixelMap](#pixelmap7) | Yes  | Target **PixelMap** object.|
570
571**Return value**
572
573| Type                            | Description                                                                   |
574| -------------------------------- | ----------------------------------------------------------------------- |
575| Promise\<void> | Promise that returns no value.|
576
577**Error codes**
578
579For details about the error codes, see [Image Error Codes](errorcode-image.md).
580
581| ID| Error Message|
582| ------- | --------------------------------------------|
583|  401          | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed|
584|  62980103     | The image data is not supported |
585|  62980246      | Failed to read the pixelMap |
586|  62980248     | Pixelmap not allow modify |
587
588**Example**
589
590```ts
591import { BusinessError } from '@kit.BasicServicesKit';
592
593async function CreatePremultipliedPixelMap() {
594  const color: ArrayBuffer = new ArrayBuffer(16); // 16 is the size of the pixel buffer to create. The value is calculated as follows: height * width * 4.
595  let bufferArr = new Uint8Array(color);
596  for (let i = 0; i < bufferArr.length; i += 4) {
597    bufferArr[i] = 255;
598    bufferArr[i+1] = 255;
599    bufferArr[i+2] = 122;
600    bufferArr[i+3] = 122;
601  }
602  let optsForUnpre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.UNPREMUL}
603  let srcPixelmap = image.createPixelMapSync(color, optsForUnpre);
604  let optsForPre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.PREMUL}
605  let dstPixelMap = image.createPixelMapSync(optsForPre);
606  image.createPremultipliedPixelMap(srcPixelmap, dstPixelMap).then(() => {
607    console.info('Succeeded in converting pixelmap.');
608  }).catch((error: BusinessError) => {
609    console.error(`Failed to convert pixelmap. code is ${error.code}, message is ${error.message}`);
610  })
611}
612```
613
614## image.createUnpremultipliedPixelMap<sup>12+</sup>
615
616createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap, callback: AsyncCallback\<void>): void
617
618Converts a premultiplied alpha of a PixelMap to a non-premultiplied one and stores the converted data to a target PixelMap. This API uses an asynchronous callback to return the result.
619
620**System capability**: SystemCapability.Multimedia.Image.Core
621
622**Parameters**
623
624| Name  | Type                                            | Mandatory| Description                      |
625| -------- | ------------------------------------------------ | ---- | -------------------------- |
626| src | [PixelMap](#pixelmap7) | Yes  | Source **PixelMap** object.|
627| dst | [PixelMap](#pixelmap7) | Yes  | Target **PixelMap** object.|
628|callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
629
630**Error codes**
631
632For details about the error codes, see [Image Error Codes](errorcode-image.md).
633
634| ID| Error Message|
635| ------- | --------------------------------------------|
636|  401          | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed|
637|  62980103     | The image data is not supported |
638|  62980246      | Failed to read the pixelMap |
639|  62980248     | Pixelmap not allow modify |
640
641**Example**
642
643```ts
644import { BusinessError } from '@kit.BasicServicesKit';
645
646async function CreateUnpremultipliedPixelMap() {
647  const color: ArrayBuffer = new ArrayBuffer(16); // 16 is the size of the pixel buffer to create. The value is calculated as follows: height * width * 4.
648  let bufferArr = new Uint8Array(color);
649  for (let i = 0; i < bufferArr.length; i += 4) {
650    bufferArr[i] = 255;
651    bufferArr[i+1] = 255;
652    bufferArr[i+2] = 122;
653    bufferArr[i+3] = 122;
654  }
655  let optsForPre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.PREMUL}
656  let srcPixelmap = image.createPixelMapSync(color, optsForPre);
657  let optsForUnpre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.UNPREMUL}
658  let dstPixelMap = image.createPixelMapSync(optsForUnpre);
659  image.createUnpremultipliedPixelMap(srcPixelmap, dstPixelMap, (error: BusinessError) => {
660    if(error) {
661      console.error(`Failed to convert pixelmap. code is ${error.code}, message is ${error.message}`);
662      return;
663    } else {
664      console.info('Succeeded in converting pixelmap.');
665    }
666  })
667}
668```
669
670## image.createUnpremultipliedPixelMap<sup>12+</sup>
671
672createUnpremultipliedPixelMap(src: PixelMap, dst: PixelMap): Promise\<void>
673
674Converts a premultiplied alpha of a PixelMap to a non-premultiplied one and stores the converted data to a target PixelMap. This API uses a promise to return the result.
675
676**System capability**: SystemCapability.Multimedia.Image.Core
677
678**Parameters**
679
680| Name | Type                                            | Mandatory| Description                                                            |
681| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- |
682| src | [PixelMap](#pixelmap7) | Yes  | Source **PixelMap** object.|
683| dst | [PixelMap](#pixelmap7) | Yes  | Target **PixelMap** object.|
684
685**Return value**
686
687| Type                            | Description                                                                   |
688| -------------------------------- | ----------------------------------------------------------------------- |
689| Promise\<void> |  Promise that returns no value.|
690
691**Error codes**
692
693For details about the error codes, see [Image Error Codes](errorcode-image.md).
694
695| ID| Error Message|
696| ------- | --------------------------------------------|
697|  401          | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed|
698|  62980103    | The image data is not supported |
699|  62980246    | Failed to read the pixelMap. |
700|  62980248    | Pixelmap not allow modify. |
701
702**Example**
703
704```ts
705import { BusinessError } from '@kit.BasicServicesKit';
706
707async function CreateUnpremultipliedPixelMap() {
708  const color: ArrayBuffer = new ArrayBuffer(16); // 16 is the size of the pixel buffer to create. The value is calculated as follows: height * width * 4.
709  let bufferArr = new Uint8Array(color);
710  for (let i = 0; i < bufferArr.length; i += 4) {
711    bufferArr[i] = 255;
712    bufferArr[i+1] = 255;
713    bufferArr[i+2] = 122;
714    bufferArr[i+3] = 122;
715  }
716  let optsForPre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.PREMUL}
717  let srcPixelmap = image.createPixelMapSync(color, optsForPre);
718  let optsForUnpre: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 2, width: 2 } , alphaType: image.AlphaType.UNPREMUL}
719  let dstPixelMap = image.createPixelMapSync(optsForUnpre);
720  image.createUnpremultipliedPixelMap(srcPixelmap, dstPixelMap).then(() => {
721    console.info('Succeeded in converting pixelmap.');
722  }).catch((error: BusinessError) => {
723    console.error(`Failed to convert pixelmap. code is ${error.code}, message is ${error.message}`);
724  })
725}
726```
727
728
729## Picture<sup>13+</sup>
730
731An image that contains special information can be decoded into a picture object, which generally contains the main picture, auxiliary picture, and metadata. The main picture contains most information about the image and is mainly used to render the image. The auxiliary picture is used to store data related to but different from the main picture, revealing more comprehensive details. The metadata is generally used to store information about the image file. The picture object class is used to read or write picture objects. Before calling any API in **Picture**, you must use [createPicture](#imagecreatepicture13) to create a **Picture** object.
732
733### Properties
734
735**System capability**: SystemCapability.Multimedia.Image.Core
736
737### getMainPixelmap<sup>13+</sup>
738
739getMainPixelmap(): PixelMap
740
741Obtains the **PixelMap** object of the main picture. This API returns the result synchronously.
742
743**System capability**: SystemCapability.Multimedia.Image.Core
744
745**Return value**
746
747| Type               | Description                  |
748| ------------------- | ---------------------- |
749| [PixelMap](#pixelmap7) | **PixelMap** object.|
750
751**Example**
752
753```ts
754import { BusinessError } from '@kit.BasicServicesKit';
755import { image } from '@kit.ImageKit';
756
757async function GetMainPixelmap() {
758  let funcName = "getMainPixelmap";
759  if (pictureObj != null) {
760    let mainPixelmap: image.PixelMap = pictureObj.getMainPixelmap();
761    if (mainPixelmap != null) {
762      mainPixelmap.getImageInfo().then((imageInfo: image.ImageInfo) => {
763        if (imageInfo != null) {
764          console.info('GetMainPixelmap information height:' + imageInfo.size.height + ' width:' + imageInfo.size.width);
765        }
766      }).catch((error: BusinessError) => {
767        console.error(funcName, 'Failed error.code: ${error.code} ,error.message: ${error.message}');
768      });
769    }
770  } else {
771    console.info('PictureObj is null');
772  }
773}
774```
775
776### getHdrComposedPixelmap<sup>13+</sup>
777
778getHdrComposedPixelmap(): Promise\<PixelMap>
779
780Generates an HDR image and obtains its **PixelMap** object. This API uses a promise to return the result.
781
782**System capability**: SystemCapability.Multimedia.Image.Core
783
784**Return value**
785
786| Type                         | Description                       |
787| ----------------------------- | --------------------------- |
788| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|
789
790**Error codes**
791
792For details about the error codes, see [Image Error Codes](errorcode-image.md).
793
794| ID| Error Message              |
795| -------- | ---------------------- |
796| 7600901  | Unknown error.         |
797| 7600201  | Unsupported operation. |
798
799**Example**
800
801```ts
802import { BusinessError } from '@kit.BasicServicesKit';
803import { image } from '@kit.ImageKit';
804
805async function GetHdrComposedPixelmap() {
806  let funcName = "getHdrComposedPixelmap";
807  if (pictureObj != null) { // An HDR image is contained.
808    let hdrComposedPixelmap: image.PixelMap = await pictureObj.getHdrComposedPixelmap();
809    if (hdrComposedPixelmap != null) {
810      hdrComposedPixelmap.getImageInfo().then((imageInfo: image.ImageInfo) => {
811        if (imageInfo != null) {
812          console.info('GetHdrComposedPixelmap information height:' + imageInfo.size.height + ' width:' + imageInfo.size.width);
813        }
814      }).catch((error: BusinessError) => {
815        console.error(funcName, 'Failed error.code: ${error.code} ,error.message: ${error.message}');
816      });
817    }
818  } else {
819    console.info('PictureObj is null');
820  }
821}
822```
823
824### getGainmapPixelmap<sup>13+</sup>
825
826getGainmapPixelmap(): PixelMap | null
827
828Obtains the **PixelMap** object of the gain map.
829
830**System capability**: SystemCapability.Multimedia.Image.Core
831
832**Return value**
833
834| Type                     | Description                                  |
835| ------------------------- | -------------------------------------- |
836| [PixelMap](#pixelmap7) \| null | **PixelMap** object obtained. If there is no **PixelMap** object, null is returned.|
837
838**Example**
839
840```ts
841import { BusinessError } from '@kit.BasicServicesKit';
842import { image } from '@kit.ImageKit';
843
844async function GetGainmapPixelmap() {
845  let funcName = "getGainmapPixelmap";
846  if (pictureObj != null) { // A gain map is contained.
847    let gainPixelmap: image.PixelMap | null = pictureObj.getGainmapPixelmap();
848    if (gainPixelmap != null) {
849      gainPixelmap.getImageInfo().then((imageInfo: image.ImageInfo) => {
850        if (imageInfo != null) {
851          console.info('GetGainmapPixelmap information height:' + imageInfo.size.height + ' width:' + imageInfo.size.width);
852        } else {
853          console.info('GainPixelmap is null');
854        }
855      }).catch((error: BusinessError) => {
856        console.error(funcName, 'Failed error.code: ${error.code} ,error.message: ${error.message}');
857      });
858    } else {
859      console.info('GainPixelmap is null');
860    }
861  } else {
862    console.info('PictureObj is null');
863  }
864}
865```
866
867### setAuxiliaryPicture<sup>13+</sup>
868
869setAuxiliaryPicture(type: AuxiliaryPictureType, auxiliaryPicture: AuxiliaryPicture): void
870
871Sets an auxiliary picture.
872
873**System capability**: SystemCapability.Multimedia.Image.Core
874
875**Parameters**
876
877| Name          | Type                | Mandatory| Description        |
878| ---------------- | -------------------- | ---- | ------------ |
879| type             | [AuxiliaryPictureType](#auxiliarypicturetype13) | Yes  | Type of the auxiliary picture.|
880| auxiliaryPicture | [AuxiliaryPicture](#auxiliarypicture13)     | Yes  | **AuxiliaryPicture** object.|
881
882**Error codes**
883
884For details about the error codes, see [Image Error Codes](errorcode-image.md).
885
886| ID| Error Message                                                    |
887| -------- | ------------------------------------------------------------ |
888| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
889
890**Example**
891
892```ts
893import { image } from '@kit.ImageKit';
894
895async function SetAuxiliaryPicture() {
896  const context = getContext();
897  const resourceMgr = context.resourceManager;
898  const rawFile = await resourceMgr.getRawFileContent("hdr.jpg"); // Support for HDR images is required.
899  let ops: image.SourceOptions = {
900    sourceDensity: 98,
901  }
902  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
903  let pixelMap: image.PixelMap = await imageSource.createPixelMap();
904  let auxPicture: image.Picture = image.createPicture(pixelMap);
905  if (auxPicture != null) {
906    console.info('Create picture succeeded');
907  } else {
908    console.info('Create picture failed');
909  }
910
911  if (pictureObj != null) {
912    let type: image.AuxiliaryPictureType = image.AuxiliaryPictureType.GAINMAP;
913    let auxPictureObj: image.AuxiliaryPicture | null = await auxPicture.getAuxiliaryPicture(type);
914    if (auxPictureObj != null) {
915      pictureObj.setAuxiliaryPicture(type, auxPictureObj);
916    }
917  }
918}
919```
920
921### getAuxiliaryPicture<sup>13+</sup>
922
923getAuxiliaryPicture(type: AuxiliaryPictureType): AuxiliaryPicture | null
924
925Obtains an auxiliary picture by type.
926
927**System capability**: SystemCapability.Multimedia.Image.Core
928
929**Parameters**
930
931| Name| Type                | Mandatory| Description        |
932| ------ | -------------------- | ---- | ------------ |
933| type   | [AuxiliaryPictureType](#auxiliarypicturetype13) | Yes  | Type of the auxiliary picture.|
934
935**Return value**
936
937| Type                  | Description                                          |
938| ---------------------- | ---------------------------------------------- |
939| [AuxiliaryPicture](#auxiliarypicture13) \| null | **AuxiliaryPicture** object. If there is no **AuxiliaryPicture** object, null is returned.|
940
941**Error codes**
942
943For details about the error codes, see [Image Error Codes](errorcode-image.md).
944
945| ID| Error Message                                                    |
946| -------- | ------------------------------------------------------------ |
947| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
948
949**Example**
950
951```ts
952import { image } from '@kit.ImageKit';
953
954async function GetAuxiliaryPicture() {
955  if (pictureObj != null) {
956    let type: image.AuxiliaryPictureType = image.AuxiliaryPictureType.GAINMAP;
957    let auxPictureObj: image.AuxiliaryPicture | null = pictureObj.getAuxiliaryPicture(type);
958  }
959}
960```
961
962### setMetadata<sup>13+</sup>
963
964setMetadata(metadataType: MetadataType, metadata: Metadata): Promise\<void>
965
966Sets the metadata for this **Picture** object.
967
968**System capability**: SystemCapability.Multimedia.Image.Core
969
970**Parameters**
971
972| Name      | Type        | Mandatory| Description        |
973| ------------ | ------------ | ---- | ------------ |
974| metadataType | [MetadataType](#metadatatype13) | Yes  | Metadata type.|
975| metadata     | [Metadata](#metadata13)     | Yes  | **Metadata** object.|
976
977**Return value**
978
979| Type          | Description                                  |
980| -------------- | -------------------------------------- |
981| Promise\<void> | Promise that returns no value.|
982
983**Error codes**
984
985For details about the error codes, see [Image Error Codes](errorcode-image.md).
986
987| ID| Error Message                                                    |
988| -------- | ------------------------------------------------------------ |
989| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
990| 7600202  | Unsupported metadata. Possible causes: Unsupported metadata type. |
991
992**Example**
993
994```ts
995import { BusinessError } from '@kit.BasicServicesKit';
996import { image } from '@kit.ImageKit';
997
998async function SetPictureObjMetadata() {
999  const exifContext = getContext();
1000  const exifResourceMgr = exifContext.resourceManager;
1001  const exifRawFile = await exifResourceMgr.getRawFileContent("exif.jpg"); // The image contains EXIF metadata.
1002  let exifOps: image.SourceOptions = {
1003    sourceDensity: 98,
1004  }
1005  let exifImageSource: image.ImageSource = image.createImageSource(exifRawFile.buffer as ArrayBuffer, exifOps);
1006  let exifCommodityPixelMap: image.PixelMap = await exifImageSource.createPixelMap();
1007  let exifPictureObj: image.Picture = image.createPicture(exifCommodityPixelMap);
1008  if (exifPictureObj != null) {
1009    console.info('Create picture succeeded');
1010  } else {
1011    console.info('Create picture failed');
1012  }
1013
1014  if (pictureObj != null) {
1015    let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
1016    let exifMetaData: image.Metadata = await exifPictureObj.getMetadata(metadataType);
1017    pictureObj.setMetadata(metadataType, exifMetaData).then(() => {
1018      console.info('Set metadata success');
1019    }).catch((error: BusinessError) => {
1020      console.error('Failed to set metadata. error.code: ' +JSON.stringify(error.code) + ' ,error.message:' + JSON.stringify(error.message));
1021    });
1022  } else {
1023    console.info('PictureObj is null');
1024  }
1025}
1026```
1027
1028### getMetadata<sup>13+</sup>
1029
1030getMetadata(metadataType: MetadataType): Promise\<Metadata>
1031
1032Obtains the metadata of this **Picture** object.
1033
1034**System capability**: SystemCapability.Multimedia.Image.Core
1035
1036**Parameters**
1037
1038| Name      | Type        | Mandatory| Description        |
1039| ------------ | ------------ | ---- | ------------ |
1040| metadataType | [MetadataType](#metadatatype13) | Yes  | Metadata type.|
1041
1042**Return value**
1043
1044| Type              | Description                     |
1045| ------------------ | ------------------------- |
1046| Promise\<[Metadata](#metadata13)> | Promise used to return the metadata.|
1047
1048**Error codes**
1049
1050For details about the error codes, see [Image Error Codes](errorcode-image.md).
1051
1052| ID| Error Message                                                    |
1053| -------- | ------------------------------------------------------------ |
1054| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
1055| 7600202  | Unsupported metadata. Possible causes: Unsupported metadata type. |
1056
1057**Example**
1058
1059```ts
1060import { image } from '@kit.ImageKit';
1061
1062async function GetPictureObjMetadataProperties() {
1063  if (pictureObj != null) {
1064    let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
1065    let pictureObjMetaData: image.Metadata = await pictureObj.getMetadata(metadataType);
1066    if (pictureObjMetaData != null) {
1067      console.info('get picture metadata success');
1068    } else {
1069      console.info('get picture metadata is failed');
1070    }
1071  } else {
1072    console.info(" pictureObj is null");
1073  }
1074}
1075```
1076
1077### marshalling<sup>13+</sup>
1078
1079marshalling(sequence: rpc.MessageSequence): void
1080
1081Marshals this **Picture** object and writes it to a **MessageSequence** object.
1082
1083**System capability**: SystemCapability.Multimedia.Image.Core
1084
1085**Parameters**
1086
1087| Name  | Type                                                               | Mandatory| Description                     |
1088| -------- | ------------------------------------------------------------------- | ---- | ------------------------- |
1089| sequence | [rpc.MessageSequence](../apis-ipc-kit/js-apis-rpc.md#messagesequence9) | Yes  | **MessageSequence** object.|
1090
1091**Error codes**
1092
1093For details about the error codes, see [Image Error Codes](errorcode-image.md).
1094
1095| ID| Error Message                                                    |
1096| -------- | ------------------------------------------------------------ |
1097| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
1098| 62980097 | IPC error.                                                   |
1099
1100**Example**
1101
1102```ts
1103import { BusinessError } from '@kit.BasicServicesKit';
1104import { image } from '@kit.ImageKit';
1105import { rpc } from '@kit.IPCKit';
1106
1107class MySequence implements rpc.Parcelable {
1108  picture: image.Picture | null = null;
1109  constructor(conPicture: image.Picture) {
1110    this.picture = conPicture;
1111  }
1112  marshalling(messageSequence: rpc.MessageSequence) {
1113    if(this.picture != null) {
1114      this.picture.marshalling(messageSequence);
1115      console.info('Marshalling success !');
1116      return true;
1117    } else {
1118      console.info('Marshalling failed !');
1119      return false;
1120    }
1121  }
1122  unmarshalling(messageSequence : rpc.MessageSequence) {
1123    this.picture = image.createPictureFromParcel(messageSequence);
1124    this.picture.getMainPixelmap().getImageInfo().then((imageInfo : image.ImageInfo) => {
1125      console.info('Unmarshalling to get mainPixelmap information height:' + imageInfo.size.height + ' width:' + imageInfo.size.width);
1126    }).catch((error: BusinessError) => {
1127      console.error('Unmarshalling failed error.code: ${error.code} ,error.message: ${error.message}');
1128    });
1129    return true;
1130  }
1131}
1132
1133async function Marshalling_UnMarshalling() {
1134  if (pictureObj != null) {
1135    let parcelable: MySequence = new MySequence(pictureObj);
1136    let data: rpc.MessageSequence = rpc.MessageSequence.create();
1137    // marshalling
1138    data.writeParcelable(parcelable);
1139    let ret: MySequence = new MySequence(pictureObj);
1140    // unmarshalling
1141    data.readParcelable(ret);
1142  } else {
1143    console.info('PictureObj is null');
1144  }
1145}
1146```
1147
1148### release<sup>13+</sup>
1149
1150release(): void
1151
1152Releases this **Picture** object.
1153
1154**System capability**: SystemCapability.Multimedia.Image.Core
1155
1156**Example**
1157
1158```ts
1159import { image } from '@kit.ImageKit';
1160
1161async function Release() {
1162  let funcName = "Release";
1163  if (pictureObj != null) {
1164    pictureObj.release();
1165    if (pictureObj.getMainPixelmap() == null) {
1166      console.info(funcName, 'Success !');
1167    } else {
1168      console.info(funcName, 'Failed !');
1169    }
1170  } else {
1171    console.info('PictureObj is null');
1172  }
1173}
1174```
1175
1176## PixelMap<sup>7+</sup>
1177
1178Provides APIs to read or write image data and obtain image information. Before calling any API in **PixelMap**, you must use [createPixelMap](#imagecreatepixelmap8) to create a **PixelMap** object. Currently, the maximum size of a serialized PixelMap is 128 MB. A larger size will cause a display failure. The size is calculated as follows: Width * Height * Number of bytes occupied by each pixel.
1179
1180Since API version 11, **PixelMap** supports cross-thread calls through workers. If a **PixelMap** object is invoked by another thread through [Worker](../apis-arkts/js-apis-worker.md), all APIs of the **PixelMap** object cannot be called in the original thread. Otherwise, error 501 is reported, indicating that the server cannot complete the request.
1181
1182Before calling any API in **PixelMap**, you must use [image.createPixelMap](#imagecreatepixelmap8) to create a **PixelMap** object.
1183
1184### Properties
1185
1186**System capability**: SystemCapability.Multimedia.Image.Core
1187
1188| Name             | Type   | Readable| Writable| Description                      |
1189| -----------------| ------- | ---- | ---- | -------------------------- |
1190| isEditable        | boolean | Yes  | No  | Whether the pixels of an image are editable.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
1191| isStrideAlignment<sup>11+</sup> | boolean | Yes  | No  | Whether the image memory is the DMA memory.|
1192
1193### readPixelsToBuffer<sup>7+</sup>
1194
1195readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
1196
1197Reads the pixels of this **PixelMap** object based on the PixelMap's pixel format and writes the data to the buffer. This API uses a promise to return the result.
1198
1199**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1200
1201**Atomic service API**: This API can be used in atomic services since API version 11.
1202
1203**System capability**: SystemCapability.Multimedia.Image.Core
1204
1205**Parameters**
1206
1207| Name| Type       | Mandatory| Description                                                                                                 |
1208| ------ | ----------- | ---- | ----------------------------------------------------------------------------------------------------- |
1209| dst    | ArrayBuffer | Yes  | Buffer to which the pixels will be written. The buffer size is obtained by calling [getPixelBytesNumber](#getpixelbytesnumber7).|
1210
1211**Return value**
1212
1213| Type          | Description                                           |
1214| -------------- | ----------------------------------------------- |
1215| Promise\<void> | Promise that returns no value. |
1216
1217**Example**
1218
1219```ts
1220import { BusinessError } from '@kit.BasicServicesKit';
1221
1222async function ReadPixelsToBuffer() {
1223  const readBuffer: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
1224  if (pixelMap != undefined) {
1225    pixelMap.readPixelsToBuffer(readBuffer).then(() => {
1226      console.info('Succeeded in reading image pixel data.'); // Called if the condition is met.
1227    }).catch((error: BusinessError) => {
1228      console.error(`Failed to read image pixel data. code is ${error.code}, message is ${error.message}`); // Called if no condition is met.
1229    })
1230  }
1231}
1232```
1233
1234### readPixelsToBuffer<sup>7+</sup>
1235
1236readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
1237
1238Reads the pixels of this **PixelMap** object based on the PixelMap's pixel format and writes the data to the buffer. This API uses an asynchronous callback to return the result.
1239
1240**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1241
1242**Atomic service API**: This API can be used in atomic services since API version 11.
1243
1244**System capability**: SystemCapability.Multimedia.Image.Core
1245
1246**Parameters**
1247
1248| Name  | Type                | Mandatory| Description                                                                                                 |
1249| -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- |
1250| dst      | ArrayBuffer          | Yes  | Buffer to which the pixels will be written. The buffer size is obtained by calling [getPixelBytesNumber](#getpixelbytesnumber7).|
1251| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
1252
1253**Example**
1254
1255```ts
1256import { BusinessError } from '@kit.BasicServicesKit';
1257
1258async function ReadPixelsToBuffer() {
1259  const readBuffer: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
1260  if (pixelMap != undefined) {
1261    pixelMap.readPixelsToBuffer(readBuffer, (error: BusinessError, res: void) => {
1262      if(error) {
1263        console.error(`Failed to read image pixel data. code is ${error.code}, message is ${error.message}`); // Called if no condition is met.
1264        return;
1265      } else {
1266        console.info('Succeeded in reading image pixel data.');  // Called if the condition is met.
1267      }
1268    })
1269  }
1270}
1271```
1272
1273### readPixelsToBufferSync<sup>12+</sup>
1274
1275readPixelsToBufferSync(dst: ArrayBuffer): void
1276
1277Reads the pixels of this **PixelMap** object based on the PixelMap's pixel format and writes the data to the buffer. This API returns the result synchronously.
1278
1279**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1280
1281**Atomic service API**: This API can be used in atomic services since API version 12.
1282
1283**System capability**: SystemCapability.Multimedia.Image.Core
1284
1285**Parameters**
1286
1287| Name  | Type                | Mandatory| Description                                                                                                 |
1288| -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- |
1289| dst      | ArrayBuffer          | Yes  | Buffer to which the pixels will be written. The buffer size is obtained by calling [getPixelBytesNumber](#getpixelbytesnumber7).|
1290
1291**Error codes**
1292
1293For details about the error codes, see [Image Error Codes](errorcode-image.md).
1294
1295| ID| Error Message|
1296| ------- | --------------------------------------------|
1297|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
1298|  501    | Resource Unavailable |
1299
1300**Example**
1301
1302```ts
1303import { BusinessError } from '@kit.BasicServicesKit';
1304
1305async function ReadPixelsToBufferSync() {
1306  const readBuffer: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
1307  if (pixelMap != undefined) {
1308    pixelMap.readPixelsToBufferSync(readBuffer);
1309  }
1310}
1311```
1312
1313### readPixels<sup>7+</sup>
1314
1315readPixels(area: PositionArea): Promise\<void>
1316
1317Reads the pixels in the area specified by [PositionArea](#positionarea7).region of this **PixelMap** object in the BGRA_8888 format and writes the data to the [PositionArea](#positionarea7).pixels buffer. This API uses a promise to return the result.
1318
1319You can use a formula to calculate the size of the memory to be applied for based on **PositionArea**.
1320
1321YUV region calculation formula: region to read (region.size{width * height}) * 1.5 (1 * Y component + 0.25 * U component + 0.25 * V component)
1322
1323RGBA region calculation formula: region to read (region.size{width * height}) * 4 (1 * R component + 1 * G component + 1 * B component + 1 * A component)
1324
1325**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1326
1327**Atomic service API**: This API can be used in atomic services since API version 11.
1328
1329**System capability**: SystemCapability.Multimedia.Image.Core
1330
1331**Parameters**
1332
1333| Name| Type                          | Mandatory| Description                    |
1334| ------ | ------------------------------ | ---- | ------------------------ |
1335| area   | [PositionArea](#positionarea7) | Yes  | Area from which the pixels will be read.|
1336
1337**Return value**
1338
1339| Type          | Description                                               |
1340| :------------- | :-------------------------------------------------- |
1341| Promise\<void> | Promise that returns no value. |
1342
1343**Example**
1344
1345```ts
1346import { BusinessError } from '@kit.BasicServicesKit';
1347
1348async function ReadPixels() {
1349  const area: image.PositionArea = {
1350    pixels: new ArrayBuffer(8), // 8 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 4.
1351    offset: 0,
1352    stride: 8,
1353    region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
1354  };
1355  if (pixelMap != undefined) {
1356    pixelMap.readPixels(area).then(() => {
1357      console.info('Succeeded in reading the image data in the area.'); // Called if the condition is met.
1358    }).catch((error: BusinessError) => {
1359      console.error(`Failed to read the image data in the area. code is ${error.code}, message is ${error.message}`);// Called if no condition is met.
1360    })
1361  }
1362}
1363
1364async function ReadPixels() {
1365  const area: image.PositionArea = {
1366    pixels: new ArrayBuffer(6),  // 6 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 1.5.
1367    offset: 0,
1368    stride: 8,
1369    region: { size: { height: 2, width: 2 }, x: 0, y: 0 }
1370  };
1371  if (pixelMap != undefined) {
1372    pixelMap.readPixels(area).then(() => {
1373      console.info('Succeeded in reading the image data in the area.'); // Called if the condition is met.
1374    }).catch((error: BusinessError) => {
1375      console.error(`Failed to read the image data in the area. code is ${error.code}, message is ${error.message}`);// Called if no condition is met.
1376    })
1377  }
1378}
1379```
1380
1381### readPixels<sup>7+</sup>
1382
1383readPixels(area: PositionArea, callback: AsyncCallback\<void>): void
1384
1385Reads the pixels in the area specified by [PositionArea](#positionarea7).region of this **PixelMap** object in the BGRA_8888 format and writes the data to the [PositionArea](#positionarea7).pixels buffer. This API uses an asynchronous callback to return the result.
1386
1387You can use a formula to calculate the size of the memory to be applied for based on **PositionArea**.
1388
1389YUV region calculation formula: region to read (region.size{width * height}) * 1.5 (1 * Y component + 0.25 * U component + 0.25 * V component)
1390
1391RGBA region calculation formula: region to read (region.size{width * height}) * 4 (1 * R component + 1 * G component + 1 * B component + 1 * A component)
1392
1393**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1394
1395**Atomic service API**: This API can be used in atomic services since API version 11.
1396
1397**System capability**: SystemCapability.Multimedia.Image.Core
1398
1399**Parameters**
1400
1401| Name  | Type                          | Mandatory| Description                          |
1402| -------- | ------------------------------ | ---- | ------------------------------ |
1403| area     | [PositionArea](#positionarea7) | Yes  | Area from which the pixels will be read.      |
1404| callback | AsyncCallback\<void>           | Yes  |  Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
1405
1406**Example**
1407
1408```ts
1409import { BusinessError } from '@kit.BasicServicesKit';
1410
1411async function ReadPixels() {
1412  const area: image.PositionArea = {
1413    pixels: new ArrayBuffer(8), // 8 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 4.
1414    offset: 0,
1415    stride: 8,
1416    region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
1417  };
1418  if (pixelMap != undefined) {
1419    pixelMap.readPixels(area, (error: BusinessError) => {
1420      if (error) {
1421        console.error(`Failed to read pixelmap from the specified area. code is ${error.code}, message is ${error.message}`);
1422        return;
1423      } else {
1424        console.info('Succeeded in reading pixelmap from the specified area.');
1425      }
1426    })
1427  }
1428}
1429
1430async function ReadPixels() {
1431  const area: image.PositionArea = {
1432    pixels: new ArrayBuffer(6),  // 6 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 1.5.
1433    offset: 0,
1434    stride: 8,
1435    region: { size: { height: 2, width: 2 }, x: 0, y: 0 }
1436  };
1437  if (pixelMap != undefined) {
1438    pixelMap.readPixels(area, (error: BusinessError) => {
1439      if (error) {
1440        console.error(`Failed to read pixelmap from the specified area. code is ${error.code}, message is ${error.message}`);
1441        return;
1442      } else {
1443        console.info('Succeeded in reading pixelmap from the specified area.');
1444      }
1445    })
1446  }
1447}
1448```
1449
1450### readPixelsSync<sup>12+</sup>
1451
1452readPixelsSync(area: PositionArea): void
1453
1454Reads the pixels in the area specified by [PositionArea](#positionarea7).region of this **PixelMap** object in the BGRA_8888 format and writes the data to the [PositionArea](#positionarea7).pixels buffer. This API returns the result synchronously.
1455
1456**Atomic service API**: This API can be used in atomic services since API version 12.
1457
1458**System capability**: SystemCapability.Multimedia.Image.Core
1459
1460**Parameters**
1461
1462| Name| Type                          | Mandatory| Description                    |
1463| ------ | ------------------------------ | ---- | ------------------------ |
1464| area   | [PositionArea](#positionarea7) | Yes  | Area from which the pixels will be read.|
1465
1466**Error codes**
1467
1468For details about the error codes, see [Image Error Codes](errorcode-image.md).
1469
1470| ID| Error Message|
1471| ------- | --------------------------------------------|
1472|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
1473|  501    | Resource Unavailable |
1474
1475**Example**
1476
1477```ts
1478import { BusinessError } from '@kit.BasicServicesKit';
1479
1480async function ReadPixelsSync() {
1481  const area : image.PositionArea = {
1482    pixels: new ArrayBuffer(8),
1483    offset: 0,
1484    stride: 8,
1485    region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
1486  };
1487  if (pixelMap != undefined) {
1488    pixelMap.readPixelsSync(area);
1489  }
1490}
1491```
1492
1493### writePixels<sup>7+</sup>
1494
1495writePixels(area: PositionArea): Promise\<void>
1496
1497Reads the pixels in the [PositionArea](#positionarea7).pixels buffer in the BGRA_8888 format and writes the data to the area specified by [PositionArea](#positionarea7).region in this **PixelMap** object. This API uses a promise to return the result.
1498
1499You can use a formula to calculate the size of the memory to be applied for based on **PositionArea**.
1500
1501YUV region calculation formula: region to read (region.size{width * height}) * 1.5 (1 * Y component + 0.25 * U component + 0.25 * V component)
1502
1503RGBA region calculation formula: region to read (region.size{width * height}) * 4 (1 * R component + 1 * G component + 1 * B component + 1 * A component)
1504
1505**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1506
1507**Atomic service API**: This API can be used in atomic services since API version 11.
1508
1509**System capability**: SystemCapability.Multimedia.Image.Core
1510
1511**Parameters**
1512
1513| Name| Type                          | Mandatory| Description                |
1514| ------ | ------------------------------ | ---- | -------------------- |
1515| area   | [PositionArea](#positionarea7) | Yes  | Area to which the pixels will be written.|
1516
1517**Return value**
1518
1519| Type          | Description                                               |
1520| :------------- | :-------------------------------------------------- |
1521| Promise\<void> | Promise that returns no value. |
1522
1523**Example**
1524
1525```ts
1526import { BusinessError } from '@kit.BasicServicesKit';
1527
1528async function WritePixels() {
1529  const area: image.PositionArea = {
1530    pixels: new ArrayBuffer(8), // 8 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 4.
1531    offset: 0,
1532    stride: 8,
1533    region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
1534  };
1535  let bufferArr: Uint8Array = new Uint8Array(area.pixels);
1536  for (let i = 0; i < bufferArr.length; i++) {
1537    bufferArr[i] = i + 1;
1538  }
1539  if (pixelMap != undefined) {
1540    pixelMap.writePixels(area).then(() => {
1541      console.info('Succeeded in writing pixelmap into the specified area.');
1542    }).catch((error: BusinessError) => {
1543      console.error(`Failed to write pixelmap into the specified area. code is ${error.code}, message is ${error.message}`);
1544    })
1545  }
1546}
1547
1548async function WritePixels() {
1549  const area: image.PositionArea = {
1550    pixels: new ArrayBuffer(6),  // 6 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 1.5.
1551    offset: 0,
1552    stride: 8,
1553    region: { size: { height: 2, width: 2 }, x: 0, y: 0 }
1554  };
1555  let bufferArr: Uint8Array = new Uint8Array(area.pixels);
1556  for (let i = 0; i < bufferArr.length; i++) {
1557    bufferArr[i] = i + 1;
1558  }
1559  if (pixelMap != undefined) {
1560    pixelMap.writePixels(area).then(() => {
1561      console.info('Succeeded in writing pixelmap into the specified area.');
1562    }).catch((error: BusinessError) => {
1563      console.error(`Failed to write pixelmap into the specified area. code is ${error.code}, message is ${error.message}`);
1564    })
1565  }
1566}
1567```
1568
1569### writePixels<sup>7+</sup>
1570
1571writePixels(area: PositionArea, callback: AsyncCallback\<void>): void
1572
1573Reads the pixels in the [PositionArea](#positionarea7).pixels buffer in the BGRA_8888 format and writes the data to the area specified by [PositionArea](#positionarea7).region in this **PixelMap** object. This API uses an asynchronous callback to return the result.
1574
1575You can use a formula to calculate the size of the memory to be applied for based on **PositionArea**.
1576
1577YUV region calculation formula: region to read (region.size{width * height}) * 1.5 (1 * Y component + 0.25 * U component + 0.25 * V component)
1578
1579RGBA region calculation formula: region to read (region.size{width * height}) * 4 (1 * R component + 1 * G component + 1 * B component + 1 * A component)
1580
1581**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1582
1583**Atomic service API**: This API can be used in atomic services since API version 11.
1584
1585**System capability**: SystemCapability.Multimedia.Image.Core
1586
1587**Parameters**
1588
1589| Name   | Type                          | Mandatory| Description                          |
1590| --------- | ------------------------------ | ---- | ------------------------------ |
1591| area      | [PositionArea](#positionarea7) | Yes  | Area to which the pixels will be written.          |
1592| callback  | AsyncCallback\<void>           | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
1593
1594**Example**
1595
1596```ts
1597import { BusinessError } from '@kit.BasicServicesKit';
1598
1599async function WritePixels() {
1600  const area: image.PositionArea = { pixels: new ArrayBuffer(8), // 8 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 4.
1601    offset: 0,
1602    stride: 8,
1603    region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
1604  };
1605  let bufferArr: Uint8Array = new Uint8Array(area.pixels);
1606  for (let i = 0; i < bufferArr.length; i++) {
1607    bufferArr[i] = i + 1;
1608  }
1609  if (pixelMap != undefined) {
1610    pixelMap.writePixels(area, (error : BusinessError) => {
1611      if (error) {
1612        console.error(`Failed to write pixelmap into the specified area. code is ${error.code}, message is ${error.message}`);
1613        return;
1614      } else {
1615        console.info('Succeeded in writing pixelmap into the specified area.');
1616      }
1617    })
1618  }
1619}
1620
1621async function WritePixels() {
1622  const area: image.PositionArea = { pixels: new ArrayBuffer(6), // 6 is the size of the PixelMap buffer to create. The value is calculated as follows: height * width * 1.5.
1623    offset: 0,
1624    stride: 8,
1625    region: { size: { height: 2, width: 2 }, x: 0, y: 0 }
1626  };
1627  let bufferArr: Uint8Array = new Uint8Array(area.pixels);
1628  for (let i = 0; i < bufferArr.length; i++) {
1629    bufferArr[i] = i + 1;
1630  }
1631  if (pixelMap != undefined) {
1632    pixelMap.writePixels(area, (error : BusinessError) => {
1633      if (error) {
1634        console.error(`Failed to write pixelmap into the specified area. code is ${error.code}, message is ${error.message}`);
1635        return;
1636      } else {
1637        console.info('Succeeded in writing pixelmap into the specified area.');
1638      }
1639    })
1640  }
1641}
1642```
1643
1644### writePixelsSync<sup>12+</sup>
1645
1646writePixelsSync(area: PositionArea): void
1647
1648Reads the pixels in the [PositionArea](#positionarea7).pixels buffer in the BGRA_8888 format and writes the data to the area specified by [PositionArea](#positionarea7).region in this **PixelMap** object. This API returns the result synchronously.
1649
1650**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1651
1652**Atomic service API**: This API can be used in atomic services since API version 12.
1653
1654**System capability**: SystemCapability.Multimedia.Image.Core
1655
1656**Parameters**
1657
1658| Name| Type                          | Mandatory| Description                |
1659| ------ | ------------------------------ | ---- | -------------------- |
1660| area   | [PositionArea](#positionarea7) | Yes  | Area to which the pixels will be written.|
1661
1662**Error codes**
1663
1664For details about the error codes, see [Image Error Codes](errorcode-image.md).
1665
1666| ID| Error Message|
1667| ------- | --------------------------------------------|
1668|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
1669|  501    | Resource Unavailable |
1670
1671**Example**
1672
1673```ts
1674import { BusinessError } from '@kit.BasicServicesKit';
1675
1676async function WritePixelsSync() {
1677  const area: image.PositionArea = {
1678    pixels: new ArrayBuffer(8),
1679    offset: 0,
1680    stride: 8,
1681    region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
1682  };
1683  let bufferArr: Uint8Array = new Uint8Array(area.pixels);
1684  for (let i = 0; i < bufferArr.length; i++) {
1685    bufferArr[i] = i + 1;
1686  }
1687  if (pixelMap != undefined) {
1688    pixelMap.writePixelsSync(area);
1689  }
1690}
1691```
1692
1693### writeBufferToPixels<sup>7+</sup>
1694
1695writeBufferToPixels(src: ArrayBuffer): Promise\<void>
1696
1697Reads the pixels in the buffer based on the PixelMap's pixel format and writes the data to this **PixelMap** object. This API uses a promise to return the result.
1698
1699**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1700
1701**Atomic service API**: This API can be used in atomic services since API version 11.
1702
1703**System capability**: SystemCapability.Multimedia.Image.Core
1704
1705**Parameters**
1706
1707| Name| Type       | Mandatory| Description          |
1708| ------ | ----------- | ---- | -------------- |
1709| src    | ArrayBuffer | Yes  | Buffer from which the pixels are read. The buffer size is obtained by calling [getPixelBytesNumber](#getpixelbytesnumber7).|
1710
1711**Return value**
1712
1713| Type          | Description                                           |
1714| -------------- | ----------------------------------------------- |
1715| Promise\<void> | Promise that returns no value. |
1716
1717**Example**
1718
1719```ts
1720import { BusinessError } from '@kit.BasicServicesKit';
1721
1722async function WriteBufferToPixels() {
1723  const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
1724  let bufferArr: Uint8Array = new Uint8Array(color);
1725  for (let i = 0; i < bufferArr.length; i++) {
1726    bufferArr[i] = i + 1;
1727  }
1728  if (pixelMap != undefined) {
1729    pixelMap.writeBufferToPixels(color).then(() => {
1730      console.info("Succeeded in writing data from a buffer to a PixelMap.");
1731    }).catch((error: BusinessError) => {
1732      console.error(`Failed to write data from a buffer to a PixelMap. code is ${error.code}, message is ${error.message}`);
1733    })
1734  }
1735}
1736```
1737
1738### writeBufferToPixels<sup>7+</sup>
1739
1740writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void
1741
1742Reads the pixels in the buffer based on the PixelMap's pixel format and writes the data to this **PixelMap** object. This API uses an asynchronous callback to return the result.
1743
1744**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1745
1746**Atomic service API**: This API can be used in atomic services since API version 11.
1747
1748**System capability**: SystemCapability.Multimedia.Image.Core
1749
1750**Parameters**
1751
1752| Name  | Type                | Mandatory| Description                          |
1753| -------- | -------------------- | ---- | ------------------------------ |
1754| src      | ArrayBuffer          | Yes  | Buffer from which the pixels are read. The buffer size is obtained by calling [getPixelBytesNumber](#getpixelbytesnumber7).|
1755| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the pixels in the buffer are successfully written to the PixelMap, **err** is **undefined**; otherwise, **err** is an error object.|
1756
1757**Example**
1758
1759```ts
1760import { BusinessError } from '@kit.BasicServicesKit';
1761
1762async function WriteBufferToPixels() {
1763  const color: ArrayBuffer = new ArrayBuffer(96);  // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
1764  let bufferArr: Uint8Array = new Uint8Array(color);
1765  for (let i = 0; i < bufferArr.length; i++) {
1766    bufferArr[i] = i + 1;
1767  }
1768  if (pixelMap != undefined) {
1769    pixelMap.writeBufferToPixels(color, (error: BusinessError) => {
1770      if (error) {
1771        console.error(`Failed to write data from a buffer to a PixelMap. code is ${error.code}, message is ${error.message}`);
1772        return;
1773      } else {
1774        console.info("Succeeded in writing data from a buffer to a PixelMap.");
1775      }
1776    })
1777  }
1778}
1779```
1780
1781### writeBufferToPixelsSync<sup>12+</sup>
1782
1783writeBufferToPixelsSync(src: ArrayBuffer): void
1784
1785Reads the pixels in the buffer based on the PixelMap's pixel format and writes the data to this **PixelMap** object. This API returns the result synchronously.
1786
1787**Atomic service API**: This API can be used in atomic services since API version 12.
1788
1789**System capability**: SystemCapability.Multimedia.Image.Core
1790
1791**Parameters**
1792
1793| Name| Type       | Mandatory| Description          |
1794| ------ | ----------- | ---- | -------------- |
1795| src    | ArrayBuffer | Yes  | Buffer from which the pixels are read. The buffer size is obtained by calling [getPixelBytesNumber](#getpixelbytesnumber7).|
1796
1797**Error codes**
1798
1799For details about the error codes, see [Image Error Codes](errorcode-image.md).
1800
1801| ID| Error Message|
1802| ------- | --------------------------------------------|
1803|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
1804|  501    | Resource Unavailable |
1805
1806**Example**
1807
1808```ts
1809import { BusinessError } from '@kit.BasicServicesKit';
1810
1811async function WriteBufferToPixelsSync() {
1812  const color : ArrayBuffer = new ArrayBuffer(96);  // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
1813  let bufferArr : Uint8Array = new Uint8Array(color);
1814  for (let i = 0; i < bufferArr.length; i++) {
1815    bufferArr[i] = i + 1;
1816  }
1817  if (pixelMap != undefined) {
1818    pixelMap.writeBufferToPixelsSync(color);
1819  }
1820}
1821```
1822
1823
1824### getImageInfo<sup>7+</sup>
1825
1826getImageInfo(): Promise\<ImageInfo>
1827
1828Obtains the image information. This API uses a promise to return the result.
1829
1830**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1831
1832**Atomic service API**: This API can be used in atomic services since API version 11.
1833
1834**System capability**: SystemCapability.Multimedia.Image.Core
1835
1836**Return value**
1837
1838| Type                             | Description                                                       |
1839| --------------------------------- | ----------------------------------------------------------- |
1840| Promise\<[ImageInfo](#imageinfo)> | Promise used to return the image information.|
1841
1842**Example**
1843
1844```ts
1845import { BusinessError } from '@kit.BasicServicesKit';
1846
1847async function GetImageInfo() {
1848  if (pixelMap != undefined) {
1849    pixelMap.getImageInfo().then((imageInfo: image.ImageInfo) => {
1850      if (imageInfo != undefined) {
1851        console.info("Succeeded in obtaining the image pixel map information."+ imageInfo.size.height);
1852      }
1853    }).catch((error: BusinessError) => {
1854      console.error(`Failed to obtain the image pixel map information. code is ${error.code}, message is ${error.message}`);
1855    })
1856  }
1857}
1858```
1859
1860### getImageInfo<sup>7+</sup>
1861
1862getImageInfo(callback: AsyncCallback\<ImageInfo>): void
1863
1864Obtains the image information. This API uses an asynchronous callback to return the result.
1865
1866**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1867
1868**Atomic service API**: This API can be used in atomic services since API version 11.
1869
1870**System capability**: SystemCapability.Multimedia.Image.Core
1871
1872**Parameters**
1873
1874| Name  | Type                                   | Mandatory| Description                                                        |
1875| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
1876| callback | AsyncCallback\<[ImageInfo](#imageinfo)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the image information obtained; otherwise, **err** is an error object.|
1877
1878**Example**
1879
1880```ts
1881import { BusinessError } from '@kit.BasicServicesKit';
1882
1883async function GetImageInfo() {
1884  if (pixelMap != undefined) {
1885    pixelMap.getImageInfo((error: BusinessError, imageInfo: image.ImageInfo) => {
1886      if (error) {
1887        console.error(`Failed to obtain the image pixel map information. code is ${error.code}, message is ${error.message}`);
1888        return;
1889      } else {
1890        console.info("Succeeded in obtaining the image pixel map information."+ imageInfo.size.height);
1891      }
1892    })
1893  }
1894}
1895```
1896
1897### getImageInfoSync<sup>12+</sup>
1898
1899getImageInfoSync(): ImageInfo
1900
1901Obtains the image information. This API returns the result synchronously.
1902
1903**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1904
1905**Atomic service API**: This API can be used in atomic services since API version 12.
1906
1907**System capability**: SystemCapability.Multimedia.Image.ImageSource
1908
1909**Return value**
1910
1911| Type                             | Description                                                       |
1912| --------------------------------- | ----------------------------------------------------------- |
1913| [ImageInfo](#imageinfo)           | Image information.                                               |
1914
1915**Error codes**
1916
1917For details about the error codes, see [Image Error Codes](errorcode-image.md).
1918
1919| ID| Error Message|
1920| ------- | --------------------------------------------|
1921|  501    | Resource Unavailable |
1922
1923**Example**
1924
1925```ts
1926import { BusinessError } from '@kit.BasicServicesKit';
1927
1928async function GetImageInfoSync() {
1929  if (pixelMap != undefined) {
1930    let imageInfo : image.ImageInfo = pixelMap.getImageInfoSync();
1931    return imageInfo;
1932  }
1933  return undefined;
1934}
1935```
1936
1937### getBytesNumberPerRow<sup>7+</sup>
1938
1939getBytesNumberPerRow(): number
1940
1941Obtains the number of bytes per row of this image.
1942
1943**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1944
1945**Atomic service API**: This API can be used in atomic services since API version 11.
1946
1947**System capability**: SystemCapability.Multimedia.Image.Core
1948
1949**Return value**
1950
1951| Type  | Description                |
1952| ------ | -------------------- |
1953| number | Number of bytes per row.|
1954
1955**Example**
1956
1957```ts
1958let rowCount: number = pixelMap.getBytesNumberPerRow();
1959```
1960
1961### getPixelBytesNumber<sup>7+</sup>
1962
1963getPixelBytesNumber(): number
1964
1965Obtains the total number of bytes of this image.
1966
1967**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1968
1969**Atomic service API**: This API can be used in atomic services since API version 11.
1970
1971**System capability**: SystemCapability.Multimedia.Image.Core
1972
1973**Return value**
1974
1975| Type  | Description                |
1976| ------ | -------------------- |
1977| number | Total number of bytes.|
1978
1979**Example**
1980
1981```ts
1982let pixelBytesNumber: number = pixelMap.getPixelBytesNumber();
1983```
1984
1985### getDensity<sup>9+</sup>
1986
1987getDensity():number
1988
1989Obtains the density of this image.
1990
1991**Widget capability**: This API can be used in ArkTS widgets since API version 12.
1992
1993**Atomic service API**: This API can be used in atomic services since API version 11.
1994
1995**System capability**: SystemCapability.Multimedia.Image.Core
1996
1997**Return value**
1998
1999| Type  | Description           |
2000| ------ | --------------- |
2001| number | Density of the image.|
2002
2003**Example**
2004
2005```ts
2006let getDensity: number = pixelMap.getDensity();
2007```
2008
2009### opacity<sup>9+</sup>
2010
2011opacity(rate: number, callback: AsyncCallback\<void>): void
2012
2013Sets an opacity rate for this image. This API uses an asynchronous callback to return the result. It is invalid for YUV images.
2014
2015**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2016
2017**Atomic service API**: This API can be used in atomic services since API version 11.
2018
2019**System capability**: SystemCapability.Multimedia.Image.Core
2020
2021**Parameters**
2022
2023| Name  | Type                | Mandatory| Description                          |
2024| -------- | -------------------- | ---- | ------------------------------ |
2025| rate     | number               | Yes  | Opacity rate.  |
2026| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
2027
2028**Example**
2029
2030```ts
2031import { BusinessError } from '@kit.BasicServicesKit';
2032
2033async function Opacity() {
2034  let rate: number = 0.5;
2035  if (pixelMap != undefined) {
2036    pixelMap.opacity(rate, (err: BusinessError) => {
2037      if (err) {
2038        console.error(`Failed to set opacity. code is ${err.code}, message is ${err.message}`);
2039        return;
2040      } else {
2041        console.info("Succeeded in setting opacity.");
2042      }
2043    })
2044  }
2045}
2046```
2047
2048### opacity<sup>9+</sup>
2049
2050opacity(rate: number): Promise\<void>
2051
2052Sets an opacity rate for this image. This API uses a promise to return the result. It is invalid for YUV images.
2053
2054**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2055
2056**Atomic service API**: This API can be used in atomic services since API version 11.
2057
2058**System capability**: SystemCapability.Multimedia.Image.Core
2059
2060**Parameters**
2061
2062| Name| Type  | Mandatory| Description                       |
2063| ------ | ------ | ---- | --------------------------- |
2064| rate   | number | Yes  | Opacity rate.|
2065
2066**Return value**
2067
2068| Type          | Description                                           |
2069| -------------- | ----------------------------------------------- |
2070| Promise\<void> | Promise that returns no value. |
2071
2072**Example**
2073
2074```ts
2075import { BusinessError } from '@kit.BasicServicesKit';
2076
2077async function Opacity() {
2078  let rate: number = 0.5;
2079  if (pixelMap != undefined) {
2080    pixelMap.opacity(rate).then(() => {
2081      console.info('Succeeded in setting opacity.');
2082    }).catch((err: BusinessError) => {
2083      console.error(`Failed to set opacity. code is ${err.code}, message is ${err.message}`);
2084    })
2085  }
2086}
2087```
2088
2089### opacitySync<sup>12+</sup>
2090
2091opacitySync(rate: number): void
2092
2093Sets an opacity rate for this image. This API returns the result synchronously. It is invalid for YUV images.
2094
2095**Atomic service API**: This API can be used in atomic services since API version 12.
2096
2097**System capability**: SystemCapability.Multimedia.Image.Core
2098
2099**Parameters**
2100
2101| Name  | Type                | Mandatory| Description                          |
2102| -------- | -------------------- | ---- | ------------------------------ |
2103| rate     | number               | Yes  | Opacity rate.  |
2104
2105**Error codes**
2106
2107For details about the error codes, see [Image Error Codes](errorcode-image.md).
2108
2109| ID| Error Message|
2110| ------- | --------------------------------------------|
2111|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2112|  501    | Resource Unavailable |
2113
2114**Example**
2115
2116```ts
2117import { BusinessError } from '@kit.BasicServicesKit';
2118
2119async function OpacitySync() {
2120  let rate : number = 0.5;
2121  if (pixelMap != undefined) {
2122    pixelMap.opacitySync(rate);
2123  }
2124}
2125```
2126
2127### createAlphaPixelmap<sup>9+</sup>
2128
2129createAlphaPixelmap(): Promise\<PixelMap>
2130
2131Creates a **PixelMap** object that contains only the alpha channel information. This object can be used for the shadow effect. This API uses a promise to return the result. It is invalid for YUV images.
2132
2133**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2134
2135**Atomic service API**: This API can be used in atomic services since API version 11.
2136
2137**System capability**: SystemCapability.Multimedia.Image.Core
2138
2139**Return value**
2140
2141| Type                            | Description                       |
2142| -------------------------------- | --------------------------- |
2143| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|
2144
2145**Example**
2146
2147```ts
2148import { BusinessError } from '@kit.BasicServicesKit';
2149
2150async function CreateAlphaPixelmap() {
2151  if (pixelMap != undefined) {
2152    pixelMap.createAlphaPixelmap().then((alphaPixelMap: image.PixelMap) => {
2153      console.info('Succeeded in creating alpha pixelmap.');
2154    }).catch((error: BusinessError) => {
2155      console.error(`Failed to create alpha pixelmap. code is ${error.code}, message is ${error.message}`);
2156    })
2157  }
2158}
2159```
2160
2161### createAlphaPixelmap<sup>9+</sup>
2162
2163createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void
2164
2165Creates a **PixelMap** object that contains only the alpha channel information. This object can be used for the shadow effect. This API uses an asynchronous callback to return the result. It is invalid for YUV images.
2166
2167**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2168
2169**Atomic service API**: This API can be used in atomic services since API version 11.
2170
2171**System capability**: SystemCapability.Multimedia.Image.Core
2172
2173**Parameters**
2174
2175| Name  | Type                    | Mandatory| Description                    |
2176| -------- | ------------------------ | ---- | ------------------------ |
2177| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes  |  Callback used to return the result. If the operation is successful, **err** is undefined and **data** is the **PixelMap** object obtained; otherwise, **err** is an error object.|
2178
2179**Example**
2180
2181```ts
2182import { BusinessError } from '@kit.BasicServicesKit';
2183
2184async function CreateAlphaPixelmap() {
2185  if (pixelMap != undefined) {
2186    pixelMap.createAlphaPixelmap((err: BusinessError, alphaPixelMap: image.PixelMap) => {
2187      if (alphaPixelMap == undefined) {
2188        console.error(`Failed to obtain new pixel map. code is ${err.code}, message is ${err.message}`);
2189        return;
2190      } else {
2191        console.info('Succeeded in obtaining new pixel map.');
2192      }
2193    })
2194  }
2195}
2196```
2197
2198### createAlphaPixelmapSync<sup>12+</sup>
2199
2200createAlphaPixelmapSync(): PixelMap
2201
2202Creates a **PixelMap** object that contains only the alpha channel information. This object can be used for the shadow effect. This API returns the result synchronously. It is invalid for YUV images.
2203
2204**Atomic service API**: This API can be used in atomic services since API version 12.
2205
2206**System capability**: SystemCapability.Multimedia.Image.Core
2207
2208**Return value**
2209
2210| Type                            | Description                 |
2211| -------------------------------- | --------------------- |
2212| [PixelMap](#pixelmap7) | Returns a **PixelMap** object if the operation is successful; throws an error otherwise.|
2213
2214**Error codes**
2215
2216For details about the error codes, see [Image Error Codes](errorcode-image.md).
2217
2218| ID| Error Message|
2219| ------- | --------------------------------------------|
2220|  401    | Parameter error. Possible causes: 1.Parameter verification failed |
2221|  501    | Resource Unavailable |
2222
2223**Example**
2224
2225```ts
2226import { BusinessError } from '@kit.BasicServicesKit';
2227
2228async function CreateAlphaPixelmapSync() {
2229  if (pixelMap != undefined) {
2230    let pixelmap : image.PixelMap = pixelMap.createAlphaPixelmapSync();
2231    return pixelmap;
2232  }
2233  return undefined;
2234}
2235```
2236
2237### scale<sup>9+</sup>
2238
2239scale(x: number, y: number, callback: AsyncCallback\<void>): void
2240
2241Scales this image based on the scale factors of the width and height. This API uses an asynchronous callback to return the result.
2242
2243> **NOTE**
2244>
2245> You are advised to set the scale factors to non-negative numbers to avoid a flipping effect.
2246>
2247> Scale factors of the width and height = Width and height of the resized image/Width and height of the original image
2248
2249**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2250
2251**Atomic service API**: This API can be used in atomic services since API version 11.
2252
2253**System capability**: SystemCapability.Multimedia.Image.Core
2254
2255**Parameters**
2256
2257| Name  | Type                | Mandatory| Description                           |
2258| -------- | -------------------- | ---- | ------------------------------- |
2259| x        | number               | Yes  | Scale factor of the width.|
2260| y        | number               | Yes  | Scale factor of the height.|
2261| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
2262
2263**Example**
2264
2265```ts
2266import { BusinessError } from '@kit.BasicServicesKit';
2267
2268async function Scale() {
2269  let scaleX: number = 2.0;
2270  let scaleY: number = 1.0;
2271  if (pixelMap != undefined) {
2272    pixelMap.scale(scaleX, scaleY, (err: BusinessError) => {
2273      if (err) {
2274        console.error(`Failed to scale pixelmap. code is ${err.code}, message is ${err.message}`);
2275        return;
2276      } else {
2277        console.info("Succeeded in scaling pixelmap.");
2278      }
2279    })
2280  }
2281}
2282```
2283
2284### scale<sup>9+</sup>
2285
2286scale(x: number, y: number): Promise\<void>
2287
2288Scales this image based on the scale factors of the width and height. This API uses a promise to return the result.
2289
2290> **NOTE**
2291>
2292> You are advised to set the scale factors to non-negative numbers to avoid a flipping effect.
2293>
2294> Scale factors of the width and height = Width and height of the resized image/Width and height of the original image
2295
2296**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2297
2298**Atomic service API**: This API can be used in atomic services since API version 11.
2299
2300**System capability**: SystemCapability.Multimedia.Image.Core
2301
2302**Parameters**
2303
2304| Name| Type  | Mandatory| Description                           |
2305| ------ | ------ | ---- | ------------------------------- |
2306| x      | number | Yes  | Scale factor of the width.|
2307| y      | number | Yes  | Scale factor of the height.|
2308
2309**Return value**
2310
2311| Type          | Description                       |
2312| -------------- | --------------------------- |
2313| Promise\<void> |  Promise that returns no value.|
2314
2315**Example**
2316
2317```ts
2318import { BusinessError } from '@kit.BasicServicesKit';
2319
2320async function Scale() {
2321  let scaleX: number = 2.0;
2322  let scaleY: number = 1.0;
2323  if (pixelMap != undefined) {
2324    pixelMap.scale(scaleX, scaleY).then(() => {
2325      console.info('Succeeded in scaling pixelmap.');
2326    }).catch((err: BusinessError) => {
2327      console.error(`Failed to scale pixelmap. code is ${err.code}, message is ${err.message}`);
2328
2329    })
2330  }
2331}
2332```
2333
2334### scaleSync<sup>12+</sup>
2335
2336scaleSync(x: number, y: number): void
2337
2338Scales this image based on the scale factors of the width and height. This API returns the result synchronously.
2339
2340> **NOTE**
2341>
2342> You are advised to set the scale factors to non-negative numbers to avoid a flipping effect.
2343>
2344> Scale factors of the width and height = Width and height of the resized image/Width and height of the original image
2345
2346**Atomic service API**: This API can be used in atomic services since API version 12.
2347
2348**System capability**: SystemCapability.Multimedia.Image.Core
2349
2350**Parameters**
2351
2352| Name| Type  | Mandatory| Description                           |
2353| ------ | ------ | ---- | ------------------------------- |
2354| x      | number | Yes  | Scale factor of the width.|
2355| y      | number | Yes  | Scale factor of the height.|
2356
2357**Error codes**
2358
2359For details about the error codes, see [Image Error Codes](errorcode-image.md).
2360
2361| ID| Error Message|
2362| ------- | --------------------------------------------|
2363|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2364|  501    | Resource Unavailable |
2365
2366**Example**
2367
2368```ts
2369import { BusinessError } from '@kit.BasicServicesKit';
2370
2371async function ScaleSync() {
2372  let scaleX: number = 2.0;
2373  let scaleY: number = 1.0;
2374  if (pixelMap != undefined) {
2375    pixelMap.scaleSync(scaleX, scaleY);
2376  }
2377}
2378```
2379
2380### scale<sup>12+</sup>
2381
2382scale(x: number, y: number, level: AntiAliasingLevel): Promise\<void>
2383
2384Scales this image based on the specified anti-aliasing level and the scale factors for the width and height. This API uses a promise to return the result.
2385
2386> **NOTE**
2387>
2388> You are advised to set the scaling factors to non-negative numbers to avoid a flipping effect.
2389>
2390> Scale factors of the width and height = Width and height of the resized image/Width and height of the original image
2391
2392**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2393
2394**Atomic service API**: This API can be used in atomic services since API version 12.
2395
2396**System capability**: SystemCapability.Multimedia.Image.Core
2397
2398**Parameters**
2399
2400| Name| Type  | Mandatory| Description                           |
2401| ------ | ------ | ---- | ------------------------------- |
2402| x      | number | Yes  | Scale factor of the width.|
2403| y      | number | Yes  | Scale factor of the height.|
2404| level  | [AntiAliasingLevel](#antialiasinglevel12) | Yes  | Anti-aliasing level.|
2405
2406**Return value**
2407
2408| Type          | Description                       |
2409| -------------- | --------------------------- |
2410| Promise\<void> |  Promise that returns no value.|
2411
2412**Error codes**
2413
2414For details about the error codes, see [Image Error Codes](errorcode-image.md).
2415
2416| ID| Error Message|
2417| ------- | --------------------------------------------|
2418|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2419|  501    | Resource Unavailable |
2420
2421**Example**
2422
2423```ts
2424import { BusinessError } from '@kit.BasicServicesKit';
2425
2426async function Scale() {
2427  let scaleX: number = 2.0;
2428  let scaleY: number = 1.0;
2429  if (pixelMap != undefined) {
2430    pixelMap.scale(scaleX, scaleY, image.AntiAliasingLevel.LOW).then(() => {
2431      console.info('Succeeded in scaling pixelmap.');
2432    }).catch((err: BusinessError) => {
2433      console.error(`Failed to scale pixelmap. code is ${err.code}, message is ${err.message}`);
2434
2435    })
2436  }
2437}
2438```
2439
2440### scaleSync<sup>12+</sup>
2441
2442scaleSync(x: number, y: number, level: AntiAliasingLevel): void
2443
2444Scales this image based on the specified anti-aliasing level and the scale factors for the width and height. This API returns the result synchronously.
2445
2446> **NOTE**
2447>
2448> You are advised to set the scaling factors to non-negative numbers to avoid a flipping effect.
2449>
2450> Scale factors of the width and height = Width and height of the resized image/Width and height of the original image
2451
2452**Atomic service API**: This API can be used in atomic services since API version 12.
2453
2454**System capability**: SystemCapability.Multimedia.Image.Core
2455
2456**Parameters**
2457
2458| Name| Type  | Mandatory| Description                           |
2459| ------ | ------ | ---- | ------------------------------- |
2460| x      | number | Yes  | Scale factor of the width.|
2461| y      | number | Yes  | Scale factor of the height.|
2462| level  | [AntiAliasingLevel](#antialiasinglevel12) | Yes  | Anti-aliasing level.|
2463
2464**Error codes**
2465
2466For details about the error codes, see [Image Error Codes](errorcode-image.md).
2467
2468| ID| Error Message|
2469| ------- | --------------------------------------------|
2470|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2471|  501    | Resource Unavailable |
2472
2473**Example**
2474
2475```ts
2476import { BusinessError } from '@kit.BasicServicesKit';
2477
2478async function ScaleSync() {
2479  let scaleX: number = 2.0;
2480  let scaleY: number = 1.0;
2481  if (pixelMap != undefined) {
2482    pixelMap.scaleSync(scaleX, scaleY, image.AntiAliasingLevel.LOW);
2483  }
2484}
2485```
2486
2487### translate<sup>9+</sup>
2488
2489translate(x: number, y: number, callback: AsyncCallback\<void>): void
2490
2491Translates this image based on given coordinates. This API uses an asynchronous callback to return the result.
2492
2493The size of the translated image is changed to width+X and height+Y. It is recommended that the new width and height not exceed the width and height of the screen.
2494
2495**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2496
2497**Atomic service API**: This API can be used in atomic services since API version 11.
2498
2499**System capability**: SystemCapability.Multimedia.Image.Core
2500
2501**Parameters**
2502
2503| Name  | Type                | Mandatory| Description                         |
2504| -------- | -------------------- | ---- | ----------------------------- |
2505| x        | number               | Yes  | X coordinate to translate, in pixels.|
2506| y        | number               | Yes  | Y coordinate to translate, in pixels.|
2507| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
2508
2509**Example**
2510
2511```ts
2512import { BusinessError } from '@kit.BasicServicesKit';
2513
2514async function Translate() {
2515  let translateX: number = 50.0;
2516  let translateY: number = 10.0;
2517  if (pixelMap != undefined) {
2518    pixelMap.translate(translateX, translateY, (err: BusinessError) => {
2519      if (err) {
2520        console.error(`Failed to translate pixelmap. code is ${err.code}, message is ${err.message}`);
2521        return;
2522      } else {
2523        console.info("Succeeded in translating pixelmap.");
2524      }
2525    })
2526  }
2527}
2528```
2529
2530### translate<sup>9+</sup>
2531
2532translate(x: number, y: number): Promise\<void>
2533
2534Translates this image based on given coordinates. This API uses a promise to return the result.
2535
2536The size of the translated image is changed to width+X and height+Y. It is recommended that the new width and height not exceed the width and height of the screen.
2537
2538**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2539
2540**Atomic service API**: This API can be used in atomic services since API version 11.
2541
2542**System capability**: SystemCapability.Multimedia.Image.Core
2543
2544**Parameters**
2545
2546| Name| Type  | Mandatory| Description       |
2547| ------ | ------ | ---- | ----------- |
2548| x      | number | Yes  | X coordinate to translate, in pixels.|
2549| y      | number | Yes  | Y coordinate to translate, in pixels.|
2550
2551**Return value**
2552
2553| Type          | Description                       |
2554| -------------- | --------------------------- |
2555| Promise\<void> |  Promise that returns no value.|
2556
2557**Example**
2558
2559```ts
2560import { BusinessError } from '@kit.BasicServicesKit';
2561
2562async function Translate() {
2563  let translateX: number = 50.0;
2564  let translateY: number = 10.0;
2565  if (pixelMap != undefined) {
2566    pixelMap.translate(translateX, translateY).then(() => {
2567      console.info('Succeeded in translating pixelmap.');
2568    }).catch((err: BusinessError) => {
2569      console.error(`Failed to translate pixelmap. code is ${err.code}, message is ${err.message}`);
2570    })
2571  }
2572}
2573```
2574
2575### translateSync<sup>12+</sup>
2576
2577translateSync(x: number, y: number): void
2578
2579Translates this image based on given coordinates. This API returns the result synchronously.
2580
2581The size of the translated image is changed to width+X and height+Y. It is recommended that the new width and height not exceed the width and height of the screen.
2582
2583**Atomic service API**: This API can be used in atomic services since API version 12.
2584
2585**System capability**: SystemCapability.Multimedia.Image.Core
2586
2587**Parameters**
2588
2589| Name  | Type                | Mandatory| Description                           |
2590| -------- | -------------------- | ---- | ------------------------------- |
2591| x        | number               | Yes  | X coordinate to translate, in pixels.|
2592| y        | number               | Yes  | Y coordinate to translate, in pixels.|
2593
2594**Error codes**
2595
2596For details about the error codes, see [Image Error Codes](errorcode-image.md).
2597
2598| ID| Error Message|
2599| ------- | --------------------------------------------|
2600|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2601|  501    | Resource Unavailable |
2602
2603**Example**
2604
2605```ts
2606import { BusinessError } from '@kit.BasicServicesKit';
2607
2608async function TranslateSync() {
2609  let translateX : number = 50.0;
2610  let translateY : number = 10.0;
2611  if (pixelMap != undefined) {
2612    pixelMap.translateSync(translateX, translateY);
2613  }
2614}
2615```
2616
2617### rotate<sup>9+</sup>
2618
2619rotate(angle: number, callback: AsyncCallback\<void>): void
2620
2621Rotates this image based on a given angle. This API uses an asynchronous callback to return the result.
2622
2623> **NOTE**
2624>
2625> The allowable range for image rotation angles is between 0 and 360 degrees. Angles outside this range are automatically adjusted according to the 360-degree cycle. For example, an angle of -100 degrees will produce the same result as 260 degrees.
2626>
2627> If the rotation angle is not an integer multiple of 90 degrees, the image size will change after rotation.
2628
2629**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2630
2631**Atomic service API**: This API can be used in atomic services since API version 11.
2632
2633**System capability**: SystemCapability.Multimedia.Image.Core
2634
2635**Parameters**
2636
2637| Name  | Type                | Mandatory| Description                         |
2638| -------- | -------------------- | ---- | ----------------------------- |
2639| angle    | number               | Yes  | Angle to rotate.|
2640| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
2641
2642**Example**
2643
2644```ts
2645import { BusinessError } from '@kit.BasicServicesKit';
2646
2647async function Rotate() {
2648  let angle: number = 90.0;
2649  if (pixelMap != undefined) {
2650    pixelMap.rotate(angle, (err: BusinessError) => {
2651      if (err) {
2652        console.error(`Failed to rotate pixelmap. code is ${err.code}, message is ${err.message}`);
2653        return;
2654      } else {
2655        console.info("Succeeded in rotating pixelmap.");
2656      }
2657    })
2658  }
2659}
2660```
2661
2662### rotate<sup>9+</sup>
2663
2664rotate(angle: number): Promise\<void>
2665
2666Rotates this image based on a given angle. This API uses a promise to return the result.
2667
2668> **NOTE**
2669>
2670> The allowable range for image rotation angles is between 0 and 360 degrees. Angles outside this range are automatically adjusted according to the 360-degree cycle. For example, an angle of -100 degrees will produce the same result as 260 degrees.
2671>
2672> If the rotation angle is not an integer multiple of 90 degrees, the image size will change after rotation.
2673
2674**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2675
2676**Atomic service API**: This API can be used in atomic services since API version 11.
2677
2678**System capability**: SystemCapability.Multimedia.Image.Core
2679
2680**Parameters**
2681
2682| Name| Type  | Mandatory| Description                         |
2683| ------ | ------ | ---- | ----------------------------- |
2684| angle  | number | Yes  | Angle to rotate.|
2685
2686**Return value**
2687
2688| Type          | Description                       |
2689| -------------- | --------------------------- |
2690| Promise\<void> |  Promise that returns no value.|
2691
2692**Example**
2693
2694```ts
2695import { BusinessError } from '@kit.BasicServicesKit';
2696
2697async function Rotate() {
2698  let angle: number = 90.0;
2699  if (pixelMap != undefined) {
2700    pixelMap.rotate(angle).then(() => {
2701      console.info('Succeeded in rotating pixelmap.');
2702    }).catch((err: BusinessError) => {
2703      console.error(`Failed to rotate pixelmap. code is ${err.code}, message is ${err.message}`);
2704    })
2705  }
2706}
2707```
2708
2709### rotateSync<sup>12+</sup>
2710
2711rotateSync(angle: number): void
2712
2713Rotates this image based on a given angle. This API returns the result synchronously.
2714
2715> **NOTE**
2716>
2717> The allowable range for image rotation angles is between 0 and 360 degrees. Angles outside this range are automatically adjusted according to the 360-degree cycle. For example, an angle of -100 degrees will produce the same result as 260 degrees.
2718>
2719> If the rotation angle is not an integer multiple of 90 degrees, the image size will change after rotation.
2720
2721**Atomic service API**: This API can be used in atomic services since API version 12.
2722
2723**System capability**: SystemCapability.Multimedia.Image.Core
2724
2725**Parameters**
2726
2727| Name  | Type                | Mandatory| Description                         |
2728| -------- | -------------------- | ---- | ----------------------------- |
2729| angle    | number               | Yes  | Angle to rotate.|
2730
2731**Error codes**
2732
2733For details about the error codes, see [Image Error Codes](errorcode-image.md).
2734
2735| ID| Error Message|
2736| ------- | --------------------------------------------|
2737|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2738|  501    | Resource Unavailable |
2739
2740**Example**
2741
2742```ts
2743import { BusinessError } from '@kit.BasicServicesKit';
2744
2745async function RotateSync() {
2746  let angle : number = 90.0;
2747  if (pixelMap != undefined) {
2748    pixelMap.rotateSync(angle);
2749  }
2750}
2751```
2752
2753### flip<sup>9+</sup>
2754
2755flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\<void>): void
2756
2757Flips this image horizontally or vertically, or both. This API uses an asynchronous callback to return the result.
2758
2759**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2760
2761**Atomic service API**: This API can be used in atomic services since API version 11.
2762
2763**System capability**: SystemCapability.Multimedia.Image.Core
2764
2765**Parameters**
2766
2767| Name    | Type                | Mandatory| Description                         |
2768| ---------- | -------------------- | ---- | ----------------------------- |
2769| horizontal | boolean              | Yes  | Whether to flip the image horizontally.                   |
2770| vertical   | boolean              | Yes  | Whether to flip the image vertically.                   |
2771| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
2772
2773**Example**
2774
2775```ts
2776import { BusinessError } from '@kit.BasicServicesKit';
2777
2778async function Flip() {
2779  let horizontal: boolean = true;
2780  let vertical: boolean = false;
2781  if (pixelMap != undefined) {
2782    pixelMap.flip(horizontal, vertical, (err: BusinessError) => {
2783      if (err) {
2784        console.error(`Failed to flip pixelmap. code is ${err.code}, message is ${err.message}`);
2785        return;
2786      } else {
2787        console.info("Succeeded in flipping pixelmap.");
2788      }
2789    })
2790  }
2791}
2792```
2793
2794### flip<sup>9+</sup>
2795
2796flip(horizontal: boolean, vertical: boolean): Promise\<void>
2797
2798Flips this image horizontally or vertically, or both. This API uses a promise to return the result.
2799
2800**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2801
2802**Atomic service API**: This API can be used in atomic services since API version 11.
2803
2804**System capability**: SystemCapability.Multimedia.Image.Core
2805
2806**Parameters**
2807
2808| Name    | Type   | Mandatory| Description     |
2809| ---------- | ------- | ---- | --------- |
2810| horizontal | boolean | Yes  | Whether to flip the image horizontally.|
2811| vertical   | boolean | Yes  | Whether to flip the image vertically.|
2812
2813**Return value**
2814
2815| Type          | Description                       |
2816| -------------- | --------------------------- |
2817| Promise\<void> |  Promise that returns no value.|
2818
2819**Example**
2820
2821```ts
2822import { BusinessError } from '@kit.BasicServicesKit';
2823
2824async function Flip() {
2825  let horizontal: boolean = true;
2826  let vertical: boolean = false;
2827  if (pixelMap != undefined) {
2828    pixelMap.flip(horizontal, vertical).then(() => {
2829      console.info('Succeeded in flipping pixelmap.');
2830    }).catch((err: BusinessError) => {
2831      console.error(`Failed to flip pixelmap. code is ${err.code}, message is ${err.message}`);
2832    })
2833  }
2834}
2835```
2836
2837### flipSync<sup>12+</sup>
2838
2839flipSync(horizontal: boolean, vertical: boolean): void
2840
2841Flips this image horizontally or vertically, or both. This API returns the result synchronously.
2842
2843**Atomic service API**: This API can be used in atomic services since API version 12.
2844
2845**System capability**: SystemCapability.Multimedia.Image.Core
2846
2847**Parameters**
2848
2849| Name    | Type                | Mandatory| Description                         |
2850| ---------- | -------------------- | ---- | ----------------------------- |
2851| horizontal | boolean              | Yes  | Whether to flip the image horizontally.                   |
2852| vertical   | boolean              | Yes  | Whether to flip the image vertically.                   |
2853
2854**Error codes**
2855
2856For details about the error codes, see [Image Error Codes](errorcode-image.md).
2857
2858| ID| Error Message|
2859| ------- | --------------------------------------------|
2860|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2861|  501    | Resource Unavailable |
2862
2863**Example**
2864
2865```ts
2866import { BusinessError } from '@kit.BasicServicesKit';
2867
2868async function FlipSync() {
2869  let horizontal : boolean = true;
2870  let vertical : boolean = false;
2871  if (pixelMap != undefined) {
2872    pixelMap.flipSync(horizontal, vertical);
2873  }
2874}
2875```
2876
2877### crop<sup>9+</sup>
2878
2879crop(region: Region, callback: AsyncCallback\<void>): void
2880
2881Crops this image based on a given size. This API uses an asynchronous callback to return the result.
2882
2883**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2884
2885**Atomic service API**: This API can be used in atomic services since API version 11.
2886
2887**System capability**: SystemCapability.Multimedia.Image.Core
2888
2889**Parameters**
2890
2891| Name  | Type                | Mandatory| Description                         |
2892| -------- | -------------------- | ---- | ----------------------------- |
2893| region   | [Region](#region8)   | Yes  | Size of the image after cropping. |
2894| callback | AsyncCallback\<void> | Yes  |  Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
2895
2896**Example**
2897
2898```ts
2899import { BusinessError } from '@kit.BasicServicesKit';
2900
2901async function Crop() {
2902  let region: image.Region = { x: 0, y: 0, size: { height: 100, width: 100 } };
2903  if (pixelMap != undefined) {
2904    pixelMap.crop(region, (err: BusinessError) => {
2905      if (err) {
2906        console.error(`Failed to crop pixelmap. code is ${err.code}, message is ${err.message}`);
2907        return;
2908      } else {
2909        console.info("Succeeded in cropping pixelmap.");
2910      }
2911    })
2912  }
2913}
2914```
2915
2916### crop<sup>9+</sup>
2917
2918crop(region: Region): Promise\<void>
2919
2920Crops this image based on a given size. This API uses a promise to return the result.
2921
2922**Widget capability**: This API can be used in ArkTS widgets since API version 12.
2923
2924**Atomic service API**: This API can be used in atomic services since API version 11.
2925
2926**System capability**: SystemCapability.Multimedia.Image.Core
2927
2928**Parameters**
2929
2930| Name| Type              | Mandatory| Description       |
2931| ------ | ------------------ | ---- | ----------- |
2932| region | [Region](#region8) | Yes  | Size of the image after cropping. |
2933
2934**Return value**
2935
2936| Type          | Description                       |
2937| -------------- | --------------------------- |
2938| Promise\<void> |  Promise that returns no value.|
2939
2940**Example**
2941
2942```ts
2943import { BusinessError } from '@kit.BasicServicesKit';
2944
2945async function Crop() {
2946  let region: image.Region = { x: 0, y: 0, size: { height: 100, width: 100 } };
2947  if (pixelMap != undefined) {
2948    pixelMap.crop(region).then(() => {
2949      console.info('Succeeded in cropping pixelmap.');
2950    }).catch((err: BusinessError) => {
2951      console.error(`Failed to crop pixelmap. code is ${err.code}, message is ${err.message}`);
2952
2953    });
2954  }
2955}
2956```
2957
2958### cropSync<sup>12+</sup>
2959
2960cropSync(region: Region): void
2961
2962Crops this image based on a given size. This API returns the result synchronously.
2963
2964**Atomic service API**: This API can be used in atomic services since API version 12.
2965
2966**System capability**: SystemCapability.Multimedia.Image.Core
2967
2968**Parameters**
2969
2970| Name  | Type                | Mandatory| Description                         |
2971| -------- | -------------------- | ---- | ----------------------------- |
2972| region   | [Region](#region8)   | Yes  | Size of the image after cropping. |
2973
2974**Error codes**
2975
2976For details about the error codes, see [Image Error Codes](errorcode-image.md).
2977
2978| ID| Error Message|
2979| ------- | --------------------------------------------|
2980|  401    | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
2981|  501    | Resource Unavailable |
2982
2983**Example**
2984
2985```ts
2986import { BusinessError } from '@kit.BasicServicesKit';
2987
2988async function CropSync() {
2989  let region : image.Region = { x: 0, y: 0, size: { height: 100, width: 100 } };
2990  if (pixelMap != undefined) {
2991    pixelMap.cropSync(region);
2992  }
2993}
2994```
2995
2996### getColorSpace<sup>10+</sup>
2997
2998getColorSpace(): colorSpaceManager.ColorSpaceManager
2999
3000Obtains the color space of this image.
3001
3002**System capability**: SystemCapability.Multimedia.Image.Core
3003
3004**Return value**
3005
3006| Type                               | Description            |
3007| ----------------------------------- | ---------------- |
3008| [colorSpaceManager.ColorSpaceManager](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspacemanager) | Color space obtained.|
3009
3010**Error codes**
3011
3012For details about the error codes, see [Image Error Codes](errorcode-image.md).
3013
3014| ID| Error Message|
3015| ------- | --------------------------------------------|
3016| 62980101| If the image data abnormal.            |
3017| 62980103| If the image data unsupport.             |
3018| 62980115| If the image parameter invalid.            |
3019
3020**Example**
3021
3022```ts
3023async function GetColorSpace() {
3024  if (pixelMap != undefined) {
3025    let csm = pixelMap.getColorSpace();
3026  }
3027}
3028```
3029
3030### setColorSpace<sup>10+</sup>
3031
3032setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void
3033
3034Sets the color space for this image.
3035
3036**System capability**: SystemCapability.Multimedia.Image.Core
3037
3038**Parameters**
3039
3040| Name    | Type                               | Mandatory| Description           |
3041| ---------- | ----------------------------------- | ---- | --------------- |
3042| colorSpace | [colorSpaceManager.ColorSpaceManager](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspacemanager) | Yes  | Color space to set.|
3043
3044**Error codes**
3045
3046For details about the error codes, see [Image Error Codes](errorcode-image.md).
3047
3048| ID| Error Message|
3049| ------- | --------------------------------------------|
3050| 62980111| The image source data is incomplete.        |
3051| 62980115| If the image parameter invalid.             |
3052
3053**Example**
3054
3055```ts
3056import { colorSpaceManager } from '@kit.ArkGraphics2D';
3057async function SetColorSpace() {
3058  let colorSpaceName = colorSpaceManager.ColorSpace.SRGB;
3059  let csm: colorSpaceManager.ColorSpaceManager = colorSpaceManager.create(colorSpaceName);
3060  if (pixelMap != undefined) {
3061    pixelMap.setColorSpace(csm);
3062  }
3063}
3064```
3065
3066### applyColorSpace<sup>11+</sup>
3067
3068applyColorSpace(targetColorSpace: colorSpaceManager.ColorSpaceManager, callback: AsyncCallback\<void>): void
3069
3070Performs color space conversion (CSC) on the image pixel color based on a given color space. This API uses an asynchronous callback to return the result.
3071
3072**System capability**: SystemCapability.Multimedia.Image.Core
3073
3074**Parameters**
3075
3076| Name  | Type                | Mandatory| Description                         |
3077| -------- | -------------------- | ---- | ----------------------------- |
3078| targetColorSpace | [colorSpaceManager.ColorSpaceManager](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspacemanager) | Yes  | Target color space. SRGB, DCI_P3, DISPLAY_P3, and ADOBE_RGB_1998 are supported.|
3079| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the setting is successful, **err** is **undefined**; otherwise, **err** is an error object.|
3080
3081**Error codes**
3082
3083For details about the error codes, see [Image Error Codes](errorcode-image.md).
3084
3085| ID| Error Message|
3086| ------- | ------------------------------------------|
3087| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
3088| 62980104| Failed to initialize the internal object. |
3089| 62980108| Failed to convert the color space.       |
3090| 62980115| Invalid image parameter.            |
3091
3092**Example**
3093
3094```ts
3095import { colorSpaceManager } from '@kit.ArkGraphics2D';
3096import { BusinessError } from '@kit.BasicServicesKit';
3097
3098async function ApplyColorSpace() {
3099  let colorSpaceName = colorSpaceManager.ColorSpace.SRGB;
3100  let targetColorSpace: colorSpaceManager.ColorSpaceManager = colorSpaceManager.create(colorSpaceName);
3101  if (pixelMap != undefined) {
3102    pixelMap.applyColorSpace(targetColorSpace, (err: BusinessError) => {
3103      if (err) {
3104        console.error(`Failed to apply color space for pixelmap object. code is ${err.code}, message is ${err.message}`);
3105        return;
3106      } else {
3107        console.info('Succeeded in applying color space for pixelmap object.');
3108      }
3109    })
3110  }
3111}
3112```
3113
3114### applyColorSpace<sup>11+</sup>
3115
3116applyColorSpace(targetColorSpace: colorSpaceManager.ColorSpaceManager): Promise\<void>
3117
3118Performs CSC on the image pixel color based on a given color space. This API uses a promise to return the result.
3119
3120**System capability**: SystemCapability.Multimedia.Image.Core
3121
3122**Parameters**
3123
3124| Name| Type              | Mandatory| Description       |
3125| ------ | ------------------ | ---- | ----------- |
3126| targetColorSpace | [colorSpaceManager.ColorSpaceManager](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspacemanager) | Yes  | Target color space. SRGB, DCI_P3, DISPLAY_P3, and ADOBE_RGB_1998 are supported.|
3127
3128**Return value**
3129
3130| Type          | Description                       |
3131| -------------- | --------------------------- |
3132| Promise\<void> |  Promise that returns no value.|
3133
3134**Error codes**
3135
3136For details about the error codes, see [Image Error Codes](errorcode-image.md).
3137
3138| ID| Error Message|
3139| ------- | ------------------------------------------|
3140| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed |
3141| 62980104| Failed to initialize the internal object. |
3142| 62980108| Failed to convert the color space.       |
3143| 62980115| Invalid image parameter.            |
3144
3145**Example**
3146
3147```ts
3148import { colorSpaceManager } from '@kit.ArkGraphics2D';
3149import { BusinessError } from '@kit.BasicServicesKit';
3150
3151async function ApplyColorSpace() {
3152  let colorSpaceName = colorSpaceManager.ColorSpace.SRGB;
3153  let targetColorSpace: colorSpaceManager.ColorSpaceManager = colorSpaceManager.create(colorSpaceName);
3154  if (pixelMap != undefined) {
3155    pixelMap.applyColorSpace(targetColorSpace).then(() => {
3156      console.info('Succeeded in applying color space for pixelmap object.');
3157    }).catch((error: BusinessError) => {
3158      console.error(`Failed to apply color space for pixelmap object. code is ${error.code}, message is ${error.message}`);
3159    })
3160  }
3161}
3162```
3163
3164### toSdr<sup>12+<sup>
3165
3166toSdr(): Promise\<void>
3167
3168Converts an HDR image into an SDR image. This API uses a promise to return the result.
3169
3170**System capability**: SystemCapability.Multimedia.Image.Core
3171
3172**Return value**
3173
3174| Type          | Description                       |
3175| -------------- | --------------------------- |
3176| Promise\<void> |  Promise that returns no value.|
3177
3178**Error codes**
3179
3180For details about the error codes, see [Image Error Codes](errorcode-image.md).
3181
3182| ID| Error Message|
3183| ------- | --------------------------------------------|
3184| 62980137 | Invalid image operation.              |
3185
3186**Example**
3187
3188```ts
3189import image from '@ohos.multimedia.image'
3190import resourceManager from '@ohos.resourceManager'
3191import { BusinessError } from '@kit.BasicServicesKit';
3192
3193// 'hdr.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
3194let img = getContext().resourceManager.getMediaContentSync($r('app.media.hdr'));
3195let imageSource = image.createImageSource(img.buffer.slice(0));
3196let decodingOptions: image.DecodingOptions = {
3197  desiredDynamicRange: image.DecodingDynamicRange.AUTO
3198};
3199let pixelmap = imageSource.createPixelMapSync(decodingOptions);
3200if (pixelmap != undefined) {
3201  console.info('Succeeded in creating pixelMap object.');
3202  pixelmap.toSdr().then(() => {
3203    let imageInfo = pixelmap.getImageInfoSync();
3204    console.info("after toSdr ,imageInfo isHdr:" + imageInfo.isHdr);
3205  }).catch((err: BusinessError) => {
3206    console.error(`Failed to set sdr. code is ${err.code}, message is ${err.message}`);
3207  });
3208} else {
3209  console.info('Failed to create pixelMap.');
3210}
3211```
3212
3213### getMetadata<sup>12+</sup>
3214
3215getMetadata(key: HdrMetadataKey): HdrMetadataValue
3216
3217Obtains the value of the metadata with a given key in this PixelMap.
3218
3219**System capability**: SystemCapability.Multimedia.Image.Core
3220
3221**Parameters**
3222
3223| Name       | Type                            | Mandatory| Description            |
3224| ------------- | -------------------------------- | ---- | ---------------- |
3225| key | [HdrMetadataKey](#hdrmetadatakey12) | Yes  | Key of the HDR metadata.|
3226
3227**Return value**
3228
3229| Type                             | Description                             |
3230| --------------------------------- | --------------------------------- |
3231| [HdrMetadataValue](#hdrmetadatavalue12) | Value of the metadata with the given key.|
3232
3233**Error codes**
3234
3235For details about the error codes, see [Image Error Codes](errorcode-image.md).
3236
3237| ID| Error Message|
3238| ------- | --------------------------------------------|
3239| 401| Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.          |
3240| 501 | Resource unavailable.          |
3241| 62980173 | The DMA memory does not exist.          |
3242| 62980302 | Memory copy failed.          |
3243
3244**Example**
3245
3246```ts
3247import { BusinessError } from '@kit.BasicServicesKit';
3248import image from '@ohos.multimedia.image'
3249
3250// Replace 'app.media.test' with a local HDR image.
3251let img = getContext().resourceManager.getMediaContentSync($r('app.media.test'));
3252let imageSource = image.createImageSource(img.buffer.slice(0));
3253let decodingOptions: image.DecodingOptions = {
3254  desiredDynamicRange: image.DecodingDynamicRange.AUTO
3255};
3256let pixelmap = imageSource.createPixelMapSync(decodingOptions);
3257if (pixelmap != undefined) {
3258  console.info('Succeeded in creating pixelMap object.');
3259  try {
3260    let staticMetadata = pixelmap.getMetadata(image.HdrMetadataKey.HDR_STATIC_METADATA);
3261    console.info("getmetadata:" + JSON.stringify(staticMetadata));
3262  } catch (e) {
3263    console.info('pixelmap create failed' + e);
3264  }
3265} else {
3266  console.info('Failed to create pixelMap.');
3267}
3268```
3269
3270### setMetadata<sup>12+</sup>
3271
3272setMetadata(key: HdrMetadataKey, value: HdrMetadataValue): Promise\<void>
3273
3274Sets the value for the metadata with a given key in this PixelMap.
3275
3276**System capability**: SystemCapability.Multimedia.Image.Core
3277
3278**Parameters**
3279
3280| Name       | Type                            | Mandatory| Description            |
3281| ------------- | -------------------------------- | ---- | ---------------- |
3282| key | [HdrMetadataKey](#hdrmetadatakey12) | Yes  | Key of the HDR metadata.|
3283| value | [HdrMetadataValue](#hdrmetadatavalue12) | Yes  | Value of the metadata.|
3284
3285**Return value**
3286
3287| Type          | Description                 |
3288| -------------- | --------------------- |
3289| Promise\<void> |  Promise that returns no value.|
3290
3291**Error codes**
3292
3293For details about the error codes, see [Image Error Codes](errorcode-image.md).
3294
3295| ID| Error Message|
3296| ------- | --------------------------------------------|
3297| 401|  Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.         |
3298| 501 | Resource unavailable.          |
3299| 62980173 | The DMA memory does not exist.          |
3300| 62980302 | Memory copy failed.          |
3301
3302**Example**
3303
3304```ts
3305import image from '@ohos.multimedia.image'
3306import { BusinessError } from '@kit.BasicServicesKit';
3307
3308let staticMetadata: image.HdrStaticMetadata = {
3309  displayPrimariesX: [1.1, 1.1, 1.1],
3310  displayPrimariesY: [1.2, 1.2, 1.2],
3311  whitePointX: 1.1,
3312  whitePointY: 1.2,
3313  maxLuminance: 2.1,
3314  minLuminance: 1.0,
3315  maxContentLightLevel: 2.1,
3316  maxFrameAverageLightLevel: 2.1,
3317}
3318const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
3319let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
3320image.createPixelMap(color, opts).then((pixelMap: image.PixelMap) => {
3321  pixelMap.setMetadata(image.HdrMetadataKey.HDR_STATIC_METADATA, staticMetadata).then(() => {
3322    console.info('Succeeded in setting pixelMap metadata.');
3323  }).catch((error: BusinessError) => {
3324    console.error(`Failed to set the metadata.code ${error.code},message is ${error.message}`);
3325  })
3326}).catch((error: BusinessError) => {
3327  console.error(`Failed to create the PixelMap.code ${error.code},message is ${error.message}`);
3328})
3329
3330```
3331
3332### setTransferDetached<sup>12+<sup>
3333
3334setTransferDetached(detached: boolean): void
3335
3336Sets whether to detach from the original thread when this PixelMap is transmitted across threads. This API applies to the scenario where the PixelMap needs to be released immediately.
3337
3338**System capability**: SystemCapability.Multimedia.Image.Core
3339
3340**Parameters**
3341
3342| Name  | Type              | Mandatory| Description                         |
3343| ------- | ------------------ | ---- | ----------------------------- |
3344| detached | boolean   | Yes  | Whether to detach from the original thread.                 |
3345
3346**Error codes**
3347
3348For details about the error codes, see [Image Error Codes](errorcode-image.md).
3349
3350| ID| Error Message|
3351| ------- | --------------------------------------------|
3352|  501    | Resource Unavailable |
3353
3354**Example**
3355
3356```ts
3357import { BusinessError } from '@kit.BasicServicesKit';
3358import image from '@ohos.multimedia.image';
3359import taskpool from '@ohos.taskpool';
3360
3361@Concurrent
3362// Child thread method
3363async function loadPixelMap(rawFileDescriptor: number): Promise<PixelMap> {
3364  // Create an ImageSource instance.
3365  const imageSource = image.createImageSource(rawFileDescriptor);
3366  // Create a pixelMap.
3367  const pixelMap = imageSource.createPixelMapSync();
3368  // Release the ImageSource instance.
3369  imageSource.release();
3370  // Disconnect the reference of the original thread after the cross-thread transfer of the pixelMap is complete.
3371  pixelMap.setTransferDetached(true);
3372  // Return the pixelMap to the main thread.
3373  return pixelMap;
3374}
3375
3376@Entry
3377@Component
3378struct Demo {
3379  @State pixelMap: PixelMap | undefined = undefined;
3380  // Main thread method
3381  private loadImageFromThread(): void {
3382    const resourceMgr = getContext(this).resourceManager;
3383    // 'example.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
3384    resourceMgr.getRawFd('example.jpg').then(rawFileDescriptor => {
3385      taskpool.execute(loadPixelMap, rawFileDescriptor).then(pixelMap => {
3386        if (pixelMap) {
3387          this.pixelMap = pixelMap as PixelMap;
3388          console.log('Succeeded in creating pixelMap.');
3389          // The main thread releases the pixelMap. Because setTransferDetached has been called when the child thread returns pixelMap, the pixelMap can be released immediately.
3390          this.pixelMap.release();
3391        } else {
3392          console.error('Failed to create pixelMap.');
3393        }
3394      });
3395    });
3396  }
3397  build() {
3398    // ...
3399  }
3400}
3401```
3402
3403### marshalling<sup>10+</sup>
3404
3405marshalling(sequence: rpc.MessageSequence): void
3406
3407Marshals this **PixelMap** object and writes it to a **MessageSequence** object.
3408
3409**System capability**: SystemCapability.Multimedia.Image.Core
3410
3411**Parameters**
3412
3413| Name                | Type                                                 | Mandatory| Description                                    |
3414| ---------------------- | ------------------------------------------------------ | ---- | ---------------------------------------- |
3415| sequence               | [rpc.MessageSequence](../apis-ipc-kit/js-apis-rpc.md#messagesequence9)  | Yes  | **MessageSequence** object.                |
3416
3417**Error codes**
3418
3419For details about the error codes, see [Image Error Codes](errorcode-image.md).
3420
3421| ID| Error Message|
3422| ------- | --------------------------------------------|
3423| 62980115 | Invalid image parameter.              |
3424| 62980097 | IPC error.             |
3425
3426**Example**
3427
3428```ts
3429import { image } from '@kit.ImageKit';
3430import { rpc } from '@kit.IPCKit';
3431
3432class MySequence implements rpc.Parcelable {
3433  pixel_map: image.PixelMap;
3434  constructor(conPixelMap : image.PixelMap) {
3435    this.pixel_map = conPixelMap;
3436  }
3437  marshalling(messageSequence : rpc.MessageSequence) {
3438    this.pixel_map.marshalling(messageSequence);
3439    console.info('marshalling');
3440    return true;
3441  }
3442  unmarshalling(messageSequence : rpc.MessageSequence) {
3443    image.createPixelMap(new ArrayBuffer(96), {size: { height:4, width: 6}}).then((pixelParcel: image.PixelMap) => {
3444      pixelParcel.unmarshalling(messageSequence).then(async (pixelMap: image.PixelMap) => {
3445        this.pixel_map = pixelMap;
3446        pixelMap.getImageInfo().then((imageInfo: image.ImageInfo) => {
3447          console.info("unmarshalling information h:" + imageInfo.size.height + "w:" + imageInfo.size.width);
3448        })
3449      })
3450    });
3451    return true;
3452  }
3453}
3454async function Marshalling() {
3455  const color: ArrayBuffer = new ArrayBuffer(96);
3456  let bufferArr: Uint8Array = new Uint8Array(color);
3457  for (let i = 0; i < bufferArr.length; i++) {
3458    bufferArr[i] = 0x80;
3459  }
3460  let opts: image.InitializationOptions = {
3461    editable: true,
3462    pixelFormat: image.PixelMapFormat.BGRA_8888,
3463    size: { height: 4, width: 6 },
3464    alphaType: image.AlphaType.UNPREMUL
3465  }
3466  let pixelMap: image.PixelMap | undefined = undefined;
3467  image.createPixelMap(color, opts).then((srcPixelMap: image.PixelMap) => {
3468    pixelMap = srcPixelMap;
3469  })
3470  if (pixelMap != undefined) {
3471    // Implement serialization.
3472    let parcelable: MySequence = new MySequence(pixelMap);
3473    let data: rpc.MessageSequence = rpc.MessageSequence.create();
3474    data.writeParcelable(parcelable);
3475
3476    // Implement deserialization to obtain data through the RPC.
3477    let ret: MySequence = new MySequence(pixelMap);
3478    data.readParcelable(ret);
3479  }
3480}
3481```
3482
3483### unmarshalling<sup>10+</sup>
3484
3485unmarshalling(sequence: rpc.MessageSequence): Promise\<PixelMap>
3486
3487Unmarshals a **MessageSequence** object to obtain a **PixelMap** object.
3488To create a **PixelMap** object in synchronous mode, use [createPixelMapFromParcel](#imagecreatepixelmapfromparcel11).
3489
3490**System capability**: SystemCapability.Multimedia.Image.Core
3491
3492**Parameters**
3493
3494| Name                | Type                                                 | Mandatory| Description                                    |
3495| ---------------------- | ----------------------------------------------------- | ---- | ---------------------------------------- |
3496| sequence               | [rpc.MessageSequence](../apis-ipc-kit/js-apis-rpc.md#messagesequence9) | Yes  | **MessageSequence** object that stores the **PixelMap** information.     |
3497
3498**Return value**
3499
3500| Type                            | Description                 |
3501| -------------------------------- | --------------------- |
3502| Promise\<[PixelMap](#pixelmap7)> |Promise used to return the **PixelMap** object.|
3503
3504**Error codes**
3505
3506For details about the error codes, see [Image Error Codes](errorcode-image.md).
3507
3508| ID| Error Message|
3509| ------- | --------------------------------------------|
3510| 62980115 | Invalid image parameter.              |
3511| 62980097 | IPC error.              |
3512| 62980096 | The operation failed.         |
3513
3514**Example**
3515
3516```ts
3517import { image } from '@kit.ImageKit';
3518import { rpc } from '@kit.IPCKit';
3519
3520class MySequence implements rpc.Parcelable {
3521  pixel_map: image.PixelMap;
3522  constructor(conPixelMap: image.PixelMap) {
3523    this.pixel_map = conPixelMap;
3524  }
3525  marshalling(messageSequence: rpc.MessageSequence) {
3526    this.pixel_map.marshalling(messageSequence);
3527    console.info('marshalling');
3528    return true;
3529  }
3530  unmarshalling(messageSequence: rpc.MessageSequence) {
3531    image.createPixelMap(new ArrayBuffer(96), {size: { height:4, width: 6}}).then((pixelParcel : image.PixelMap) => {
3532      pixelParcel.unmarshalling(messageSequence).then(async (pixelMap : image.PixelMap) => {
3533        this.pixel_map = pixelMap;
3534        pixelMap.getImageInfo().then((imageInfo : image.ImageInfo) => {
3535          console.info("unmarshalling information h:" + imageInfo.size.height + "w:" + imageInfo.size.width);
3536        })
3537      })
3538    });
3539    return true;
3540  }
3541}
3542async function Unmarshalling() {
3543  const color: ArrayBuffer = new ArrayBuffer(96);
3544  let bufferArr: Uint8Array = new Uint8Array(color);
3545  for (let i = 0; i < bufferArr.length; i++) {
3546    bufferArr[i] = 0x80;
3547  }
3548  let opts: image.InitializationOptions = {
3549    editable: true,
3550    pixelFormat: image.PixelMapFormat.BGRA_8888,
3551    size: { height: 4, width: 6 },
3552    alphaType: image.AlphaType.UNPREMUL
3553  }
3554  let pixelMap: image.PixelMap | undefined = undefined;
3555  image.createPixelMap(color, opts).then((srcPixelMap : image.PixelMap) => {
3556    pixelMap = srcPixelMap;
3557  })
3558  if (pixelMap != undefined) {
3559    // Implement serialization.
3560    let parcelable: MySequence = new MySequence(pixelMap);
3561    let data : rpc.MessageSequence = rpc.MessageSequence.create();
3562    data.writeParcelable(parcelable);
3563
3564    // Implement deserialization to obtain data through the RPC.
3565    let ret : MySequence = new MySequence(pixelMap);
3566    data.readParcelable(ret);
3567  }
3568}
3569```
3570
3571### release<sup>7+</sup>
3572
3573release():Promise\<void>
3574
3575Releases this **PixelMap** object. This API uses a promise to return the result.
3576
3577ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **PixelMap** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
3578
3579**Widget capability**: This API can be used in ArkTS widgets since API version 12.
3580
3581**Atomic service API**: This API can be used in atomic services since API version 11.
3582
3583**System capability**: SystemCapability.Multimedia.Image.Core
3584
3585**Return value**
3586
3587| Type          | Description                           |
3588| -------------- | ------------------------------- |
3589| Promise\<void> | Promise that returns no value.|
3590
3591**Example**
3592
3593```ts
3594import { BusinessError } from '@kit.BasicServicesKit';
3595
3596async function Release() {
3597  if (pixelMap != undefined) {
3598    pixelMap.release().then(() => {
3599      console.info('Succeeded in releasing pixelmap object.');
3600    }).catch((error: BusinessError) => {
3601      console.error(`Failed to release pixelmap object. code is ${error.code}, message is ${error.message}`);
3602    })
3603  }
3604}
3605```
3606
3607### release<sup>7+</sup>
3608
3609release(callback: AsyncCallback\<void>): void
3610
3611Releases this **PixelMap** object. This API uses an asynchronous callback to return the result.
3612
3613ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **PixelMap** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
3614
3615**Widget capability**: This API can be used in ArkTS widgets since API version 12.
3616
3617**Atomic service API**: This API can be used in atomic services since API version 11.
3618
3619**System capability**: SystemCapability.Multimedia.Image.Core
3620
3621**Parameters**
3622
3623| Name  | Type                | Mandatory| Description              |
3624| -------- | -------------------- | ---- | ------------------ |
3625| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
3626
3627**Example**
3628
3629```ts
3630import { BusinessError } from '@kit.BasicServicesKit';
3631
3632async function Release() {
3633  if (pixelMap != undefined) {
3634    pixelMap.release((err: BusinessError) => {
3635      if (err) {
3636        console.error(`Failed to release pixelmap object. code is ${err.code}, message is ${err.message}`);
3637        return;
3638      } else {
3639        console.info('Succeeded in releasing pixelmap object.');
3640      }
3641    })
3642  }
3643}
3644```
3645
3646### convertPixelFormat<sup>12+</sup>
3647
3648convertPixelFormat(targetPixelFormat: PixelMapFormat): Promise\<void>
3649
3650Performs a conversion between YUV and RGB formats. Currently, only conversion between NV12/NV21 and RGB888/RGBA8888/RGB565/BGRA8888/RGBAF16 and conversion between YCRCB_P010/YCBCR_P010 and RGBA1010102 are supported.
3651
3652**System capability**: SystemCapability.Multimedia.Image.Core
3653
3654**Parameters**
3655
3656| Name  | Type                | Mandatory| Description              |
3657| -------- | -------------------- | ---- | ------------------ |
3658| targetPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes  | Target pixel format. Currently, only conversion between NV12/NV21 and RGB888/RGBA8888/RGB565/BGRA8888/RGBAF16 and conversion between YCRCB_P010/YCBCR_P010 and RGBA1010102 are supported.|
3659
3660**Return value**
3661
3662| Type          | Description                           |
3663| -------------- | ------------------------------- |
3664| Promise\<void> | Promise that returns no value.|
3665
3666**Error codes**
3667
3668For details about the error codes, see [Image Error Codes](errorcode-image.md).
3669
3670| ID| Error Message|
3671| ------- | --------------------------------------------|
3672| 62980111 | The image source data is incomplete. |
3673| 62980115 | Invalid input parameter.              |
3674| 62980178 | Failed to create the pixelmap. |
3675| 62980274 | The conversion failed |
3676| 62980276 | The type to be converted is an unsupported target pixel format|
3677
3678**Example**
3679
3680```ts
3681import { BusinessError } from '@kit.BasicServicesKit';
3682
3683if (pixelMap != undefined) {
3684  // Set the target pixel format to NV12.
3685  let targetPixelFormat = image.PixelMapFormat.NV12;
3686  pixelMap.convertPixelFormat(targetPixelFormat).then(() => {
3687    // The pixelMap is converted to the NV12 format.
3688    console.info('PixelMapFormat convert Succeeded');
3689  }).catch((error: BusinessError) => {
3690    // The pixelMap fails to be converted to the NV12 format.
3691    console.error(`PixelMapFormat convert Failed. code is ${error.code}, message is ${error.message}`);
3692  })
3693}
3694```
3695
3696### setMemoryNameSync<sup>13+</sup>
3697
3698setMemoryNameSync(name: string): void
3699
3700Sets a memory name for this PixelMap.
3701
3702**System capability**: SystemCapability.Multimedia.Image.Core
3703
3704**Parameters**
3705
3706| Name       | Type                            | Mandatory| Description            |
3707| ------------- | -------------------------------- | ---- | ---------------- |
3708| name | string | Yes  | Memory name, which can be set only for a PixelMap with the DMA or ASHMEM memory format. The length ranges from 1 to 31 bits.|
3709
3710**Error codes**
3711
3712For details about the error codes, see [Image Error Codes](errorcode-image.md).
3713
3714| ID| Error Message|
3715| ------- | --------------------------------------------|
3716| 401 | Parameter error. Possible causes: 1.The length of the input parameter is too long. 2.Parameter verification failed. |
3717| 501 | Resource unavailable. |
3718| 62980286 | Memory format not supported. |
3719
3720**Example**
3721
3722```ts
3723import { BusinessError } from '@ohos.base';
3724
3725async function SetMemoryNameSync() {
3726  if (pixelMap != undefined) {
3727    try {
3728      pixelMap.setMemoryNameSync("PixelMapName Test");
3729    } catch(e) {
3730      let error = e as BusinessError;
3731      console.error(`setMemoryNameSync error. code is ${error.code}, message is ${error.message}`);
3732    }
3733  }
3734}
3735```
3736
3737## image.createImageSource
3738
3739createImageSource(uri: string): ImageSource
3740
3741Creates an **ImageSource** instance based on a given URI.
3742
3743
3744**Atomic service API**: This API can be used in atomic services since API version 11.
3745
3746**System capability**: SystemCapability.Multimedia.Image.ImageSource
3747
3748**Parameters**
3749
3750| Name| Type  | Mandatory| Description                              |
3751| ------ | ------ | ---- | ---------------------------------- |
3752| uri    | string | Yes  | Image path. Currently, only the application sandbox path is supported.<br>The following formats are supported: .jpg, .png, .gif, .bmp, .webp, .dng, .heic<sup>12+</sup> (depending on the hardware), [.svg<sup>10+</sup>](#svg-tags), and .ico<sup>11+</sup>.|
3753
3754**Return value**
3755
3756| Type                       | Description                                        |
3757| --------------------------- | -------------------------------------------- |
3758| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
3759
3760**Example**
3761
3762```ts
3763const context: Context = getContext(this);
3764// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
3765const path: string = context.filesDir + "/test.jpg";
3766const imageSourceApi: image.ImageSource = image.createImageSource(path);
3767```
3768
3769## image.createImageSource<sup>9+</sup>
3770
3771createImageSource(uri: string, options: SourceOptions): ImageSource
3772
3773Creates an **ImageSource** instance based on a given URI.
3774
3775**Widget capability**: This API can be used in ArkTS widgets since API version 12.
3776
3777**Atomic service API**: This API can be used in atomic services since API version 11.
3778
3779**System capability**: SystemCapability.Multimedia.Image.ImageSource
3780
3781**Parameters**
3782
3783| Name | Type                           | Mandatory| Description                               |
3784| ------- | ------------------------------- | ---- | ----------------------------------- |
3785| uri     | string                          | Yes  | Image path. Currently, only the application sandbox path is supported.<br>The following formats are supported: .jpg, .png, .gif, .bmp, .webp, .dng, .heic<sup>12+</sup> (depending on the hardware), [.svg<sup>10+</sup>](#svg-tags), and .ico<sup>11+</sup>.|
3786| options | [SourceOptions](#sourceoptions9) | Yes  | Image properties, including the image pixel density, pixel format, and image size.|
3787
3788**Return value**
3789
3790| Type                       | Description                                        |
3791| --------------------------- | -------------------------------------------- |
3792| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
3793
3794**Example**
3795
3796```ts
3797let sourceOptions: image.SourceOptions = { sourceDensity: 120 };
3798const context: Context = getContext(this);
3799// 'test.png' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
3800const path: string = context.filesDir + "/test.png";
3801let imageSourceApi: image.ImageSource = image.createImageSource(path, sourceOptions);
3802```
3803
3804## image.createImageSource<sup>7+</sup>
3805
3806createImageSource(fd: number): ImageSource
3807
3808Creates an **ImageSource** instance based on a given file descriptor.
3809
3810**Atomic service API**: This API can be used in atomic services since API version 11.
3811
3812**System capability**: SystemCapability.Multimedia.Image.ImageSource
3813
3814**Parameters**
3815
3816| Name| Type  | Mandatory| Description         |
3817| ------ | ------ | ---- | ------------- |
3818| fd     | number | Yes  | File descriptor.|
3819
3820**Return value**
3821
3822| Type                       | Description                                        |
3823| --------------------------- | -------------------------------------------- |
3824| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
3825
3826**Example**
3827
3828```ts
3829import { fileIo as fs } from '@kit.CoreFileKit';
3830
3831const context: Context = getContext(this);
3832// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
3833let filePath: string = context.filesDir + "/test.jpg";
3834let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3835const imageSourceApi: image.ImageSource = image.createImageSource(file.fd);
3836```
3837
3838## image.createImageSource<sup>9+</sup>
3839
3840createImageSource(fd: number, options: SourceOptions): ImageSource
3841
3842Creates an **ImageSource** instance based on a given file descriptor.
3843
3844**Widget capability**: This API can be used in ArkTS widgets since API version 12.
3845
3846**Atomic service API**: This API can be used in atomic services since API version 11.
3847
3848**System capability**: SystemCapability.Multimedia.Image.ImageSource
3849
3850**Parameters**
3851
3852| Name | Type                           | Mandatory| Description                               |
3853| ------- | ------------------------------- | ---- | ----------------------------------- |
3854| fd      | number                          | Yes  | File descriptor.                     |
3855| options | [SourceOptions](#sourceoptions9) | Yes  | Image properties, including the image pixel density, pixel format, and image size.|
3856
3857**Return value**
3858
3859| Type                       | Description                                        |
3860| --------------------------- | -------------------------------------------- |
3861| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
3862
3863**Example**
3864
3865```ts
3866import { fileIo as fs } from '@kit.CoreFileKit';
3867
3868let sourceOptions: image.SourceOptions = { sourceDensity: 120 };
3869const context: Context = getContext();
3870// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
3871const filePath: string = context.filesDir + "/test.jpg";
3872let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
3873const imageSourceApi: image.ImageSource = image.createImageSource(file.fd, sourceOptions);
3874```
3875
3876## image.createImageSource<sup>9+</sup>
3877
3878createImageSource(buf: ArrayBuffer): ImageSource
3879
3880Creates an **ImageSource** instance based on buffers. The data passed by **buf** must be undecoded. Do not pass the pixel buffer data such as RBGA and YUV. If you want to create a PixelMap based on the pixel buffer data, call [image.createPixelMapSync](#createpixelmapsync12).
3881
3882**Widget capability**: This API can be used in ArkTS widgets since API version 12.
3883
3884**Atomic service API**: This API can be used in atomic services since API version 11.
3885
3886**System capability**: SystemCapability.Multimedia.Image.ImageSource
3887
3888**Parameters**
3889
3890| Name| Type       | Mandatory| Description            |
3891| ------ | ----------- | ---- | ---------------- |
3892| buf    | ArrayBuffer | Yes  | Array of image buffers.|
3893
3894**Return value**
3895
3896| Type                       | Description                                        |
3897| --------------------------- | -------------------------------------------- |
3898| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
3899
3900
3901**Example**
3902
3903```ts
3904const buf: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
3905const imageSourceApi: image.ImageSource = image.createImageSource(buf);
3906```
3907
3908## image.createImageSource<sup>9+</sup>
3909
3910createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource
3911
3912Creates an **ImageSource** instance based on buffers. The data passed by **buf** must be undecoded. Do not pass the pixel buffer data such as RBGA and YUV. If you want to create a PixelMap based on the pixel buffer data, call [image.createPixelMapSync](#createpixelmapsync12).
3913
3914**Widget capability**: This API can be used in ArkTS widgets since API version 12.
3915
3916**Atomic service API**: This API can be used in atomic services since API version 11.
3917
3918**System capability**: SystemCapability.Multimedia.Image.ImageSource
3919
3920**Parameters**
3921
3922| Name| Type                            | Mandatory| Description                                |
3923| ------ | -------------------------------- | ---- | ------------------------------------ |
3924| buf    | ArrayBuffer                      | Yes  | Array of image buffers.                    |
3925| options | [SourceOptions](#sourceoptions9) | Yes  | Image properties, including the image pixel density, pixel format, and image size.|
3926
3927**Return value**
3928
3929| Type                       | Description                                        |
3930| --------------------------- | -------------------------------------------- |
3931| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
3932
3933**Example**
3934
3935```ts
3936const data: ArrayBuffer = new ArrayBuffer(112);
3937let sourceOptions: image.SourceOptions = { sourceDensity: 120 };
3938const imageSourceApi: image.ImageSource = image.createImageSource(data, sourceOptions);
3939```
3940
3941## image.createImageSource<sup>11+</sup>
3942
3943createImageSource(rawfile: resourceManager.RawFileDescriptor, options?: SourceOptions): ImageSource
3944
3945Creates an **ImageSource** instance based on the raw file descriptor of an image resource file.
3946
3947**Atomic service API**: This API can be used in atomic services since API version 11.
3948
3949**System capability**: SystemCapability.Multimedia.Image.ImageSource
3950
3951**Parameters**
3952
3953| Name| Type                            | Mandatory| Description                                |
3954| ------ | -------------------------------- | ---- | ------------------------------------ |
3955| rawfile | [resourceManager.RawFileDescriptor](../apis-localization-kit/js-apis-resource-manager.md#rawfiledescriptor8) | Yes| Raw file descriptor of the image resource file.|
3956| options | [SourceOptions](#sourceoptions9) | No| Image properties, including the image pixel density, pixel format, and image size.|
3957
3958**Return value**
3959
3960| Type                       | Description                                        |
3961| --------------------------- | -------------------------------------------- |
3962| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
3963
3964**Example**
3965
3966```ts
3967import { resourceManager } from '@kit.LocalizationKit';
3968
3969const context: Context = getContext(this);
3970// Obtain a resource manager.
3971const resourceMgr: resourceManager.ResourceManager = context.resourceManager;
3972// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
3973resourceMgr.getRawFd('test.jpg').then((rawFileDescriptor: resourceManager.RawFileDescriptor) => {
3974  const imageSourceApi: image.ImageSource = image.createImageSource(rawFileDescriptor);
3975}).catch((error: BusinessError) => {
3976  console.error(`Failed to get RawFileDescriptor.code is ${error.code}, message is ${error.message}`);
3977})
3978```
3979
3980## image.CreateIncrementalSource<sup>9+</sup>
3981
3982CreateIncrementalSource(buf: ArrayBuffer): ImageSource
3983
3984Creates an **ImageSource** instance in incremental mode based on buffers. Such an instance does not support reading or writing of EXIF information.
3985
3986The **ImageSource** instance created in incremental mode supports the following capabilities (applicable to synchronous, callback, and promise modes):
3987- Obtaining image information: Call [getImageInfo](#getimageinfo) to obtain image information by index, or call [getImageInfo](#getimageinfo-1) to directly obtain image information.
3988- Obtaining an image property: Call [getImageProperty](#getimageproperty11) to obtain the value of a property with the specified index in an image.
3989- Obtaining image properties: Call [getImageProperties](#getimageproperties12) to obtain the values of properties with the given names in an image.
3990- Updating incremental data: Call [updateData](#updatedata9) to update data.
3991- Creating a **PixelMap** object: Call [createPixelMap](#createpixelmap7) or [createPixelMap](#createpixelmap7-2) to create a PixelMap based on image decoding parameters, or call [createPixelMap](#createpixelmap7-1) to create a PixelMap based on default parameters.
3992- Releasing an **ImageSource** instance: Call [release](#release) to release an image source.
3993
3994**System capability**: SystemCapability.Multimedia.Image.ImageSource
3995
3996**Parameters**
3997
3998| Name | Type       | Mandatory| Description     |
3999| ------- | ------------| ---- | ----------|
4000| buf     | ArrayBuffer | Yes  | Incremental data.|
4001
4002**Return value**
4003
4004| Type                       | Description                             |
4005| --------------------------- | --------------------------------- |
4006| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.|
4007
4008**Example**
4009
4010```ts
4011const context: Context = getContext(this)
4012let imageArray = context.resourceManager.getMediaContentSync($r('app.media.startIcon')) // Obtain the image resource.
4013// 'app.media.startIcon' is only an example. Replace it with the actual one in use. Otherwise, the imageArray instance fails to be created, and subsequent operations cannot be performed.
4014let splitBuff1 = imageArray.slice(0, imageArray.byteLength / 2) // Image slice.
4015let splitBuff2 = imageArray.slice(imageArray.byteLength / 2)
4016const imageSourceIncrementalSApi: image.ImageSource = image.CreateIncrementalSource(new ArrayBuffer(imageArray.byteLength));
4017imageSourceIncrementalSApi.updateData(splitBuff1, false, 0, splitBuff1.byteLength).then(() => {
4018  imageSourceIncrementalSApi.updateData(splitBuff2, true, 0, splitBuff2.byteLength).then(() => {
4019    let pixelMap = imageSourceIncrementalSApi.createPixelMapSync()
4020    let imageInfo = pixelMap.getImageInfoSync()
4021    console.info('Succeeded in creating pixelMap')
4022  }).catch((error : BusinessError) => {
4023    console.error(`Failed to updateData error code is ${error.code}, message is ${error.message}`)
4024  })
4025}).catch((error : BusinessError) => {
4026  console.error(`Failed to updateData error code is ${error.code}, message is ${error.message}`)
4027})
4028```
4029
4030## image.CreateIncrementalSource<sup>9+</sup>
4031
4032CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
4033
4034Creates an **ImageSource** instance in incremental mode based on buffers. Such an instance does not support reading or writing of EXIF information.
4035
4036The capabilities supported by the **ImageSource** instance created by this API are the same as those supported by the instance created by [CreateIncrementalSource(buf: ArrayBuffer): ImageSource](#imagecreateincrementalsource9).
4037
4038**System capability**: SystemCapability.Multimedia.Image.ImageSource
4039
4040**Parameters**
4041
4042| Name | Type                           | Mandatory| Description                                |
4043| ------- | ------------------------------- | ---- | ------------------------------------ |
4044| buf     | ArrayBuffer                     | Yes  | Incremental data.                          |
4045| options | [SourceOptions](#sourceoptions9) | No  | Image properties, including the image pixel density, pixel format, and image size.|
4046
4047**Return value**
4048
4049| Type                       | Description                             |
4050| --------------------------- | --------------------------------- |
4051| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.|
4052
4053**Example**
4054
4055```ts
4056const context: Context = getContext(this)
4057let imageArray = context.resourceManager.getMediaContentSync($r('app.media.startIcon')) // Obtain the image resource.
4058// 'app.media.startIcon' is only an example. Replace it with the actual one in use. Otherwise, the imageArray instance fails to be created, and subsequent operations cannot be performed.
4059let splitBuff1 = imageArray.slice(0, imageArray.byteLength / 2) // Image slice.
4060let splitBuff2 = imageArray.slice(imageArray.byteLength / 2)
4061let sourceOptions: image.SourceOptions = { sourceDensity: 120};
4062
4063const imageSourceIncrementalSApi: image.ImageSource = image.CreateIncrementalSource(new ArrayBuffer(imageArray.byteLength), sourceOptions);
4064imageSourceIncrementalSApi.updateData(splitBuff1, false, 0, splitBuff1.byteLength).then(() => {
4065  imageSourceIncrementalSApi.updateData(splitBuff2, true, 0, splitBuff2.byteLength).then(() => {
4066    let pixelMap = imageSourceIncrementalSApi.createPixelMapSync()
4067    let imageInfo = pixelMap.getImageInfoSync()
4068    console.info('Succeeded in creating pixelMap')
4069  }).catch((error : BusinessError) => {
4070    console.error(`Failed to updateData error code is ${error.code}, message is ${error.message}`)
4071  })
4072}).catch((error : BusinessError) => {
4073  console.error(`Failed to updateData error code is ${error.code}, message is ${error.message}`)
4074})
4075```
4076
4077## ImageSource
4078
4079Provides APIs to obtain image information. Before calling any API in **ImageSource**, you must use [createImageSource](#imagecreateimagesource) to create an **ImageSource** instance.
4080
4081### Properties
4082
4083**System capability**: SystemCapability.Multimedia.Image.ImageSource
4084
4085| Name            | Type          | Readable| Writable| Description                                                        |
4086| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
4087| supportedFormats | Array\<string> | Yes  | No  | Supported formats, including .png, .jpeg, .bmp, .gif, .webp, .dng. and .heic<sup>12+</sup> (depending on the hardware).|
4088
4089### getImageInfo
4090
4091getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void
4092
4093Obtains information about an image with the specified index. This API uses an asynchronous callback to return the result.
4094
4095**Widget capability**: This API can be used in ArkTS widgets since API version 12.
4096
4097**Atomic service API**: This API can be used in atomic services since API version 11.
4098
4099**System capability**: SystemCapability.Multimedia.Image.ImageSource
4100
4101**Parameters**
4102
4103| Name  | Type                                  | Mandatory| Description                                    |
4104| -------- | -------------------------------------- | ---- | ---------------------------------------- |
4105| index    | number                                 | Yes  | Index of the image.                    |
4106| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the image information obtained; otherwise, **err** is an error object.|
4107
4108**Example**
4109
4110```ts
4111import { BusinessError } from '@kit.BasicServicesKit';
4112
4113imageSourceApi.getImageInfo(0, (error: BusinessError, imageInfo: image.ImageInfo) => {
4114  if (error) {
4115    console.error(`Failed to obtain the image information.code is ${error.code}, message is ${error.message}`);
4116  } else {
4117    console.info('Succeeded in obtaining the image information.');
4118  }
4119})
4120```
4121
4122### getImageInfo
4123
4124getImageInfo(callback: AsyncCallback\<ImageInfo>): void
4125
4126Obtains information about this image. This API uses an asynchronous callback to return the result.
4127
4128**Widget capability**: This API can be used in ArkTS widgets since API version 12.
4129
4130**Atomic service API**: This API can be used in atomic services since API version 11.
4131
4132**System capability**: SystemCapability.Multimedia.Image.ImageSource
4133
4134**Parameters**
4135
4136| Name  | Type                                  | Mandatory| Description                                    |
4137| -------- | -------------------------------------- | ---- | ---------------------------------------- |
4138| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the image information obtained; otherwise, **err** is an error object.|
4139
4140**Example**
4141
4142```ts
4143import { BusinessError } from '@kit.BasicServicesKit';
4144
4145imageSourceApi.getImageInfo((err: BusinessError, imageInfo: image.ImageInfo) => {
4146  if (err) {
4147    console.error(`Failed to obtain the image information.code is ${err.code}, message is ${err.message}`);
4148  } else {
4149    console.info('Succeeded in obtaining the image information.');
4150  }
4151})
4152```
4153
4154### getImageInfo
4155
4156getImageInfo(index?: number): Promise\<ImageInfo>
4157
4158Obtains information about an image with the specified index. This API uses a promise to return the result.
4159
4160**Widget capability**: This API can be used in ArkTS widgets since API version 12.
4161
4162**Atomic service API**: This API can be used in atomic services since API version 11.
4163
4164**System capability**: SystemCapability.Multimedia.Image.ImageSource
4165
4166**Parameters**
4167
4168| Name| Type  | Mandatory| Description                                 |
4169| ----- | ------ | ---- | ------------------------------------- |
4170| index | number | No  | Index of the image. If this parameter is not set, the default value **0** is used.|
4171
4172**Return value**
4173
4174| Type                            | Description                  |
4175| -------------------------------- | ---------------------- |
4176| Promise<[ImageInfo](#imageinfo)> | Promise used to return the image information.|
4177
4178**Example**
4179
4180```ts
4181import { BusinessError } from '@kit.BasicServicesKit';
4182
4183imageSourceApi.getImageInfo(0)
4184  .then((imageInfo: image.ImageInfo) => {
4185    console.info('Succeeded in obtaining the image information.');
4186  }).catch((error: BusinessError) => {
4187    console.error(`Failed to obtain the image information.code is ${error.code}, message is ${error.message}`);
4188  })
4189```
4190
4191### getImageInfoSync<sup>12+</sup>
4192
4193getImageInfoSync(index?: number): ImageInfo
4194
4195Obtains information about an image with the specified index. This API returns the result synchronously.
4196
4197**System capability**: SystemCapability.Multimedia.Image.ImageSource
4198
4199**Parameters**
4200
4201| Name| Type  | Mandatory| Description                                 |
4202| ----- | ------ | ---- | ------------------------------------- |
4203| index | number | No  | Index of the image. If this parameter is not set, the default value **0** is used.|
4204
4205**Return value**
4206
4207| Type                            | Description                  |
4208| -------------------------------- | ---------------------- |
4209| [ImageInfo](#imageinfo) | Image information.|
4210
4211**Example**
4212
4213```ts
4214import { image } from '@kit.ImageKit';
4215
4216const context: Context = getContext();
4217// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
4218let filePath: string = context.filesDir + "/test.jpg";
4219let imageSource = image.createImageSource(filePath);
4220let imageInfo = imageSource.getImageInfoSync(0);
4221if (imageInfo == undefined) {
4222  console.error('Failed to obtain the image information.');
4223} else {
4224  console.info('Succeeded in obtaining the image information.');
4225  console.info('imageInfo.size.height:' + imageInfo.size.height);
4226  console.info('imageInfo.size.width:' + imageInfo.size.width);
4227}
4228```
4229
4230### getImageProperty<sup>11+</sup>
4231
4232getImageProperty(key:PropertyKey, options?: ImagePropertyOptions): Promise\<string>
4233
4234Obtains the value of a property with the specified index in this image. This API uses a promise to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4235
4236**System capability**: SystemCapability.Multimedia.Image.ImageSource
4237
4238**Parameters**
4239
4240| Name | Type                                                | Mandatory| Description                                |
4241| ------- | ---------------------------------------------------- | ---- | ------------------------------------ |
4242| key     | [PropertyKey](#propertykey7)                                               | Yes  | Name of the property.                        |
4243| options | [ImagePropertyOptions](#imagepropertyoptions11) | No  | Image properties, including the image index and default property value.|
4244
4245**Return value**
4246
4247| Type            | Description                                                             |
4248| ---------------- | ----------------------------------------------------------------- |
4249| Promise\<string> | Promise used to return the property value. If the operation fails, the default value is returned.|
4250
4251**Error codes**
4252
4253For details about the error codes, see [Image Error Codes](errorcode-image.md).
4254
4255| ID| Error Message|
4256| ------- | --------------------------------------------|
4257| 401  | Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;3.Parameter verification failed;              |
4258| 62980096 | The operation failed.             |
4259| 62980103 | The image data is not supported.         |
4260| 62980110 | The image source data is incorrect.      |
4261| 62980111 | The image source data is incomplete. |
4262| 62980112 | The image format does not match.       |
4263| 62980113 | Unknown image format.        |
4264| 62980115 | Invalid image parameter.      |
4265| 62980116| Failed to decode the image.            |
4266| 62980118 | Failed to create the image plugin.   |
4267| 62980122 | Failed to decode the image header.   |
4268| 62980123| Images in EXIF format are not supported.             |
4269| 62980135| The EXIF value is invalid.             |
4270
4271**Example**
4272
4273```ts
4274import { BusinessError } from '@kit.BasicServicesKit';
4275
4276let options: image.ImagePropertyOptions = { index: 0, defaultValue: '9999' }
4277imageSourceApi.getImageProperty(image.PropertyKey.BITS_PER_SAMPLE, options)
4278.then((data: string) => {
4279  console.info('Succeeded in getting the value of the specified attribute key of the image.');
4280}).catch((error: BusinessError) => {
4281  console.error('Failed to get the value of the specified attribute key of the image.');
4282})
4283```
4284
4285### getImageProperty<sup>(deprecated)</sup>
4286
4287getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string>
4288
4289Obtains the value of a property with the specified index in this image. This API uses a promise to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4290
4291> **NOTE**
4292>
4293> This API is deprecated since API version 11. You are advised to use [getImageProperty](#getimageproperty11).
4294
4295**System capability**: SystemCapability.Multimedia.Image.ImageSource
4296
4297**Parameters**
4298
4299| Name | Type                                                | Mandatory| Description                                |
4300| ------- | ---------------------------------------------------- | ---- | ------------------------------------ |
4301| key     | string                                               | Yes  | Name of the property.                        |
4302| options | [GetImagePropertyOptions](#getimagepropertyoptionsdeprecated) | No  | Image properties, including the image index and default property value.|
4303
4304**Return value**
4305
4306| Type            | Description                                                             |
4307| ---------------- | ----------------------------------------------------------------- |
4308| Promise\<string> | Promise used to return the property value. If the operation fails, the default value is returned.|
4309
4310**Example**
4311
4312```ts
4313import { BusinessError } from '@kit.BasicServicesKit';
4314
4315imageSourceApi.getImageProperty("BitsPerSample")
4316  .then((data: string) => {
4317    console.info('Succeeded in getting the value of the specified attribute key of the image.');
4318  }).catch((error: BusinessError) => {
4319    console.error('Failed to get the value of the specified attribute key of the image.');
4320  })
4321```
4322
4323### getImageProperty<sup>(deprecated)</sup>
4324
4325getImageProperty(key:string, callback: AsyncCallback\<string>): void
4326
4327Obtains the value of a property with the specified index in this image. This API uses an asynchronous callback to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4328
4329> **NOTE**
4330>
4331> This API is deprecated since API version 11. You are advised to use [getImageProperty](#getimageproperty11).
4332
4333**System capability**: SystemCapability.Multimedia.Image.ImageSource
4334
4335**Parameters**
4336
4337| Name  | Type                  | Mandatory| Description                                                        |
4338| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
4339| key      | string                 | Yes  | Name of the property.                                                |
4340| callback | AsyncCallback\<string> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the property value obtained; otherwise, **err** is an error object.|
4341
4342**Example**
4343
4344```ts
4345import { BusinessError } from '@kit.BasicServicesKit';
4346
4347imageSourceApi.getImageProperty("BitsPerSample", (error: BusinessError, data: string) => {
4348  if (error) {
4349    console.error('Failed to get the value of the specified attribute key of the image.');
4350  } else {
4351    console.info('Succeeded in getting the value of the specified attribute key of the image.');
4352  }
4353})
4354```
4355
4356### getImageProperty<sup>(deprecated)</sup>
4357
4358getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback\<string>): void
4359
4360Obtains the value of a property in this image. This API uses an asynchronous callback to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4361
4362> **NOTE**
4363>
4364> This API is deprecated since API version 11. You are advised to use [getImageProperty](#getimageproperty11).
4365
4366**System capability**: SystemCapability.Multimedia.Image.ImageSource
4367
4368**Parameters**
4369
4370| Name  | Type                                                | Mandatory| Description                                                         |
4371| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------- |
4372| key      | string                                               | Yes  | Name of the property.                                                 |
4373| options  | [GetImagePropertyOptions](#getimagepropertyoptionsdeprecated) | Yes  | Image properties, including the image index and default property value.                         |
4374| callback | AsyncCallback\<string>                               | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the property value obtained; otherwise, **err** is an error object.|
4375
4376**Example**
4377
4378```ts
4379import { BusinessError } from '@kit.BasicServicesKit';
4380
4381let property: image.GetImagePropertyOptions = { index: 0, defaultValue: '9999' }
4382imageSourceApi.getImageProperty("BitsPerSample", property, (error: BusinessError, data: string) => {
4383  if (error) {
4384    console.error('Failed to get the value of the specified attribute key of the image.');
4385  } else {
4386    console.info('Succeeded in getting the value of the specified attribute key of the image.');
4387  }
4388})
4389```
4390
4391### getImageProperties<sup>12+</sup>
4392
4393getImageProperties(key: Array&#60;PropertyKey&#62;): Promise<Record<PropertyKey, string|null>>
4394
4395Obtains the values of properties with the given names in this image. This API uses a promise to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4396
4397**System capability**: SystemCapability.Multimedia.Image.ImageSource
4398
4399**Parameters**
4400
4401| Name | Type                                                | Mandatory| Description                                |
4402| ------- | ---------------------------------------------------- | ---- | ------------------------------------ |
4403| key     | Array\<[PropertyKey](#propertykey7)>                                 | Yes  | Array of properties names.                        |
4404
4405**Return value**
4406
4407| Type            | Description                                                             |
4408| ---------------- | ----------------------------------------------------------------- |
4409| Promise\<Record<[PropertyKey](#propertykey7), string \| null>> | Promise used to return the property values. If the operation fails, **null** is returned.|
4410
4411**Error codes**
4412
4413For details about the error codes, see [Image Error Codes](errorcode-image.md).
4414
4415| ID| Error Message|
4416| ------- | --------------------------------------------|
4417| 401  | Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;3.Parameter verification failed;     |
4418| 62980096| The operation failed.             |
4419| 62980110| The image source data is incorrect.            |
4420| 62980113| Unknown image format.            |
4421| 62980116| Failed to decode the image.            |
4422
4423**Example**
4424
4425```ts
4426import { image } from '@kit.ImageKit';
4427import { BusinessError } from '@kit.BasicServicesKit';
4428
4429let key = [image.PropertyKey.IMAGE_WIDTH, image.PropertyKey.IMAGE_LENGTH];
4430imageSourceApi.getImageProperties(key).then((data) => {
4431  console.info(JSON.stringify(data));
4432}).catch((err: BusinessError) => {
4433  console.error(JSON.stringify(err));
4434});
4435```
4436
4437### modifyImageProperty<sup>11+</sup>
4438
4439modifyImageProperty(key: PropertyKey, value: string): Promise\<void>
4440
4441Modifies the value of a property in this image. This API uses a promise to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4442
4443> **NOTE**
4444>
4445> The property byte length is changed when the **modifyImageProperty** API is called to modify the value of a property. Currently, you can call the API in an **ImageSource** instance created based on a file descriptor or path, but not an **ImageSource** instance created based on buffers.
4446
4447**System capability**: SystemCapability.Multimedia.Image.ImageSource
4448
4449**Parameters**
4450
4451| Name | Type  | Mandatory| Description        |
4452| ------- | ------ | ---- | ------------ |
4453| key     | [PropertyKey](#propertykey7)   | Yes  | Name of the property.|
4454| value   | string | Yes  | New value of the property.    |
4455
4456**Return value**
4457
4458| Type          | Description                       |
4459| -------------- | --------------------------- |
4460| Promise\<void> | Promise that returns no value.|
4461
4462**Error codes**
4463
4464For details about the error codes, see [Image Error Codes](errorcode-image.md).
4465
4466| ID| Error Message|
4467| ------- | --------------------------------------------|
4468| 401  | Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;    |
4469| 62980123| The image does not support EXIF decoding.             |
4470| 62980133| The EXIF data is out of range.             |
4471| 62980135| The EXIF value is invalid.             |
4472| 62980146| The EXIF data failed to be written to the file.        |
4473
4474**Example**
4475
4476```ts
4477import { BusinessError } from '@kit.BasicServicesKit';
4478
4479imageSourceApi.modifyImageProperty(image.PropertyKey.IMAGE_WIDTH, "120").then(() => {
4480  imageSourceApi.getImageProperty(image.PropertyKey.IMAGE_WIDTH).then((width: string) => {
4481    console.info(`ImageWidth is :${width}`);
4482  }).catch((error: BusinessError) => {
4483    console.error('Failed to get the Image Width.');
4484  })
4485}).catch((error: BusinessError) => {
4486  console.error('Failed to modify the Image Width');
4487})
4488```
4489
4490### modifyImageProperty<sup>(deprecated)</sup>
4491
4492modifyImageProperty(key: string, value: string): Promise\<void>
4493
4494Modifies the value of a property in this image. This API uses a promise to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4495
4496> **NOTE**
4497>
4498> The property byte length is changed when the **modifyImageProperty** API is called to modify the value of a property. Currently, you can call the API in an **ImageSource** instance created based on a file descriptor or path, but not an **ImageSource** instance created based on buffers.
4499>
4500> This API is deprecated since API version 11. You are advised to use [modifyImageProperty](#modifyimageproperty11).
4501
4502**System capability**: SystemCapability.Multimedia.Image.ImageSource
4503
4504**Parameters**
4505
4506| Name | Type  | Mandatory| Description        |
4507| ------- | ------ | ---- | ------------ |
4508| key     | string | Yes  | Name of the property.|
4509| value   | string | Yes  | New value of the property.    |
4510
4511**Return value**
4512
4513| Type          | Description                       |
4514| -------------- | --------------------------- |
4515| Promise\<void> |  Promise that returns no value.|
4516
4517**Example**
4518
4519```ts
4520import { BusinessError } from '@kit.BasicServicesKit';
4521
4522imageSourceApi.modifyImageProperty("ImageWidth", "120").then(() => {
4523  imageSourceApi.getImageProperty("ImageWidth").then((width: string) => {
4524    console.info(`ImageWidth is :${width}`);
4525  }).catch((error: BusinessError) => {
4526    console.error('Failed to get the Image Width.');
4527  })
4528}).catch((error: BusinessError) => {
4529  console.error('Failed to modify the Image Width');
4530})
4531```
4532
4533### modifyImageProperty<sup>(deprecated)</sup>
4534
4535modifyImageProperty(key: string, value: string, callback: AsyncCallback\<void>): void
4536
4537Modifies the value of a property in this image. This API uses an asynchronous callback to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4538
4539> **NOTE**
4540>
4541> The property byte length is changed when the **modifyImageProperty** API is called to modify the value of a property. Currently, you can call the API in an **ImageSource** instance created based on a file descriptor or path, but not an **ImageSource** instance created based on buffers.
4542>
4543>This API is deprecated since API version 11. You are advised to use [modifyImageProperty](#modifyimageproperty11).
4544
4545**System capability**: SystemCapability.Multimedia.Image.ImageSource
4546
4547**Parameters**
4548
4549| Name  | Type               | Mandatory| Description                          |
4550| -------- | ------------------- | ---- | ------------------------------ |
4551| key      | string              | Yes  | Name of the property.                  |
4552| value    | string              | Yes  | New value of the property.                      |
4553| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
4554
4555**Example**
4556
4557```ts
4558import { BusinessError } from '@kit.BasicServicesKit';
4559
4560imageSourceApi.modifyImageProperty("ImageWidth", "120", (err: BusinessError) => {
4561  if (err) {
4562    console.error(`Failed to modify the Image Width.code is ${err.code}, message is ${err.message}`);
4563  } else {
4564    console.info('Succeeded in modifying the Image Width.');
4565  }
4566})
4567```
4568
4569### modifyImageProperties<sup>12+</sup>
4570
4571modifyImageProperties(records: Record<PropertyKey, string|null>): Promise\<void>
4572
4573Modifies the values of properties in this image. This API uses a promise to return the result. This API applies only to images that are in JPEG, PNG, or HEIF<sup>12+</sup> (depending on the hardware) format and contain the EXIF information. You can use the **supportedFormats** property to check whether the EXIF read/write operation for images in HEIF format is supported.
4574
4575> **NOTE**
4576>
4577> The property byte length is changed when the **modifyImageProperties** API is called to modify the values of properties. Currently, you can call the API in an **ImageSource** instance created based on a file descriptor or path, but not an **ImageSource** instance created based on buffers.
4578>
4579
4580**System capability**: SystemCapability.Multimedia.Image.ImageSource
4581
4582**Parameters**
4583
4584| Name | Type  | Mandatory| Description        |
4585| ------- | ------ | ---- | ------------ |
4586| records     | Record<[PropertyKey](#propertykey7), string \| null>   | Yes  | Array of property names and property values.|
4587
4588**Return value**
4589
4590| Type          | Description                       |
4591| -------------- | --------------------------- |
4592| Promise\<void> |  Promise that returns no value.|
4593
4594**Error codes**
4595
4596For details about the error codes, see [Image Error Codes](errorcode-image.md).
4597
4598| ID| Error Message|
4599| ------- | --------------------------------------------|
4600| 401  | Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;3.Parameter verification failed;      |
4601| 62980123| The image does not support EXIF decoding.             |
4602| 62980133| The EXIF data is out of range.             |
4603| 62980135| The EXIF value is invalid.             |
4604| 62980146| The EXIF data failed to be written to the file.             |
4605
4606**Example**
4607
4608```ts
4609import { image } from '@kit.ImageKit';
4610import { BusinessError } from '@kit.BasicServicesKit';
4611
4612let keyValues: Record<PropertyKey, string|null> = {
4613    [image.PropertyKey.IMAGE_WIDTH] : "1024",
4614    [image.PropertyKey.IMAGE_LENGTH] : "1024"
4615};
4616let checkKey = [image.PropertyKey.IMAGE_WIDTH, image.PropertyKey.IMAGE_LENGTH];
4617imageSourceApi.modifyImageProperties(keyValues).then(() => {
4618  imageSourceApi.getImageProperties(checkKey).then((data) => {
4619    console.info(JSON.stringify(data));
4620  }).catch((err: BusinessError) => {
4621    console.error(JSON.stringify(err));
4622  });
4623}).catch((err: BusinessError) => {
4624  console.error(JSON.stringify(err));
4625});
4626```
4627
4628### updateData<sup>9+</sup>
4629
4630updateData(buf: ArrayBuffer, isFinished: boolean, offset: number, length: number): Promise\<void>
4631
4632Updates incremental data. This API uses a promise to return the result.
4633
4634**System capability**: SystemCapability.Multimedia.Image.ImageSource
4635
4636**Parameters**
4637
4638| Name    | Type       | Mandatory| Description        |
4639| ---------- | ----------- | ---- | ------------ |
4640| buf        | ArrayBuffer | Yes  | Incremental data.  |
4641| isFinished | boolean     | Yes  | Whether the update is complete.|
4642| offset      | number      | Yes  | Offset for data reading.    |
4643| length     | number      | Yes  | Array length.    |
4644
4645**Return value**
4646
4647| Type          | Description                      |
4648| -------------- | -------------------------- |
4649| Promise\<void> | Promise that returns no value.|
4650
4651**Example**
4652
4653```ts
4654import { BusinessError } from '@kit.BasicServicesKit';
4655
4656const array: ArrayBuffer = new ArrayBuffer(100);
4657imageSourceApi.updateData(array, false, 0, 10).then(() => {
4658  console.info('Succeeded in updating data.');
4659}).catch((err: BusinessError) => {
4660  console.error(`Failed to update data.code is ${err.code},message is ${err.message}`);
4661})
4662```
4663
4664
4665### updateData<sup>9+</sup>
4666
4667updateData(buf: ArrayBuffer, isFinished: boolean, offset: number, length: number, callback: AsyncCallback\<void>): void
4668
4669Updates incremental data. This API uses an asynchronous callback to return the result.
4670
4671**System capability**: SystemCapability.Multimedia.Image.ImageSource
4672
4673**Parameters**
4674
4675| Name    | Type               | Mandatory| Description                |
4676| ---------- | ------------------- | ---- | -------------------- |
4677| buf        | ArrayBuffer         | Yes  | Incremental data.          |
4678| isFinished | boolean             | Yes  | Whether the update is complete.        |
4679| offset      | number              | Yes  | Offset for data reading.            |
4680| length     | number              | Yes  | Array length.            |
4681| callback   | AsyncCallback\<void> | Yes  |  Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
4682
4683**Example**
4684
4685```ts
4686import { BusinessError } from '@kit.BasicServicesKit';
4687
4688const array: ArrayBuffer = new ArrayBuffer(100);
4689imageSourceApi.updateData(array, false, 0, 10, (err: BusinessError) => {
4690  if (err) {
4691    console.error(`Failed to update data.code is ${err.code},message is ${err.message}`);
4692  } else {
4693    console.info('Succeeded in updating data.');
4694  }
4695})
4696```
4697
4698### createPicture<sup>13+</sup>
4699
4700createPicture(options?: DecodingOptionsForPicture): Promise\<Picture>
4701
4702Creates a **Picture** object based on image decoding parameters. This API uses a promise to return the result.
4703
4704**System capability**: SystemCapability.Multimedia.Image.ImageSource
4705
4706**Parameters**
4707
4708| Name | Type                                                  | Mandatory| Description      |
4709| ------- | ------------------------------------------------------ | ---- | ---------- |
4710| options | [DecodingOptionsForPicture](#decodingoptionsforpicture13) | No  | Image decoding parameters.|
4711
4712**Return value**
4713
4714| Type                        | Description                      |
4715| ---------------------------- | -------------------------- |
4716| Promise\<[Picture](#picture13)> | Promise used to return the **Picture** object.|
4717
4718**Error codes**
4719
4720For details about the error codes, see [Image Error Codes](errorcode-image.md).
4721
4722| ID| Error Message                                                    |
4723| -------- | ------------------------------------------------------------ |
4724| 401      | Parameter error.Possible causes: 1.Mandatory parameters are left unspecified.2.Incorrect parameter types; 3.Parameter verification failed. |
4725| 7700301  | Decode failed.                                               |
4726
4727**Example**
4728
4729```ts
4730import { image } from '@kit.ImageKit';
4731
4732async function CreatePicture() {
4733  let options: image.DecodingOptionsForPicture = {
4734    desiredAuxiliaryPictures: [image.AuxiliaryPictureType.GAINMAP] // GAINMAP indicates the type of the auxiliary picture to be decoded.
4735  };
4736  let pictureObj: image.Picture = await imageSourceApi.createPicture(options);
4737  if (pictureObj != null) {
4738    console.info('Create picture succeeded');
4739  } else {
4740    console.info('Create picture failed');
4741  }
4742}
4743```
4744
4745### createPixelMap<sup>7+</sup>
4746
4747createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
4748
4749Creates a **PixelMap** object based on image decoding parameters. This API uses a promise to return the result.
4750
4751**Widget capability**: This API can be used in ArkTS widgets since API version 12.
4752
4753**Atomic service API**: This API can be used in atomic services since API version 11.
4754
4755**System capability**: SystemCapability.Multimedia.Image.ImageSource
4756
4757**Parameters**
4758
4759| Name | Type                                | Mandatory| Description      |
4760| ------- | ------------------------------------ | ---- | ---------- |
4761| options | [DecodingOptions](#decodingoptions7) | No  | Image decoding parameters.|
4762
4763**Return value**
4764
4765| Type                            | Description                 |
4766| -------------------------------- | --------------------- |
4767| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|
4768
4769**Example**
4770
4771```ts
4772import { BusinessError } from '@kit.BasicServicesKit';
4773
4774imageSourceApi.createPixelMap().then((pixelMap: image.PixelMap) => {
4775  console.info('Succeeded in creating pixelMap object through image decoding parameters.');
4776}).catch((error: BusinessError) => {
4777  console.error('Failed to create pixelMap object through image decoding parameters.');
4778})
4779```
4780
4781### createPixelMap<sup>7+</sup>
4782
4783createPixelMap(callback: AsyncCallback\<PixelMap>): void
4784
4785Creates a **PixelMap** object based on the default parameters. This API uses an asynchronous callback to return the result.
4786
4787**Widget capability**: This API can be used in ArkTS widgets since API version 12.
4788
4789**Atomic service API**: This API can be used in atomic services since API version 11.
4790
4791**System capability**: SystemCapability.Multimedia.Image.ImageSource
4792
4793**Parameters**
4794
4795| Name    | Type                                 | Mandatory| Description                      |
4796| -------- | ------------------------------------- | ---- | -------------------------- |
4797| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes  | Callback used to return the result. If the operation is successful, **err** is undefined and **data** is the **PixelMap** object obtained; otherwise, **err** is an error object.|
4798
4799**Example**
4800
4801```ts
4802import { BusinessError } from '@kit.BasicServicesKit';
4803
4804imageSourceApi.createPixelMap((err: BusinessError, pixelMap: image.PixelMap) => {
4805  if (err) {
4806    console.error(`Failed to create pixelMap.code is ${err.code},message is ${err.message}`);
4807  } else {
4808    console.info('Succeeded in creating pixelMap object.');
4809  }
4810})
4811```
4812
4813### createPixelMap<sup>7+</sup>
4814
4815createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
4816
4817Creates a **PixelMap** object based on image decoding parameters. This API uses an asynchronous callback to return the result.
4818
4819**Widget capability**: This API can be used in ArkTS widgets since API version 12.
4820
4821**Atomic service API**: This API can be used in atomic services since API version 11.
4822
4823**System capability**: SystemCapability.Multimedia.Image.ImageSource
4824
4825**Parameters**
4826
4827| Name  | Type                                 | Mandatory| Description                      |
4828| -------- | ------------------------------------- | ---- | -------------------------- |
4829| options  | [DecodingOptions](#decodingoptions7)  | Yes  | Image decoding parameters.                |
4830| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes  | Callback used to return the result. If the operation is successful, **err** is undefined and **data** is the **PixelMap** object obtained; otherwise, **err** is an error object.|
4831
4832**Example**
4833
4834```ts
4835import { BusinessError } from '@kit.BasicServicesKit';
4836
4837let decodingOptions: image.DecodingOptions = {
4838  sampleSize: 1,
4839  editable: true,
4840  desiredSize: { width: 1, height: 2 },
4841  rotate: 10,
4842  desiredPixelFormat: image.PixelMapFormat.RGBA_8888,
4843  desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 },
4844  index: 0
4845};
4846imageSourceApi.createPixelMap(decodingOptions, (err: BusinessError, pixelMap: image.PixelMap) => {
4847  if (err) {
4848    console.error(`Failed to create pixelMap.code is ${err.code},message is ${err.message}`);
4849  } else {
4850    console.info('Succeeded in creating pixelMap object.');
4851  }
4852})
4853```
4854
4855### createPixelMapSync<sup>12+</sup>
4856
4857createPixelMapSync(options?: DecodingOptions): PixelMap
4858
4859Creates a **PixelMap** object based on image decoding parameters. This API returns the result synchronously.
4860
4861**System capability**: SystemCapability.Multimedia.Image.ImageSource
4862
4863**Parameters**
4864
4865| Name  | Type                                 | Mandatory| Description                      |
4866| -------- | ------------------------------------- | ---- | -------------------------- |
4867| options  | [DecodingOptions](#decodingoptions7)  | No  | Image decoding parameters.                |
4868
4869**Return value**
4870
4871| Type                            | Description                 |
4872| -------------------------------- | --------------------- |
4873| [PixelMap](#pixelmap7) | **PixelMap** object.|
4874
4875**Example**
4876
4877```ts
4878import { image } from '@kit.ImageKit';
4879
4880const context: Context = getContext();
4881// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
4882let filePath: string = context.filesDir + "/test.jpg";
4883let imageSource = image.createImageSource(filePath);
4884let decodingOptions: image.DecodingOptions = {
4885  sampleSize: 1,
4886  editable: true,
4887  desiredSize: { width: 1, height: 2 },
4888  rotate: 10,
4889  desiredPixelFormat: image.PixelMapFormat.RGBA_8888,
4890  desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 },
4891  index: 0
4892};
4893let pixelmap = imageSource.createPixelMapSync(decodingOptions);
4894if (pixelmap != undefined) {
4895  console.info('Succeeded in creating pixelMap object.');
4896} else {
4897  console.info('Failed to create pixelMap.');
4898}
4899```
4900
4901### createPixelMapList<sup>10+</sup>
4902
4903createPixelMapList(options?: DecodingOptions): Promise<Array\<PixelMap>>
4904
4905Creates an array of **PixelMap** objects based on image decoding parameters. This API uses a promise to return the result. For dynamic images such as GIF and WebP images, this API returns the data of each frame of the image. For static images, this API returns the data of the unique frame of the image.
4906
4907**System capability**: SystemCapability.Multimedia.Image.ImageSource
4908
4909**Parameters**
4910
4911| Name  | Type                                 | Mandatory| Description                      |
4912| -------- | ------------------------------------- | ---- | -------------------------- |
4913| options  | [DecodingOptions](#decodingoptions7)  | No  | Image decoding parameters.                |
4914
4915**Return value**
4916
4917| Type                            | Description                 |
4918| -------------------------------- | --------------------- |
4919| Promise<Array<[PixelMap](#pixelmap7)>> | Promise used to return an array of **PixelMap** objects.|
4920
4921**Error codes**
4922
4923For details about the error codes, see [Image Error Codes](errorcode-image.md).
4924
4925| ID| Error Message|
4926| ------- | --------------------------------------------|
4927| 62980096| The operation failed.              |
4928| 62980099 | The shared memory data is abnormal. |
4929| 62980101 | The image data is abnormal. |
4930| 62980103| The image data is not supported.             |
4931| 62980106 | The image is too large. |
4932| 62980109 | Failed to crop the image. |
4933| 62980110| The image source data is incorrect.             |
4934| 62980111| The image source data is incomplete.           |
4935| 62980112 | The image format does not match. |
4936| 62980113 | Unknown image format. |
4937| 62980115 | Invalid image parameter. |
4938| 62980116 | Failed to decode the image. |
4939| 62980118| Failed to create the image plugin.             |
4940| 62980122 | Failed to decode the image header. |
4941| 62980137 | Invalid media operation. |
4942| 62980173 | The DMA memory does not exist. |
4943| 62980174 | The DMA memory data is abnormal. |
4944
4945**Example**
4946
4947```ts
4948import { BusinessError } from '@kit.BasicServicesKit';
4949
4950let decodeOpts: image.DecodingOptions = {
4951  sampleSize: 1,
4952  editable: true,
4953  desiredSize: { width: 198, height: 202 },
4954  rotate: 0,
4955  desiredPixelFormat: image.PixelMapFormat.RGBA_8888,
4956  index: 0,
4957};
4958imageSourceApi.createPixelMapList(decodeOpts).then((pixelMapList: Array<image.PixelMap>) => {
4959  console.info('Succeeded in creating pixelMapList object.');
4960}).catch((err: BusinessError) => {
4961  console.error(`Failed to create pixelMapList object.code is ${err.code},message is ${err.message}`);
4962})
4963```
4964
4965### createPixelMapList<sup>10+</sup>
4966
4967createPixelMapList(callback: AsyncCallback<Array\<PixelMap>>): void
4968
4969Creates an array of **PixelMap** objects based on the default parameters. This API uses an asynchronous callback to return the result. For dynamic images such as GIF and WebP images, this API returns the data of each frame of the image. For static images, this API returns the data of the unique frame of the image.
4970
4971**System capability**: SystemCapability.Multimedia.Image.ImageSource
4972
4973**Parameters**
4974
4975| Name    | Type                                 | Mandatory| Description                      |
4976| -------- | ------------------------------------- | ---- | -------------------------- |
4977| callback | AsyncCallback<Array<[PixelMap](#pixelmap7)>> | Yes  | Callback used to return the result. If the operation is successful, **err** is undefined and **data** is the array of **PixelMap** objects obtained; otherwise, **err** is an error object. |
4978
4979**Error codes**
4980
4981For details about the error codes, see [Image Error Codes](errorcode-image.md).
4982
4983| ID| Error Message|
4984| ------- | --------------------------------------------|
4985| 62980096 | The operation failed.             |
4986| 62980099 | The shared memory data is abnormal.  |
4987| 62980101 | The image data is abnormal.          |
4988| 62980103 | The image data is not supported.         |
4989| 62980106 | The image is too large.              |
4990| 62980109 | Failed to crop the image.            |
4991| 62980110 | The image source data is incorrect.      |
4992| 62980111 | The image source data is incomplete. |
4993| 62980112 | The image format does not match.       |
4994| 62980113 | Unknown image format.        |
4995| 62980115 | Invalid image parameter.      |
4996| 62980116 | Failed to decode the image.         |
4997| 62980118 | Failed to create the image plugin.   |
4998| 62980122 | Failed to decode the image header.   |
4999| 62980137 | Invalid media operation.     |
5000| 62980173 | The DMA memory does not exist.        |
5001| 62980174 | The DMA memory data is abnormal.    |
5002
5003**Example**
5004
5005```ts
5006import { BusinessError } from '@kit.BasicServicesKit';
5007
5008imageSourceApi.createPixelMapList((err: BusinessError, pixelMapList: Array<image.PixelMap>) => {
5009  if (err) {
5010    console.error(`Failed to create pixelMapList object.code is ${err.code},message is ${err.message}`);
5011  } else {
5012    console.info('Succeeded in creating pixelMapList object.');
5013  }
5014})
5015```
5016
5017### createPixelMapList<sup>10+</sup>
5018
5019createPixelMapList(options: DecodingOptions, callback: AsyncCallback<Array\<PixelMap>>): void
5020
5021Creates an array of **PixelMap** objects based on image decoding parameters. This API uses an asynchronous callback to return the result. For dynamic images such as GIF and WebP images, this API returns the data of each frame of the image. For static images, this API returns the data of the unique frame of the image.
5022
5023**System capability**: SystemCapability.Multimedia.Image.ImageSource
5024
5025**Parameters**
5026
5027| Name  | Type                | Mandatory| Description                              |
5028| -------- | -------------------- | ---- | ---------------------------------- |
5029| options | [DecodingOptions](#decodingoptions7) | Yes| Image decoding parameters.|
5030| callback | AsyncCallback<Array<[PixelMap](#pixelmap7)>> | Yes  | Callback used to return the result. If the operation is successful, **err** is undefined and **data** is the array of **PixelMap** objects obtained; otherwise, **err** is an error object. |
5031
5032**Error codes**
5033
5034For details about the error codes, see [Image Error Codes](errorcode-image.md).
5035
5036| ID| Error Message|
5037| ------- | --------------------------------------------|
5038| 62980096 | The operation failed.            |
5039| 62980099 | The shared memory data is abnormal.  |
5040| 62980101 | The image data is abnormal.         |
5041| 62980103 | The image data is not supported.        |
5042| 62980106 | The image is too large.              |
5043| 62980109 | Failed to crop the image.           |
5044| 62980110 | The image source data is incorrect.      |
5045| 62980111 | The image source data is incomplete. |
5046| 62980112 | The image format does not match.        |
5047| 62980113 | Unknown image format.         |
5048| 62980115 | Invalid image parameter.      |
5049| 62980116 | Failed to decode the image.         |
5050| 62980118 | Failed to create the image plugin.  |
5051| 62980122 | Failed to decode the image header.   |
5052| 62980137 | Invalid media operation.      |
5053| 62980173 | The DMA memory does not exist.         |
5054| 62980174 | The DMA memory data is abnormal.     |
5055
5056**Example**
5057
5058```ts
5059import { BusinessError } from '@kit.BasicServicesKit';
5060
5061let decodeOpts: image.DecodingOptions = {
5062  sampleSize: 1,
5063  editable: true,
5064  desiredSize: { width: 198, height: 202 },
5065  rotate: 0,
5066  desiredPixelFormat: image.PixelMapFormat.RGBA_8888,
5067  index: 0,
5068};
5069imageSourceApi.createPixelMapList(decodeOpts, (err: BusinessError, pixelMapList: Array<image.PixelMap>) => {
5070  if (err) {
5071    console.error(`Failed to create pixelMapList object.code is ${err.code},message is ${err.message}`);
5072  } else {
5073    console.info('Succeeded in creating pixelMapList object.');
5074  }
5075})
5076```
5077
5078### getDelayTimeList<sup>10+</sup>
5079
5080getDelayTimeList(callback: AsyncCallback<Array\<number>>): void
5081
5082Obtains an array of delay times. This API uses an asynchronous callback to return the result. This API applies only to images in GIF or WebP format.
5083
5084**System capability**: SystemCapability.Multimedia.Image.ImageSource
5085
5086**Parameters**
5087
5088| Name  | Type                | Mandatory| Description                              |
5089| -------- | -------------------- | ---- | ---------------------------------- |
5090| callback | AsyncCallback<Array\<number>> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the array of delay times obtained; otherwise, **err** is an error object.|
5091
5092**Error codes**
5093
5094For details about the error codes, see [Image Error Codes](errorcode-image.md).
5095
5096| ID| Error Message|
5097| ------- | --------------------------------------------|
5098| 62980096| The operation failed.              |
5099| 62980110| The image source data is incorrect.             |
5100| 62980111| The image source data is incomplete.            |
5101| 62980112 | The image format does not match. |
5102| 62980113| Unknown image format. |
5103| 62980115 | Invalid image parameter. |
5104| 62980116| Failed to decode the image. |
5105| 62980118| Failed to create the image plugin. |
5106| 62980122| Failed to decode the image header. |
5107| 62980137 | Invalid media operation. |
5108| 62980149 | Invalid MIME type for the image source. |
5109
5110**Example**
5111
5112```ts
5113import { BusinessError } from '@kit.BasicServicesKit';
5114
5115imageSourceApi.getDelayTimeList((err: BusinessError, delayTimes: Array<number>) => {
5116  if (err) {
5117    console.error(`Failed to get delayTimes object.code is ${err.code},message is ${err.message}`);
5118  } else {
5119    console.info('Succeeded in getting delayTimes object.');
5120  }
5121})
5122```
5123
5124### getDelayTimeList<sup>10+</sup>
5125
5126getDelayTimeList(): Promise<Array\<number>>
5127
5128Obtains an array of delay times. This API uses a promise to return the result. This API applies only to images in GIF or WebP format.
5129
5130**System capability**: SystemCapability.Multimedia.Image.ImageSource
5131
5132**Return value**
5133
5134| Type          | Description                       |
5135| -------------- | --------------------------- |
5136| Promise<Array\<number>> | Promise used to return an array of delay times.|
5137
5138**Error codes**
5139
5140For details about the error codes, see [Image Error Codes](errorcode-image.md).
5141
5142| ID| Error Message|
5143| ------- | --------------------------------------------|
5144| 62980096 | The operation failed.             |
5145| 62980110 | The image source data is incorrect.      |
5146| 62980111 | The image source data is incomplete. |
5147| 62980112 | The image format does not match.        |
5148| 62980113 | Unknown image format.         |
5149| 62980115 | Invalid image parameter.      |
5150| 62980116 | Failed to decode the image.          |
5151| 62980118 | Failed to create the image plugin.  |
5152| 62980122 | Failed to decode the image header.   |
5153| 62980137 | Invalid media operation.      |
5154| 62980149 | Invalid MIME type for the image source.      |
5155
5156**Example**
5157
5158```ts
5159import { BusinessError } from '@kit.BasicServicesKit';
5160
5161imageSourceApi.getDelayTimeList().then((delayTimes: Array<number>) => {
5162  console.info('Succeeded in getting delayTimes object.');
5163}).catch((err: BusinessError) => {
5164  console.error(`Failed to get delayTimes object.code is ${err.code},message is ${err.message}`);
5165})
5166```
5167
5168### getFrameCount<sup>10+</sup>
5169
5170getFrameCount(callback: AsyncCallback\<number>): void
5171
5172Obtains the number of frames. This API uses an asynchronous callback to return the result.
5173
5174**System capability**: SystemCapability.Multimedia.Image.ImageSource
5175
5176**Parameters**
5177
5178| Name  | Type                | Mandatory| Description                              |
5179| -------- | -------------------- | ---- | ---------------------------------- |
5180| callback | AsyncCallback\<number> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the number of frames obtained; otherwise, **err** is an error object.|
5181
5182**Error codes**
5183
5184For details about the error codes, see [Image Error Codes](errorcode-image.md).
5185
5186| ID| Error Message|
5187| ------- | --------------------------------------------|
5188| 62980096| The operation failed.              |
5189| 62980110| The image source data is incorrect. |
5190| 62980111| The image source data is incomplete. |
5191| 62980112| The image format does not match. |
5192| 62980113| Unknown image format. |
5193| 62980115| Invalid image parameter. |
5194| 62980116| Failed to decode the image. |
5195| 62980118| Failed to create the image plugin. |
5196| 62980122| Failed to decode the image header. |
5197| 62980137| Invalid media operation. |
5198
5199**Example**
5200
5201```ts
5202import { BusinessError } from '@kit.BasicServicesKit';
5203
5204imageSourceApi.getFrameCount((err: BusinessError, frameCount: number) => {
5205  if (err) {
5206    console.error(`Failed to get frame count.code is ${err.code},message is ${err.message}`);
5207  } else {
5208    console.info('Succeeded in getting frame count.');
5209  }
5210})
5211```
5212
5213### getFrameCount<sup>10+</sup>
5214
5215getFrameCount(): Promise\<number>
5216
5217Obtains the number of frames. This API uses a promise to return the result.
5218
5219**System capability**: SystemCapability.Multimedia.Image.ImageSource
5220
5221**Return value**
5222
5223| Type          | Description                       |
5224| -------------- | --------------------------- |
5225| Promise\<number> | Promise used to return the number of frames.|
5226
5227**Error codes**
5228
5229For details about the error codes, see [Image Error Codes](errorcode-image.md).
5230
5231| ID| Error Message|
5232| ------- | --------------------------------------------|
5233| 62980096 | The operation failed.             |
5234| 62980110 | The image source data is incorrect.      |
5235| 62980111 | The image source data is incomplete. |
5236| 62980112 | The image format does not match.        |
5237| 62980113 | Unknown image format.         |
5238| 62980115 | Invalid image parameter.      |
5239| 62980116 | Failed to decode the image.          |
5240| 62980118 | Failed to create the image plugin.   |
5241| 62980122 | Failed to decode the image header.  |
5242| 62980137 | Invalid media operation.      |
5243
5244**Example**
5245
5246```ts
5247import { BusinessError } from '@kit.BasicServicesKit';
5248
5249imageSourceApi.getFrameCount().then((frameCount: number) => {
5250  console.info('Succeeded in getting frame count.');
5251}).catch((err: BusinessError) => {
5252  console.error(`Failed to get frame count.code is ${err.code},message is ${err.message}`);
5253})
5254```
5255
5256### getDisposalTypeList<sup>12+</sup>
5257
5258getDisposalTypeList(): Promise\<Array\<number>>
5259
5260Obtains the list of disposal types. This API uses a promise to return the result. It is used only for GIF images.
5261
5262**System capability**: SystemCapability.Multimedia.Image.ImageSource
5263
5264**Return value**
5265
5266| Type          | Description                       |
5267| -------------- | --------------------------- |
5268| Promise\<Array\<number>> | Promise used to return an array of disposal types.|
5269
5270**Error codes**
5271
5272For details about the error codes, see [Image Error Codes](errorcode-image.md).
5273
5274| ID| Error Message|
5275| ------- | --------------------------------------------|
5276| 62980096 | The operation failed.      |
5277| 62980101 | The image data is abnormal. |
5278| 62980137 | Invalid media operation.        |
5279| 62980149 | Invalid MIME type for the image source.      |
5280
5281**Example**
5282
5283```ts
5284import { BusinessError } from '@kit.BasicServicesKit';
5285imageSourceApi.getDisposalTypeList().then((disposalTypes: Array<number>) => {
5286  console.info('Succeeded in getting disposalTypes object.');
5287}).catch((err: BusinessError) => {
5288  console.error(`Failed to get disposalTypes object.code ${err.code},message is ${err.message}`);
5289})
5290```
5291
5292### release
5293
5294release(callback: AsyncCallback\<void>): void
5295
5296Releases this **ImageSource** instance. This API uses an asynchronous callback to return the result.
5297
5298ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImageSource** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
5299
5300**System capability**: SystemCapability.Multimedia.Image.ImageSource
5301
5302**Parameters**
5303
5304| Name  | Type                | Mandatory| Description                              |
5305| -------- | -------------------- | ---- | ---------------------------------- |
5306| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
5307
5308**Example**
5309
5310```ts
5311import { BusinessError } from '@kit.BasicServicesKit';
5312
5313imageSourceApi.release((err: BusinessError) => {
5314  if (err) {
5315    console.error(`Failed to release the image source instance.code ${err.code},message is ${err.message}`);
5316  } else {
5317    console.info('Succeeded in releasing the image source instance.');
5318  }
5319})
5320```
5321
5322### release
5323
5324release(): Promise\<void>
5325
5326Releases this **ImageSource** instance. This API uses a promise to return the result.
5327
5328ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImageSource** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
5329
5330**System capability**: SystemCapability.Multimedia.Image.ImageSource
5331
5332**Return value**
5333
5334| Type          | Description                       |
5335| -------------- | --------------------------- |
5336| Promise\<void> |  Promise that returns no value.|
5337
5338**Example**
5339
5340```ts
5341import { BusinessError } from '@kit.BasicServicesKit';
5342
5343imageSourceApi.release().then(() => {
5344  console.info('Succeeded in releasing the image source instance.');
5345}).catch((error: BusinessError) => {
5346  console.error(`Failed to release the image source instance.code ${error.code},message is ${error.message}`);
5347})
5348```
5349
5350## image.createImagePacker
5351
5352createImagePacker(): ImagePacker
5353
5354Creates an **ImagePacker** instance.
5355
5356**Atomic service API**: This API can be used in atomic services since API version 11.
5357
5358**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5359
5360**Return value**
5361
5362| Type                       | Description                 |
5363| --------------------------- | --------------------- |
5364| [ImagePacker](#imagepacker) | **ImagePacker** instance created.|
5365
5366**Example**
5367
5368```ts
5369const imagePackerApi: image.ImagePacker = image.createImagePacker();
5370```
5371
5372## ImagePacker
5373
5374Provides APIs to pack images. Before calling any API in **ImagePacker**, you must use [createImagePacker](#imagecreateimagepacker) to create an **ImagePacker** object. Currently, this class applies only to images in .jpeg, .webp, .png, or heif<sup>12+</sup> (depending on the hardware).
5375
5376### Properties
5377
5378**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5379
5380| Name            | Type          | Readable| Writable| Description                      |
5381| ---------------- | -------------- | ---- | ---- | -------------------------- |
5382| supportedFormats | Array\<string> | Yes  | No  | Supported formats, including .jpeg, .webp, .png, and heic<sup>12+</sup> (depending on the hardware).|
5383
5384### packToData<sup>13+</sup>
5385
5386packToData(source: ImageSource, options: PackingOption): Promise\<ArrayBuffer>
5387
5388Packs an image. This API uses a promise to return the result.
5389
5390**Atomic service API**: This API can be used in atomic services since API version 13.
5391
5392**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5393
5394**Parameters**
5395
5396| Name| Type                           | Mandatory| Description          |
5397| ------ | ------------------------------- | ---- | -------------- |
5398| source | [ImageSource](#imagesource)     | Yes  | Image to pack.|
5399| options | [PackingOption](#packingoption) | Yes  | Option for image packing.|
5400
5401**Error codes**
5402
5403For details about the error codes, see [Image Error Codes](errorcode-image.md).
5404
5405| ID| Error Message|
5406| ------- | --------------------------------------------|
5407| 401 | If the parameter is invalid. |
5408| 62980096| The Operation failed.              |
5409| 62980101 | The image data is abnormal. |
5410| 62980106 | The image is too large. |
5411| 62980113 | Unknown image format. |
5412| 62980119 | If encoder occur error during encoding.             |
5413| 62980120 | Add pixelmap out of range. |
5414| 62980172 | Failed to encode icc. |
5415| 62980252 | Failed to create surface. |
5416
5417**Return value**
5418
5419| Type                        | Description                                         |
5420| ---------------------------- | --------------------------------------------- |
5421| Promise\<ArrayBuffer>        | Promise used to return the packed image data.|
5422
5423**Example**
5424
5425```ts
5426import { BusinessError } from '@kit.BasicServicesKit';
5427
5428const context: Context = getContext();
5429// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
5430let filePath: string = context.filesDir + "/test.jpg";
5431const imageSourceApi: image.ImageSource = image.createImageSource(filePath);
5432let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 }
5433imagePackerApi.packToData(imageSourceApi, packOpts)
5434  .then((data: ArrayBuffer) => {
5435    console.info('Succeeded in packing the image.');
5436  }).catch((error: BusinessError) => {
5437    console.error(`Failed to pack the image.code ${error.code},message is ${error.message}`);
5438  })
5439```
5440
5441### packToData<sup>13+</sup>
5442
5443packToData(source: PixelMap, options: PackingOption): Promise\<ArrayBuffer>
5444
5445Packs an image. This API uses a promise to return the result.
5446
5447> **NOTE**
5448>
5449> If error code 401 is returned, the parameters are abnormal. The possible cause is that the **PixelMap** object is released in advance. You need to check the code and ensure that the **PixelMap** object is released after this API is called.
5450
5451**Atomic service API**: This API can be used in atomic services since API version 13.
5452
5453**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5454
5455**Parameters**
5456
5457| Name| Type                           | Mandatory| Description              |
5458| ------ | ------------------------------- | ---- | ------------------ |
5459| source | [PixelMap](#pixelmap7)           | Yes  | **PixelMap** object to pack.|
5460| options | [PackingOption](#packingoption) | Yes  | Option for image packing.    |
5461
5462**Return value**
5463
5464| Type                 | Description                                        |
5465| --------------------- | -------------------------------------------- |
5466| Promise\<ArrayBuffer> | Promise used to return the packed image data.|
5467
5468**Error codes**
5469
5470For details about the error codes, see [Image Error Codes](errorcode-image.md).
5471
5472| ID| Error Message|
5473| ------- | --------------------------------------------|
5474| 401 | If the parameter is invalid. |
5475| 62980096| The Operation failed.              |
5476| 62980101 | The image data is abnormal. |
5477| 62980106 | The image is too large. |
5478| 62980113 | Unknown image format. |
5479| 62980119 | If encoder occur error during encoding.             |
5480| 62980120 | Add pixelmap out of range. |
5481| 62980172 | Failed to encode icc. |
5482| 62980252 | Failed to create surface. |
5483
5484**Example**
5485
5486```ts
5487import { BusinessError } from '@kit.BasicServicesKit';
5488
5489const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
5490let opts: image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
5491image.createPixelMap(color, opts).then((pixelMap: image.PixelMap) => {
5492  let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 }
5493  imagePackerApi.packToData(pixelMap, packOpts)
5494    .then((data: ArrayBuffer) => {
5495      console.info('Succeeded in packing the image.');
5496    }).catch((error: BusinessError) => {
5497    console.error(`Failed to pack the image.code ${error.code},message is ${error.message}`);
5498  })
5499}).catch((error: BusinessError) => {
5500  console.error(`Failed to create PixelMap.code ${error.code},message is ${error.message}`);
5501})
5502```
5503
5504### packing<sup>13+</sup>
5505
5506packing(picture: Picture, options: PackingOption): Promise\<ArrayBuffer>
5507
5508Packs a picture. This API uses a promise to return the result.
5509
5510**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5511
5512**Parameters**
5513
5514| Name          | Type                                                | Mandatory| Description                |
5515| ---------------- | ---------------------------------------------------- | ---- | -------------------- |
5516| picture | [Picture](#picture13)                           | Yes  | **Picture** object to pack.|
5517| options          | [PackingOption](#packingoption) | Yes  | Option for image packing.      |
5518
5519**Return value**
5520
5521| Type                 | Description                                 |
5522| --------------------- | ------------------------------------- |
5523| Promise\<ArrayBuffer> | Promise used to return the packed image data.|
5524
5525**Error codes**
5526
5527For details about the error codes, see [Image Error Codes](errorcode-image.md).
5528
5529| ID| Error Message                                                    |
5530| -------- | ------------------------------------------------------------ |
5531| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
5532| 7800301  | Encode failed.                                         |
5533
5534**Example**
5535
5536```ts
5537import { BusinessError } from '@kit.BasicServicesKit';
5538import { image } from '@kit.ImageKit';
5539
5540async function Packing() {
5541  const context = getContext();
5542  const resourceMgr = context.resourceManager;
5543  const rawFile = await resourceMgr.getRawFileContent("test.jpg");
5544  let ops: image.SourceOptions = {
5545    sourceDensity: 98,
5546  }
5547  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
5548  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
5549  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
5550
5551  let funcName = "Packing";
5552  if (imagePackerApi != null) {
5553    let opts: image.PackingOption = {
5554      format: "image/jpeg",
5555      quality: 98,
5556      bufferSize: 10,
5557      desiredDynamicRange: image.PackingDynamicRange.AUTO,
5558      needsPackProperties: true};
5559    await imagePackerApi.packing(pictureObj, opts).then((data: ArrayBuffer) => {
5560        console.info(funcName, 'Succeeded in packing the image.'+ data);
5561      }).catch((error: BusinessError) => {
5562        console.error(funcName, 'Failed to pack the image.code ${error.code},message is ${error.message}');
5563      });
5564  }
5565}
5566```
5567
5568### packing<sup>13+</sup>
5569
5570packing(pixelmapSequence: Array\<PixelMap>, options: PackingOptionsForSequence): Promise\<ArrayBuffer>
5571
5572Encodes multiple PixelMaps into a GIF file. This API uses a promise to return the result.
5573
5574**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5575
5576**Parameters**
5577
5578| Name          | Type                                                     | Mandatory| Description                  |
5579| ---------------- | --------------------------------------------------------- | ---- | ---------------------- |
5580| pixelmapSequence | Array\<[PixelMap](#pixelmap7)>                            | Yes  | PixelMaps to encode.|
5581| options          | [PackingOptionsForSequence](#packingoptionsforsequence13) | Yes  | Image encoding parameters.        |
5582
5583**Return value**
5584
5585| Type                 | Description                           |
5586| --------------------- | ------------------------------- |
5587| Promise\<ArrayBuffer> | Promise used to return the encoded data.|
5588
5589**Example**
5590
5591```ts
5592import { BusinessError } from '@ohos.base';
5593import image from "@ohos.multimedia.image";
5594
5595async function Packing() {
5596  const RGBA_8888 = image.PixelMapFormat.RGBA_8888;
5597  const context = getContext();
5598  const resourceMgr = context.resourceManager;
5599  // 'moving_test.gif' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
5600  const fileData = await resourceMgr.getRawFileContent('moving_test.gif');
5601  const color = fileData.buffer;
5602  let imageSource = image.createImageSource(color);
5603  let pixelMapList = await imageSource.createPixelMapList();
5604  let ops: image.PackingOptionsForSequence = {
5605    frameCount: 3, // Set the number of frames in GIF encoding to 3.
5606    delayTimeList: [10, 10, 10], // Set the delay time of three frames in GIF encoding to 100 ms, 100 ms, and 100 ms, respectively.
5607    disposalTypes: [3, 2, 3], // Specify the frame transition modes of the three frames in GIF encoding as 3 (restore to the previous state), 2 (restore to the background color), and 3 (restore to the previous state).
5608    loopCount: 0 // Set the number of loops in GIF encoding to infinite.
5609  };
5610  let Packer = image.createImagePacker();
5611  Packer.packing(pixelMapList, ops)
5612    .then((data: ArrayBuffer) => {
5613      console.info('Succeeded in packing.');
5614    }).catch((error: BusinessError) => {
5615      console.error('Failed to packing.');
5616    })
5617}
5618```
5619
5620### packing<sup>(deprecated)</sup>
5621
5622packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void
5623
5624Packs an image. This API uses an asynchronous callback to return the result.
5625
5626> **NOTE**
5627>
5628> This API is supported since API version 6 and deprecated since API version 13. Use [packToData](#packtodata13) instead.
5629
5630**Atomic service API**: This API can be used in atomic services since API version 11.
5631
5632**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5633
5634**Parameters**
5635
5636| Name  | Type                              | Mandatory| Description                              |
5637| -------- | ---------------------------------- | ---- | ---------------------------------- |
5638| source   | [ImageSource](#imagesource)        | Yes  | Image to pack.                    |
5639| option   | [PackingOption](#packingoption)    | Yes  | Option for image packing.                     |
5640| callback | AsyncCallback\<ArrayBuffer>        | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the packed image data; otherwise, **err** is an error object. |
5641
5642**Example**
5643
5644```ts
5645import { BusinessError } from '@kit.BasicServicesKit';
5646
5647const context: Context = getContext();
5648// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
5649let filePath: string = context.filesDir + "/test.jpg";
5650const imageSourceApi: image.ImageSource = image.createImageSource(filePath);
5651let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 };
5652imagePackerApi.packing(imageSourceApi, packOpts, (err: BusinessError, data: ArrayBuffer) => {
5653  if (err) {
5654    console.error(`Failed to pack the image.code ${err.code},message is ${err.message}`);
5655  } else {
5656    console.info('Succeeded in packing the image.');
5657  }
5658})
5659```
5660
5661### packing<sup>(deprecated)</sup>
5662
5663packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer>
5664
5665Packs an image. This API uses a promise to return the result.
5666
5667> **NOTE**
5668>
5669> This API is supported since API version 6 and deprecated since API version 13. Use [packToData](#packtodata13) instead.
5670
5671**Atomic service API**: This API can be used in atomic services since API version 11.
5672
5673**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5674
5675**Parameters**
5676
5677| Name| Type                           | Mandatory| Description          |
5678| ------ | ------------------------------- | ---- | -------------- |
5679| source | [ImageSource](#imagesource)     | Yes  | Image to pack.|
5680| option | [PackingOption](#packingoption) | Yes  | Option for image packing.|
5681
5682**Return value**
5683
5684| Type                        | Description                                         |
5685| ---------------------------- | --------------------------------------------- |
5686| Promise\<ArrayBuffer>        | Promise used to return the packed image data.|
5687
5688**Example**
5689
5690```ts
5691import { BusinessError } from '@kit.BasicServicesKit';
5692
5693const context: Context = getContext();
5694// 'test.jpg' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
5695let filePath: string = context.filesDir + "/test.jpg";
5696const imageSourceApi: image.ImageSource = image.createImageSource(filePath);
5697let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 }
5698imagePackerApi.packing(imageSourceApi, packOpts)
5699  .then((data: ArrayBuffer) => {
5700    console.info('Succeeded in packing the image.');
5701  }).catch((error: BusinessError) => {
5702    console.error(`Failed to pack the image.code ${error.code},message is ${error.message}`);
5703  })
5704```
5705
5706### packing<sup>(deprecated)</sup>
5707
5708packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void
5709
5710Packs an image. This API uses an asynchronous callback to return the result.
5711
5712> **NOTE**
5713>
5714> This API is supported since API version 8 and deprecated since API version 13. Use [packToData](#packtodata13) instead.
5715
5716> **NOTE**
5717> If the message "PixelMap mismatch" is returned, the parameters are abnormal. The possible cause is that the **PixelMap** object is released in advance. You need to check the code and ensure that the **PixelMap** object is released after this API is called.
5718
5719**Atomic service API**: This API can be used in atomic services since API version 11.
5720
5721**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5722
5723**Parameters**
5724
5725| Name  | Type                           | Mandatory| Description                              |
5726| -------- | ------------------------------- | ---- | ---------------------------------- |
5727| source   | [PixelMap](#pixelmap7)           | Yes  | **PixelMap** object to pack.              |
5728| option   | [PackingOption](#packingoption) | Yes  | Option for image packing.                    |
5729| callback | AsyncCallback\<ArrayBuffer>     | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the packed image data; otherwise, **err** is an error object. |
5730
5731**Example**
5732
5733```ts
5734import { BusinessError } from '@kit.BasicServicesKit';
5735
5736const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
5737let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
5738image.createPixelMap(color, opts).then((pixelMap: image.PixelMap) => {
5739  let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 }
5740  imagePackerApi.packing(pixelMap, packOpts, (err: BusinessError, data: ArrayBuffer) => {
5741    if (err) {
5742      console.error(`Failed to pack the image.code ${err.code},message is ${err.message}`);
5743    } else {
5744      console.info('Succeeded in packing the image.');
5745    }
5746  })
5747}).catch((error: BusinessError) => {
5748  console.error(`Failed to create the PixelMap.code ${error.code},message is ${error.message}`);
5749})
5750```
5751
5752### packing<sup>(deprecated)</sup>
5753
5754packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer>
5755
5756Packs an image. This API uses a promise to return the result.
5757
5758> **NOTE**
5759>
5760> This API is supported since API version 8 and deprecated since API version 13. Use [packToData](#packtodata13) instead.
5761>
5762> If the message "PixelMap mismatch" is returned, the parameters are abnormal. The possible cause is that the **PixelMap** object is released in advance. You need to check the code and ensure that the **PixelMap** object is released after this API is called.
5763
5764**Atomic service API**: This API can be used in atomic services since API version 11.
5765
5766**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5767
5768**Parameters**
5769
5770| Name| Type                           | Mandatory| Description              |
5771| ------ | ------------------------------- | ---- | ------------------ |
5772| source | [PixelMap](#pixelmap7)           | Yes  | **PixelMap** object to pack.|
5773| option | [PackingOption](#packingoption) | Yes  | Option for image packing.    |
5774
5775**Return value**
5776
5777| Type                 | Description                                        |
5778| --------------------- | -------------------------------------------- |
5779| Promise\<ArrayBuffer> | Promise used to return the packed image data.|
5780
5781**Example**
5782
5783```ts
5784import { BusinessError } from '@kit.BasicServicesKit';
5785
5786const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
5787let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
5788image.createPixelMap(color, opts).then((pixelMap: image.PixelMap) => {
5789  let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 }
5790  imagePackerApi.packing(pixelMap, packOpts)
5791    .then((data: ArrayBuffer) => {
5792      console.info('Succeeded in packing the image.');
5793    }).catch((error: BusinessError) => {
5794    console.error(`Failed to pack the image.code ${error.code},message is ${error.message}`);
5795  })
5796}).catch((error: BusinessError) => {
5797  console.error(`Failed to create PixelMap.code ${error.code},message is ${error.message}`);
5798})
5799```
5800
5801### release
5802
5803release(callback: AsyncCallback\<void>): void
5804
5805Releases this **ImagePacker** instance. This API uses an asynchronous callback to return the result.
5806
5807ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImagePacker** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
5808
5809**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5810
5811**Parameters**
5812
5813| Name  | Type                | Mandatory| Description                          |
5814| -------- | -------------------- | ---- | ------------------------------ |
5815| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
5816
5817**Example**
5818
5819```ts
5820import { BusinessError } from '@kit.BasicServicesKit';
5821
5822imagePackerApi.release((err: BusinessError)=>{
5823  if (err) {
5824    console.error(`Failed to release image packaging.code ${err.code},message is ${err.message}`);
5825  } else {
5826    console.info('Succeeded in releasing image packaging.');
5827  }
5828})
5829```
5830
5831### release
5832
5833release(): Promise\<void>
5834
5835Releases this **ImagePacker** instance. This API uses a promise to return the result.
5836
5837ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImagePacker** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
5838
5839**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5840
5841**Return value**
5842
5843| Type          | Description                                                  |
5844| -------------- | ------------------------------------------------------ |
5845| Promise\<void> |  Promise that returns no value.|
5846
5847**Example**
5848
5849```ts
5850import { BusinessError } from '@kit.BasicServicesKit';
5851
5852imagePackerApi.release().then(() => {
5853  console.info('Succeeded in releasing image packaging.');
5854}).catch((error: BusinessError) => {
5855  console.error(`Failed to release image packaging.code ${error.code},message is ${error.message}`);
5856})
5857```
5858
5859### packToFile<sup>11+</sup>
5860
5861packToFile(source: ImageSource, fd: number, options: PackingOption, callback: AsyncCallback\<void>): void
5862
5863Encodes an **ImageSource** object and packs it into a file. This API uses an asynchronous callback to return the result.
5864
5865**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5866
5867**Parameters**
5868
5869| Name  | Type                           | Mandatory| Description                          |
5870| -------- | ------------------------------- | ---- | ------------------------------ |
5871| source   | [ImageSource](#imagesource)     | Yes  | Image to pack.                |
5872| fd       | number                          | Yes  | File descriptor.                  |
5873| options   | [PackingOption](#packingoption) | Yes  | Option for image packing.                |
5874| callback | AsyncCallback\<void>            | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
5875
5876**Error codes**
5877
5878For details about the error codes, see [Image Error Codes](errorcode-image.md).
5879
5880| ID| Error Message|
5881| ------- | --------------------------------------------|
5882| 62980096| The Operation failed.              |
5883| 62980101 | The image data is abnormal. |
5884| 62980106 | The image is too large. |
5885| 62980113 | Unknown image format. |
5886| 62980115 | If the parameter is invalid. |
5887| 62980119 | If encoder occur error during encoding.             |
5888| 62980120 | Add pixelmap out of range. |
5889| 62980172 | Failed to encode icc. |
5890| 62980252 | Failed to create surface. |
5891
5892**Example**
5893
5894```ts
5895import { BusinessError } from '@kit.BasicServicesKit';
5896import { fileIo as fs } from '@kit.CoreFileKit';
5897
5898const context: Context = getContext(this);
5899// 'test.png' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
5900const path: string = context.filesDir + "/test.png";
5901const imageSourceApi: image.ImageSource = image.createImageSource(path);
5902let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 };
5903const filePath: string = context.filesDir + "/image_source.jpg";
5904let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
5905const imagePackerApi: image.ImagePacker = image.createImagePacker();
5906imagePackerApi.packToFile(imageSourceApi, file.fd, packOpts, (err: BusinessError) => {
5907  if (err) {
5908    console.error(`Failed to pack the image to file.code ${err.code},message is ${err.message}`);
5909  } else {
5910    console.info('Succeeded in packing the image to file.');
5911  }
5912})
5913```
5914
5915### packToFile<sup>11+</sup>
5916
5917packToFile (source: ImageSource, fd: number, options: PackingOption): Promise\<void>
5918
5919Encodes an **ImageSource** object and packs it into a file. This API uses a promise to return the result.
5920
5921**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5922
5923**Parameters**
5924
5925| Name| Type                           | Mandatory| Description          |
5926| ------ | ------------------------------- | ---- | -------------- |
5927| source | [ImageSource](#imagesource)     | Yes  | Image to pack.|
5928| fd     | number                          | Yes  | File descriptor.  |
5929| options | [PackingOption](#packingoption) | Yes  | Option for image packing.|
5930
5931**Return value**
5932
5933| Type          | Description                             |
5934| -------------- | --------------------------------- |
5935| Promise\<void> |  Promise that returns no value.|
5936
5937**Error codes**
5938
5939For details about the error codes, see [Image Error Codes](errorcode-image.md).
5940
5941| ID| Error Message|
5942| ------- | --------------------------------------------|
5943| 62980096| The Operation failed.              |
5944| 62980101 | The image data is abnormal. |
5945| 62980106 | The image is too large. |
5946| 62980113 | Unknown image format. |
5947| 62980115 | If the parameter is invalid. |
5948| 62980119 | If encoder occur error during encoding.             |
5949| 62980120 | Add pixelmap out of range. |
5950| 62980172 | Failed to encode icc. |
5951| 62980252 | Failed to create surface. |
5952
5953**Example**
5954
5955```ts
5956import { BusinessError } from '@kit.BasicServicesKit';
5957import { fileIo as fs } from '@kit.CoreFileKit';
5958
5959const context: Context = getContext(this);
5960// 'test.png' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
5961const path: string = context.filesDir + "/test.png";
5962const imageSourceApi: image.ImageSource = image.createImageSource(path);
5963let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 };
5964const filePath: string = context.filesDir + "/image_source.jpg";
5965let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
5966const imagePackerApi: image.ImagePacker = image.createImagePacker();
5967imagePackerApi.packToFile(imageSourceApi, file.fd, packOpts).then(() => {
5968  console.info('Succeeded in packing the image to file.');
5969}).catch((error: BusinessError) => {
5970  console.error(`Failed to pack the image to file.code ${error.code},message is ${error.message}`);
5971})
5972```
5973
5974### packToFile<sup>11+</sup>
5975
5976packToFile (source: PixelMap, fd: number, options: PackingOption,  callback: AsyncCallback\<void>): void;
5977
5978Encodes a **PixelMap** object and packs it into a file. This API uses an asynchronous callback to return the result.
5979
5980> **NOTE**
5981>
5982> If error code 62980115 is returned, the parameters are abnormal. The possible cause is that the **PixelMap** object is released in advance. You need to check the code and ensure that the **PixelMap** object is released after this API is called.
5983
5984**System capability**: SystemCapability.Multimedia.Image.ImagePacker
5985
5986**Parameters**
5987
5988| Name  | Type                           | Mandatory| Description                          |
5989| -------- | ------------------------------- | ---- | ------------------------------ |
5990| source   | [PixelMap](#pixelmap7)          | Yes  | **PixelMap** object to pack.          |
5991| fd       | number                          | Yes  | File descriptor.                  |
5992| options   | [PackingOption](#packingoption) | Yes  | Option for image packing.                |
5993| callback | AsyncCallback\<void>            | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
5994
5995**Error codes**
5996
5997For details about the error codes, see [Image Error Codes](errorcode-image.md).
5998
5999| ID| Error Message|
6000| ------- | --------------------------------------------|
6001| 62980096| The Operation failed.              |
6002| 62980101 | The image data is abnormal. |
6003| 62980106 | The image is too large. |
6004| 62980113 | Unknown image format. |
6005| 62980115 | If the parameter is invalid. |
6006| 62980119 | If encoder occur error during encoding.             |
6007| 62980120 | Add pixelmap out of range. |
6008| 62980172 | Failed to encode icc. |
6009| 62980252 | Failed to create surface. |
6010
6011**Example**
6012
6013```ts
6014import { BusinessError } from '@kit.BasicServicesKit';
6015import { fileIo as fs } from '@kit.CoreFileKit';
6016
6017const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
6018let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
6019const context: Context = getContext(this);
6020const path: string = context.filesDir + "/pixel_map.jpg";
6021image.createPixelMap(color, opts).then((pixelmap: image.PixelMap) => {
6022  let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 }
6023  let file = fs.openSync(path, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
6024  const imagePackerApi: image.ImagePacker = image.createImagePacker();
6025  imagePackerApi.packToFile(pixelmap, file.fd, packOpts, (err: BusinessError) => {
6026    if (err) {
6027      console.error(`Failed to pack the image to file.code ${err.code},message is ${err.message}`);
6028    } else {
6029      console.info('Succeeded in packing the image to file.');
6030    }
6031  })
6032})
6033```
6034
6035### packToFile<sup>11+</sup>
6036
6037packToFile (source: PixelMap, fd: number, options: PackingOption): Promise\<void>
6038
6039Encodes a **PixelMap** object and packs it into a file. This API uses a promise to return the result.
6040
6041> **NOTE**
6042>
6043> If error code 62980115 is returned, the parameters are abnormal. The possible cause is that the **PixelMap** object is released in advance. You need to check the code and ensure that the **PixelMap** object is released after this API is called.
6044
6045**System capability**: SystemCapability.Multimedia.Image.ImagePacker
6046
6047**Parameters**
6048
6049| Name| Type                           | Mandatory| Description                |
6050| ------ | ------------------------------- | ---- | -------------------- |
6051| source | [PixelMap](#pixelmap7)          | Yes  | **PixelMap** object to pack.|
6052| fd     | number                          | Yes  | File descriptor.        |
6053| options | [PackingOption](#packingoption) | Yes  | Option for image packing.      |
6054
6055**Return value**
6056
6057| Type          | Description                             |
6058| -------------- | --------------------------------- |
6059| Promise\<void> |  Promise that returns no value.|
6060
6061**Error codes**
6062
6063For details about the error codes, see [Image Error Codes](errorcode-image.md).
6064
6065| ID| Error Message|
6066| ------- | --------------------------------------------|
6067| 62980096| The Operation failed.              |
6068| 62980101 | The image data is abnormal. |
6069| 62980106 | The image is too large. |
6070| 62980113 | Unknown image format. |
6071| 62980115 | If the parameter is invalid. |
6072| 62980119 | If encoder occur error during encoding.             |
6073| 62980120 | Add pixelmap out of range. |
6074| 62980172 | Failed to encode icc. |
6075| 62980252 | Failed to create surface. |
6076
6077**Example**
6078
6079```ts
6080import { BusinessError } from '@kit.BasicServicesKit';
6081import { fileIo as fs } from '@kit.CoreFileKit';
6082
6083const color: ArrayBuffer = new ArrayBuffer(96); // 96 is the size of the pixel buffer to create. The value is calculated as follows: height * width *4.
6084let opts: image.InitializationOptions = { editable: true, pixelFormat: image.PixelMapFormat.RGBA_8888, size: { height: 4, width: 6 } }
6085const context: Context = getContext(this);
6086const path: string = context.filesDir + "/pixel_map.jpg";
6087image.createPixelMap(color, opts).then((pixelmap: image.PixelMap) => {
6088  let packOpts: image.PackingOption = { format: "image/jpeg", quality: 98 }
6089  let file = fs.openSync(path, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
6090  const imagePackerApi: image.ImagePacker = image.createImagePacker();
6091  imagePackerApi.packToFile(pixelmap, file.fd, packOpts)
6092    .then(() => {
6093      console.info('Succeeded in packing the image to file.');
6094    }).catch((error: BusinessError) => {
6095    console.error(`Failed to pack the image to file.code ${error.code},message is ${error.message}`);
6096  })
6097})
6098```
6099
6100### packToFile<sup>13+</sup>
6101
6102packToFile(picture: Picture, fd: number, options: PackingOption): Promise\<void>
6103
6104Encodes a **Picture** object and packs it into a file. This API uses a promise to return the result.
6105
6106**System capability**: SystemCapability.Multimedia.Image.ImagePacker
6107
6108**Parameters**
6109
6110| Name | Type                        | Mandatory| Description                |
6111| ------- | ---------------------------- | ---- | -------------------- |
6112| picture  | [Picture](#picture13)          | Yes  | **Picture** object to pack.|
6113| fd      | number                       | Yes  | File descriptor.        |
6114| options | [PackingOption](#packingoption) | Yes  | Option for image packing.      |
6115
6116**Return value**
6117
6118| Type          | Description                     |
6119| -------------- | ------------------------- |
6120| Promise\<void> | that returns no value.|
6121
6122**Error codes**
6123
6124For details about the error codes, see [Image Error Codes](errorcode-image.md).
6125
6126| ID| Error Message                                                    |
6127| -------- | ------------------------------------------------------------ |
6128| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6129| 7800301  | Encode failed.                                         |
6130
6131**Example**
6132
6133```ts
6134import { BusinessError } from '@kit.BasicServicesKit';
6135import { image } from '@kit.ImageKit';
6136import { fileIo as fs } from '@kit.CoreFileKit';
6137
6138async function PackToFile() {
6139  const context = getContext();
6140  const resourceMgr = context.resourceManager;
6141  const rawFile = await resourceMgr.getRawFileContent("test.jpg");
6142  let ops: image.SourceOptions = {
6143    sourceDensity: 98,
6144  }
6145  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
6146  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
6147  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
6148
6149  let funcName = "PackToFile";
6150  if (imagePackerApi != null) {
6151    const context: Context = getContext();
6152    const filePath: string = context.filesDir + "/test.jpg";
6153    let file = fs.openSync(filePath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
6154    let packOpts: image.PackingOption = {
6155      format: "image/jpeg",
6156      quality: 98,
6157      bufferSize: 10,
6158      desiredDynamicRange: image.PackingDynamicRange.AUTO,
6159      needsPackProperties: true};
6160    await imagePackerApi.packToFile(pictureObj, file.fd, packOpts).then(() => {
6161      console.info(funcName, 'Succeeded in packing the image to file.');
6162    }).catch((error: BusinessError) => {
6163      console.error(funcName, 'Failed to pack the image to file.code ${error.code},message is ${error.message}');
6164    });
6165  }
6166}
6167```
6168
6169### packToFile<sup>13+</sup>
6170
6171packToFile(pixelmapSequence: Array\<PixelMap>, fd: number, options: PackingOptionsForSequence): Promise\<void>
6172
6173Encodes multiple PixelMaps into a GIF file. This API uses a promise to return the result.
6174
6175**System capability**: SystemCapability.Multimedia.Image.ImagePacker
6176
6177**Parameters**
6178
6179| Name          | Type                                                     | Mandatory| Description                  |
6180| ---------------- | --------------------------------------------------------- | ---- | ---------------------- |
6181| pixelmapSequence | Array<[PixelMap](#pixelmap7)>                             | Yes  | PixelMaps to encode.|
6182| fd               | number                                                    | Yes  | File descriptor.          |
6183| options          | [PackingOptionsForSequence](#packingoptionsforsequence13) | Yes  | Image encoding parameters.        |
6184
6185**Return value**
6186
6187| Type          | Description                     |
6188| -------------- | ------------------------- |
6189| Promise\<void> | that returns no value.|
6190
6191**Example**
6192
6193```ts
6194import { BusinessError } from '@ohos.base';
6195import fs from '@ohos.file.fs';
6196import image from "@ohos.multimedia.image";
6197
6198async function Packing() {
6199  const RGBA_8888 = image.PixelMapFormat.RGBA_8888;
6200  const context = getContext();
6201  const resourceMgr = context.resourceManager;
6202  // 'moving_test.gif' is only an example. Replace it with the actual one in use. Otherwise, the imageSource instance fails to be created, and subsequent operations cannot be performed.
6203  const fileData = await resourceMgr.getRawFileContent('moving_test.gif');
6204  const color = fileData.buffer;
6205  let imageSource = image.createImageSource(color);
6206  let pixelMapList = await imageSource.createPixelMapList();
6207  let path: string = context.cacheDir + '/result.gif';
6208  let file = fs.openSync(path, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
6209  let ops: image.PackingOptionsForSequence = {
6210    frameCount: 3, // Set the number of frames in GIF encoding to 3.
6211    delayTimeList: [10, 10, 10], // Set the delay time of three frames in GIF encoding to 100 ms, 100 ms, and 100 ms, respectively.
6212    disposalTypes: [3, 2, 3], // Specify the frame transition modes of the three frames in GIF encoding as 3 (restore to the previous state), 2 (restore to the background color), and 3 (restore to the previous state).
6213    loopCount: 0 // Set the number of loops in GIF encoding to infinite.
6214  };
6215  let Packer = image.createImagePacker();
6216  Packer.packToFile(pixelMapList, file.fd, ops)
6217    .then(() => {
6218      console.info('Succeeded in packToFileMultiFrames.');
6219    }).catch((error: BusinessError) => {
6220    console.error('Failed to packToFileMultiFrames.');
6221    })
6222}
6223```
6224
6225## image.createAuxiliaryPicture<sup>13+</sup>
6226
6227createAuxiliaryPicture(buffer: ArrayBuffer, size: Size, type: AuxiliaryPictureType): AuxiliaryPicture
6228
6229Creates an **AuxiliaryPicture** instance based on the ArrayBuffer image data, auxiliary picture size, and auxiliary picture type.
6230
6231**System capability**: SystemCapability.Multimedia.Image.Core
6232
6233**Parameters**
6234
6235| Name| Type                                           | Mandatory| Description                        |
6236| ------ | ----------------------------------------------- | ---- | ---------------------------- |
6237| buffer | ArrayBuffer                                     | Yes  | Image data stored in the buffer.|
6238| size   | [Size](#size)                                   | Yes  | Size of the auxiliary picture.              |
6239| type   | [AuxiliaryPictureType](#auxiliarypicturetype13) | Yes  | Type of the auxiliary picture.                |
6240
6241**Return value**
6242
6243| Type                                   | Description                                      |
6244| --------------------------------------- | ------------------------------------------ |
6245| [AuxiliaryPicture](#auxiliarypicture13) | **AuxiliaryPicture** instance if the operation is successful.|
6246
6247**Error codes**
6248
6249For details about the error codes, see [Image Error Codes](errorcode-image.md).
6250
6251| ID| Error Message                                                    |
6252| -------- | ------------------------------------------------------------ |
6253| 401      | Parameter error.Possible causes:1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6254
6255**Example**
6256
6257```ts
6258import { image } from '@kit.ImageKit';
6259
6260async function CreateAuxiliaryPicture() {
6261  let funcName = "CreateAuxiliaryPicture";
6262  const context = getContext();
6263  const resourceMgr = context.resourceManager;
6264  const rawFile = await resourceMgr.getRawFileContent("hdr.jpg"); // Support for HDR images is required.
6265  let auxBuffer: ArrayBuffer = rawFile.buffer as ArrayBuffer;
6266  let auxSize: Size = {
6267    height: 180,
6268    width: 240
6269  };
6270  let auxType: image.AuxiliaryPictureType = image.AuxiliaryPictureType.GAINMAP;
6271  let auxPictureObj: image.AuxiliaryPicture | null = image.createAuxiliaryPicture(auxBuffer, auxSize, auxType);
6272  if(auxPictureObj != null) {
6273    let type: image.AuxiliaryPictureType = auxPictureObj.getType();
6274    console.info(funcName, 'CreateAuxiliaryPicture succeeded this.Aux_picture.type.' + JSON.stringify(type));
6275  } else {
6276    console.error(funcName, 'CreateAuxiliaryPicture failed');
6277  }
6278}
6279```
6280
6281## AuxiliaryPicture<sup>13+</sup>
6282
6283The auxiliary picture is generally used to assist the main picture in displaying special information, so that the image includes richer information. The **AuxiliaryPicture** class is used to read or write auxiliary picture data of an image and obtain auxiliary picture information of an image. Before calling any API in **AuxiliaryPicture**, you must use [createAuxiliaryPicture](#imagecreateauxiliarypicture13) to create an **AuxiliaryPicture** object.
6284
6285### Properties
6286
6287**System capability**: SystemCapability.Multimedia.Image.Core
6288
6289### writePixelsFromBuffer<sup>13+</sup>
6290
6291writePixelsFromBuffer(data: ArrayBuffer): Promise\<void>
6292
6293Reads pixels from an ArrayBuffer and writes the data to this **AuxiliaryPicture** object. This API uses a promise to return the result.
6294
6295**System capability**: SystemCapability.Multimedia.Image.Core
6296
6297**Parameters**
6298
6299| Name| Type       | Mandatory| Description            |
6300| ------ | ----------- | ---- | ---------------- |
6301| data   | ArrayBuffer | Yes  | Pixels of the auxiliary picture.|
6302
6303**Return value**
6304
6305| Type          | Description                                  |
6306| -------------- | -------------------------------------- |
6307| Promise\<void> | Promise that returns no value.|
6308
6309**Error codes**
6310
6311For details about the error codes, see [Image Error Codes](errorcode-image.md).
6312
6313| ID| Error Message                                                    |
6314| -------- | ------------------------------------------------------------ |
6315| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6316| 7600301  | Memory alloc failed.                                         |
6317| 7600302  | Memory copy failed.                                          |
6318
6319**Example**
6320
6321```ts
6322import { image } from '@kit.ImageKit';
6323
6324async function WritePixelsFromBuffer() {
6325  const context = getContext();
6326  const resourceMgr = context.resourceManager;
6327  const rawFile = await resourceMgr.getRawFileContent("hdr.jpg"); // Support for HDR images is required.
6328  let ops: image.SourceOptions = {
6329    sourceDensity: 98,
6330  }
6331  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
6332  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
6333  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
6334  let auxPictureObj: image.AuxiliaryPicture | null = pictureObj.getAuxiliaryPicture(image.AuxiliaryPictureType.GAINMAP);
6335  if(auxPictureObj != null) {
6336    let auxBuffer: ArrayBuffer = await auxPictureObj.readPixelsToBuffer();
6337    await auxPictureObj.writePixelsFromBuffer(auxBuffer);
6338    console.info('Write pixels from buffer success.');
6339  } else {
6340    console.error('AuxPictureObj is null.');
6341  }
6342}
6343```
6344
6345### readPixelsToBuffer<sup>13+</sup>
6346
6347readPixelsToBuffer(): Promise\<ArrayBuffer>
6348
6349Reads pixels of this auxiliary picture and writes the data to an ArrayBuffer. This API uses a promise to return the result.
6350
6351**System capability**: SystemCapability.Multimedia.Image.Core
6352
6353**Return value**
6354
6355| Type                 | Description                             |
6356| --------------------- | --------------------------------- |
6357| Promise\<ArrayBuffer> | Promise used to return the pixels of the auxiliary picture.|
6358
6359**Error codes**
6360
6361For details about the error codes, see [Image Error Codes](errorcode-image.md).
6362
6363| ID| Error Message            |
6364| -------- | -------------------- |
6365| 7600301  | Memory alloc failed. |
6366| 7600302  | Memory copy failed.  |
6367
6368**Example**
6369
6370```ts
6371import { BusinessError } from '@kit.BasicServicesKit';
6372import { image } from '@kit.ImageKit';
6373
6374async function ReadPixelsToBuffer() {
6375  const context = getContext();
6376  const resourceMgr = context.resourceManager;
6377  const rawFile = await resourceMgr.getRawFileContent("hdr.jpg"); // Support for HDR images is required.
6378  let ops: image.SourceOptions = {
6379    sourceDensity: 98,
6380  }
6381  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
6382  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
6383  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
6384  let auxPictureObj: image.AuxiliaryPicture | null = pictureObj.getAuxiliaryPicture(image.AuxiliaryPictureType.GAINMAP);
6385  if(auxPictureObj != null) {
6386    await auxPictureObj.readPixelsToBuffer().then((pixelsBuffer: ArrayBuffer) => {
6387      console.info('Read pixels to buffer success.' );
6388    }).catch((error: BusinessError) => {
6389      console.error('Read pixels to buffer failed error.code: ' + JSON.stringify(error.code) + ' ,error.message:' + JSON.stringify(error.message));
6390    });
6391  } else {
6392    console.error('AuxPictureObj is null.');
6393  }
6394}
6395```
6396
6397### getType<sup>13+</sup>
6398
6399getType(): AuxiliaryPictureType
6400
6401Obtains the type of this auxiliary picture.
6402
6403**System capability**: SystemCapability.Multimedia.Image.Core
6404
6405**Return value**
6406
6407| Type                                           | Description                        |
6408| ----------------------------------------------- | ---------------------------- |
6409| [AuxiliaryPictureType](#auxiliarypicturetype13) | Type of the auxiliary picture.|
6410
6411**Example**
6412
6413```ts
6414import { image } from '@kit.ImageKit';
6415
6416async function GetAuxiliaryPictureType() {
6417  if (auxPictureObj != null) {
6418    let type: image.AuxiliaryPictureType = auxPictureObj.getType();
6419    console.info('Success get auxiliary picture type ' +  JSON.stringify(type));
6420  } else {
6421    console.info('Failed get auxiliary picture type ');
6422  }
6423}
6424```
6425
6426### setMetadata<sup>13+</sup>
6427
6428setMetadata(metadataType: MetadataType, metadata: Metadata): Promise\<void>
6429
6430Sets the metadata for this auxiliary picture.
6431
6432**System capability**: SystemCapability.Multimedia.Image.Core
6433
6434**Parameters**
6435
6436| Name      | Type                           | Mandatory| Description                                |
6437| ------------ | ------------------------------- | ---- | ------------------------------------ |
6438| metadataType | [MetadataType](#metadatatype13) | Yes  | Metadata type, which is used to set the corresponding metadata.|
6439| metadata     | [Metadata](#metadata13)         | Yes  | **Metadata** object.                        |
6440
6441**Return value**
6442
6443| Type          | Description                                  |
6444| -------------- | -------------------------------------- |
6445| Promise\<void> | Promise that returns no value.|
6446
6447**Error codes**
6448
6449For details about the error codes, see [Image Error Codes](errorcode-image.md).
6450
6451| ID| Error Message                                                    |
6452| -------- | ------------------------------------------------------------ |
6453| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6454| 7600202  | Unsupported metadata. Possible causes: 1. Unsupported metadata type. 2. The metadata type does not match the auxiliary picture type. |
6455
6456**Example**
6457
6458```ts
6459import { BusinessError } from '@kit.BasicServicesKit';
6460import { image } from '@kit.ImageKit';
6461
6462async function SetAuxPictureObjMetadata() {
6463  const exifContext = getContext();
6464  const exifResourceMgr = exifContext.resourceManager;
6465  const exifRawFile = await exifResourceMgr.getRawFileContent("exif.jpg");// The image contains EXIF metadata.
6466  let exifOps: image.SourceOptions = {
6467    sourceDensity: 98,
6468  }
6469  let exifImageSource: image.ImageSource = image.createImageSource(exifRawFile.buffer as ArrayBuffer, exifOps);
6470  let exifCommodityPixelMap: image.PixelMap = await exifImageSource.createPixelMap();
6471  let exifPictureObj: image.Picture = image.createPicture(exifCommodityPixelMap);
6472  if (exifPictureObj != null) {
6473    console.info('Create picture succeeded');
6474  } else {
6475    console.info('Create picture failed');
6476  }
6477
6478  if (auxPictureObj != null) {
6479    let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
6480    let exifMetaData: image.Metadata = await exifPictureObj.getMetadata(metadataType);
6481    auxPictureObj.setMetadata(metadataType, exifMetaData).then(() => {
6482      console.info('Set metadata success');
6483    }).catch((error: BusinessError) => {
6484      console.error('Set metadata failed.error.code: ${error.code}, error.message: ${error.message}');
6485    });
6486  } else {
6487    console.info('AuxPictureObjMetaData is null');
6488  }
6489}
6490```
6491
6492### getMetadata<sup>13+</sup>
6493
6494getMetadata(metadataType: MetadataType): Promise\<Metadata>
6495
6496Obtains the metadata of this auxiliary picture.
6497
6498**System capability**: SystemCapability.Multimedia.Image.Core
6499
6500**Parameters**
6501
6502| Name      | Type                           | Mandatory| Description                                  |
6503| ------------ | ------------------------------- | ---- | -------------------------------------- |
6504| metadataType | [MetadataType](#metadatatype13) | Yes  | Metadata type, which is used to obtain metadata of the corresponding type.|
6505
6506**Return value**
6507
6508| Type                            | Description            |
6509| -------------------------------- | ---------------- |
6510| Promise<[Metadata](#metadata13)> | Metadata object.|
6511
6512**Error codes**
6513
6514For details about the error codes, see [Image Error Codes](errorcode-image.md).
6515
6516| ID| Error Message                                                    |
6517| -------- | ------------------------------------------------------------ |
6518| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6519| 7600202  | Unsupported metadata. Possible causes: 1. Unsupported metadata type. 2. The metadata type does not match the auxiliary picture type. |
6520
6521**Example**
6522
6523```ts
6524import { image } from '@kit.ImageKit';
6525
6526async function GetAuxPictureObjMetadata() {
6527  if (auxPictureObj != null) {
6528    let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
6529    let auxPictureObjMetaData: image.Metadata | null = await auxPictureObj.getMetadata(metadataType);
6530    if (auxPictureObjMetaData != null) {
6531      console.info('Get auxpictureobj Metadata success' );
6532    } else {
6533      console.info('Get auxpictureobj Metadata failed');
6534    }
6535  } else {
6536    console.info('Get auxpictureobj is null.');
6537  }
6538}
6539```
6540
6541### getAuxiliaryPictureinfo<sup>13+</sup>
6542
6543getAuxiliaryPictureInfo(): AuxiliaryPictureInfo
6544
6545Obtains the auxiliary picture information.
6546
6547**System capability**: SystemCapability.Multimedia.Image.Core
6548
6549**Return value**
6550
6551| Type                                           | Description                             |
6552| ----------------------------------------------- | --------------------------------- |
6553| [AuxiliaryPictureInfo](#auxiliarypictureinfo13) | Promise used to return the auxiliary picture information.|
6554
6555**Example**
6556
6557```ts
6558import { image } from '@kit.ImageKit';
6559
6560async function GetAuxiliaryPictureInfo() {
6561  if(auxPictureObj != null) {
6562    let auxinfo: image.AuxiliaryPictureInfo = auxPictureObj.getAuxiliaryPictureInfo();
6563    console.info('GetAuxiliaryPictureInfo Type: ' + auxinfo.auxiliaryPictureType +
6564      ' height: ' + auxinfo.size.height + ' width: ' + auxinfo.size.width +
6565      ' rowStride: ' +  auxinfo.rowStride +  ' pixelFormat: ' + auxinfo.pixelFormat +
6566      ' colorSpace: ' +  auxinfo.colorSpace);
6567  } else {
6568    console.info('Get auxiliary picture information failed');
6569  }
6570}
6571```
6572
6573### setAuxiliaryPictureinfo<sup>13+</sup>
6574
6575setAuxiliaryPictureInfo(info: AuxiliaryPictureInfo): void
6576
6577Sets the auxiliary picture information.
6578
6579**System capability**: SystemCapability.Multimedia.Image.Core
6580
6581**Parameters**
6582
6583| Name| Type                                           | Mandatory| Description              |
6584| ------ | ----------------------------------------------- | ---- | ------------------ |
6585| info   | [AuxiliaryPictureInfo](#auxiliarypictureinfo13) | Yes  | Auxiliary picture information.|
6586
6587**Error codes**
6588
6589For details about the error codes, see [Image Error Codes](errorcode-image.md).
6590
6591| ID| Error Message                                                    |
6592| -------- | :----------------------------------------------------------- |
6593| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. |
6594
6595**Example**
6596
6597```ts
6598import { colorSpaceManager } from '@kit.ArkGraphics2D';
6599import { image } from '@kit.ImageKit';
6600
6601async function SetAuxiliaryPictureInfo() {
6602  if(auxPictureObj != null) {
6603    let colorSpaceName = colorSpaceManager.ColorSpace.SRGB;
6604    let info: image.AuxiliaryPictureInfo = {
6605      auxiliaryPictureType: image.AuxiliaryPictureType.GAINMAP,
6606      size: {height: 100, width: 200},
6607      pixelFormat: image.PixelMapFormat.RGBA_8888,
6608      rowStride: 0,
6609      colorSpace: colorSpaceManager.create(colorSpaceName),
6610    };
6611    auxPictureObj.setAuxiliaryPictureInfo(info);
6612  }
6613}
6614```
6615
6616### release<sup>13+</sup>
6617
6618release():void
6619
6620Releases this AuxiliaryPicture object. No value is returned.
6621
6622**System capability**: SystemCapability.Multimedia.Image.Core
6623
6624**Example**
6625
6626```ts
6627import { image } from '@kit.ImageKit';
6628
6629async function Release() {
6630  let funcName = "Release";
6631  if (auxPictureObj != null) {
6632    auxPictureObj.release();
6633    if (auxPictureObj.getType() == null) {
6634      console.info(funcName, 'Success !');
6635    } else {
6636      console.info(funcName, 'Failed !');
6637    }
6638  } else {
6639    console.info('PictureObj is null');
6640  }
6641}
6642```
6643
6644## Metadata<sup>13+</sup>
6645
6646A class used to store image metadata. For details about the supported metadata types, see [MetadataType](#metadatatype13).
6647
6648### Properties
6649
6650**System capability**: SystemCapability.Multimedia.Image.Core
6651
6652### getProperties<sup>13+</sup>
6653
6654getProperties(key: Array\<string>): Promise\<Record\<string, string | null>>
6655
6656Obtains the values of properties from the image's metadata. This API uses a promise to return the result. For details about how to obtain the property values, see [PropertyKey](#propertykey7) and [FragmentMapPropertyKey](#fragmentmappropertykey13).
6657
6658**System capability**: SystemCapability.Multimedia.Image.Core
6659
6660**Parameters**
6661
6662| Name| Type          | Mandatory| Description                    |
6663| ------ | -------------- | ---- | ------------------------ |
6664| key    | Array\<string> | Yes  | Names of the properties.|
6665
6666**Return value**
6667
6668| Type                                    | Description                                                        |
6669| ---------------------------------------- | ------------------------------------------------------------ |
6670| Promise\<Record<string, string \| null>> | Promise used to return the property values. If the retrieval operation fails, an error code is returned.|
6671
6672**Error codes**
6673
6674For details about the error codes, see [Image Error Codes](errorcode-image.md).
6675
6676| ID| Error Message                                                    |
6677| -------- | ------------------------------------------------------------ |
6678| 401      | Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;3.Parameter verification failed; |
6679| 7600202  | Unsupported metadata. Possible causes: 1. Unsupported metadata type. 2. The metadata type does not match the auxiliary picture type. |
6680
6681**Example**
6682
6683```ts
6684import { BusinessError } from '@kit.BasicServicesKit';
6685import { image } from '@kit.ImageKit';
6686
6687async function GetProperties() {
6688  const context = getContext();
6689  const resourceMgr = context.resourceManager;
6690  const rawFile = await resourceMgr.getRawFileContent("exif.jpg"); // The image contains EXIF metadata.
6691  let ops: image.SourceOptions = {
6692    sourceDensity: 98,
6693  }
6694  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
6695  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
6696  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
6697  let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
6698  let metaData: image.Metadata | null = await pictureObj.getMetadata(metadataType);
6699  if (metaData != null) {
6700    await metaData.getProperties(["ImageWidth", "ImageLength"]).then((data2) => {
6701      console.info('Get properties ',JSON.stringify(data2));
6702    }).catch((error: BusinessError) => {
6703      console.info('Get properties failed error.code: ' +JSON.stringify(error.code) + ' ,error.message:' + JSON.stringify(error.message));
6704    });
6705  } else {
6706    console.info('Metadata is null.');
6707  }
6708}
6709```
6710
6711### setProperties<sup>13+</sup>
6712
6713setProperties(records: Record\<string, string | null>): Promise\<void>
6714
6715Sets the values of properties for the image's metadata. This API uses a promise to return the result. For details about how to obtain the property values, see [PropertyKey](#propertykey7) and [FragmentMapPropertyKey](#fragmentmappropertykey13).
6716
6717**System capability**: SystemCapability.Multimedia.Image.Core
6718
6719**Parameters**
6720
6721| Name | Type                          | Mandatory| Description                    |
6722| ------- | ------------------------------ | ---- | ------------------------ |
6723| records | Record<string, string \| null> | Yes  | Array of properties and their values.|
6724
6725**Return value**
6726
6727| Type          | Description                                 |
6728| -------------- | ------------------------------------- |
6729| Promise\<void> | Promise that returns no value. If the operation fails, an error code is returned.|
6730
6731**Error codes**
6732
6733For details about the error codes, see [Image Error Codes](errorcode-image.md).
6734
6735| ID| Error Message                                                    |
6736| -------- | ------------------------------------------------------------ |
6737| 401      | Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;3.Parameter verification failed; |
6738| 7600202  | Unsupported metadata. Possible causes: 1. Unsupported metadata type. 2. The metadata type does not match the auxiliary picture type. |
6739
6740**Example**
6741
6742```ts
6743import { BusinessError } from '@kit.BasicServicesKit';
6744import { image } from '@kit.ImageKit';
6745
6746async function SetProperties() {
6747  const context = getContext();
6748  const resourceMgr = context.resourceManager;
6749  const rawFile = await resourceMgr.getRawFileContent("exif.jpg"); // The image contains EXIF metadata.
6750  let ops: image.SourceOptions = {
6751    sourceDensity: 98,
6752  }
6753  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
6754  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
6755  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
6756  let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
6757  let metaData: image.Metadata | null = await pictureObj.getMetadata(metadataType);
6758  if (metaData != null) {
6759    let setkey: Record<string, string | null> = {
6760      "ImageWidth": "200",
6761      "ImageLength": "300"
6762    };
6763    await metaData.setProperties(setkey).then(async () => {
6764      console.info('Set auxpictureobj properties success.');
6765    }).catch((error: BusinessError) => {
6766      console.error('Failed to set metadata Properties. code is ${error.code}, message is ${error.message}');
6767    })
6768  } else {
6769    console.info('AuxPictureObj metadata is null. ');
6770  }
6771}
6772```
6773
6774### getAllProperties<sup>13+</sup>
6775
6776getAllProperties(): Promise\<Record<string, string | null>>
6777
6778Obtains all properties and values from the image's metadata. This API uses a promise to return the result. For details about how to obtain the property values, see [PropertyKey](#propertykey7) and [FragmentMapPropertyKey](#fragmentmappropertykey13).
6779
6780**System capability**: SystemCapability.Multimedia.Image.Core
6781
6782**Return value**
6783
6784| Type                                    | Description                                       |
6785| ---------------------------------------- | ------------------------------------------- |
6786| Promise\<Record<string, string \| null>> | Promise used to return the values of all properties.|
6787
6788**Example**
6789
6790```ts
6791import { BusinessError } from '@kit.BasicServicesKit';
6792import { image } from '@kit.ImageKit';
6793
6794async function GetAllProperties() {
6795  const context = getContext();
6796  const resourceMgr = context.resourceManager;
6797  const rawFile = await resourceMgr.getRawFileContent("exif.jpg"); // The image contains EXIF metadata.
6798  let ops: image.SourceOptions = {
6799    sourceDensity: 98,
6800  }
6801  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
6802  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
6803  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
6804  let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
6805  let metaData: image.Metadata | null = await pictureObj.getMetadata(metadataType);
6806  if (metaData != null) {
6807    await metaData.getAllProperties().then((data2) => {
6808      const count = Object.keys(data2).length;
6809      console.info('Metadata have ', count, ' properties');
6810      console.info('Get metadata all properties: ', JSON.stringify(data2));
6811    }).catch((error: BusinessError) => {
6812      console.error('Get metadata all properties failed error.code: ' +JSON.stringify(error.code) + ' ,error.message:' + JSON.stringify(error.message));
6813    });
6814  } else {
6815    console.info('Metadata is null.');
6816  }
6817}
6818```
6819
6820### clone<sup>13+</sup>
6821
6822clone(): Promise\<Metadata>
6823
6824Clones the metadata. This API uses a promise to return the result.
6825
6826**System capability**: SystemCapability.Multimedia.Image.Core
6827
6828**Return value**
6829
6830| Type                             | Description                             |
6831| --------------------------------- | --------------------------------- |
6832| Promise\<[Metadata](#metadata13)> | Promise used to return the metadata instance.|
6833
6834**Error codes**
6835
6836For details about the error codes, see [Image Error Codes](errorcode-image.md).
6837
6838| ID| Error Message            |
6839| -------- | -------------------- |
6840| 7600301  | Memory alloc failed. |
6841| 7600302  | Memory copy failed.  |
6842
6843**Example**
6844
6845```ts
6846import { BusinessError } from '@kit.BasicServicesKit';
6847import { image } from '@kit.ImageKit';
6848
6849async function clone() {
6850  const context = getContext();
6851  const resourceMgr = context.resourceManager;
6852  const rawFile = await resourceMgr.getRawFileContent("exif.jpg"); // The image contains EXIF metadata.
6853  let ops: image.SourceOptions = {
6854    sourceDensity: 98,
6855  }
6856  let imageSource: image.ImageSource = image.createImageSource(rawFile.buffer as ArrayBuffer, ops);
6857  let commodityPixelMap: image.PixelMap = await imageSource.createPixelMap();
6858  let pictureObj: image.Picture = image.createPicture(commodityPixelMap);
6859  let metadataType: image.MetadataType = image.MetadataType.EXIF_METADATA;
6860  let metaData: image.Metadata | null = await pictureObj.getMetadata(metadataType);
6861  if (metaData != null) {
6862    let new_metadata: image.Metadata = await metaData.clone();
6863    new_metadata.getProperties(["ImageWidth"]).then((data1) => {
6864      console.info('Clone new_metadata and get Properties.', JSON.stringify(data1));
6865    }).catch((err: BusinessError) => {
6866      console.error('Clone new_metadata failed.', JSON.stringify(err));
6867    });
6868  } else {
6869    console.info('Metadata is null.');
6870  }
6871}
6872```
6873
6874## image.createImageReceiver<sup>11+</sup>
6875
6876createImageReceiver(size: Size, format: ImageFormat, capacity: number): ImageReceiver
6877
6878Creates an **ImageReceiver** instance by specifying the image size, format, and capacity.
6879
6880**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
6881
6882**Parameters**
6883
6884| Name  | Type  | Mandatory| Description                  |
6885| -------- | ------ | ---- | ---------------------- |
6886| size    | [Size](#size)  | Yes  | Default size of the image.      |
6887| format   | [ImageFormat](#imageformat9) | Yes  | Image format, which is a constant of [ImageFormat](#imageformat9). (Currently, only **ImageFormat:JPEG** is supported. The format actually returned is determined by the producer, for example, camera.)            |
6888| capacity | number | Yes  | Maximum number of images that can be accessed at the same time.|
6889
6890**Return value**
6891
6892| Type                            | Description                                   |
6893| -------------------------------- | --------------------------------------- |
6894| [ImageReceiver](#imagereceiver9) | Returns an **ImageReceiver** instance if the operation is successful.|
6895
6896**Error codes**
6897
6898For details about the error codes, see [Image Error Codes](errorcode-image.md).
6899
6900| ID| Error Message|
6901| ------- | --------------------------------------------|
6902| 401| Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;   |
6903
6904**Example**
6905
6906```ts
6907let size: image.Size = {
6908  height: 8192,
6909  width: 8
6910}
6911let receiver: image.ImageReceiver = image.createImageReceiver(size, image.ImageFormat.JPEG, 8);
6912```
6913
6914## image.createImageReceiver<sup>(deprecated)</sup>
6915
6916createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver
6917
6918Creates an **ImageReceiver** instance by specifying the image width, height, format, and capacity.
6919
6920> **NOTE**
6921>
6922> This API is deprecated since API version 11. You are advised to use [createImageReceiver](#imagecreateimagereceiver11).
6923
6924**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
6925
6926**Parameters**
6927
6928| Name  | Type  | Mandatory| Description                  |
6929| -------- | ------ | ---- | ---------------------- |
6930| width    | number | Yes  | Default image width.      |
6931| height   | number | Yes  | Default image height.      |
6932| format   | number | Yes  | Image format, which is a constant of [ImageFormat](#imageformat9). (Currently, only **ImageFormat:JPEG** is supported. The format actually returned is determined by the producer, for example, camera.) |
6933| capacity | number | Yes  | Maximum number of images that can be accessed at the same time.|
6934
6935**Return value**
6936
6937| Type                            | Description                                   |
6938| -------------------------------- | --------------------------------------- |
6939| [ImageReceiver](#imagereceiver9) | Returns an **ImageReceiver** instance if the operation is successful.|
6940
6941**Example**
6942
6943```ts
6944let receiver: image.ImageReceiver = image.createImageReceiver(8192, 8, image.ImageFormat.JPEG, 8);
6945```
6946
6947## ImageReceiver<sup>9+</sup>
6948
6949Provides APIs to obtain the surface ID of a component, read the latest image, read the next image, and release the **ImageReceiver** instance.
6950
6951Before calling any APIs in **ImageReceiver**, you must create an **ImageReceiver** instance.
6952
6953### Properties
6954
6955**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
6956
6957| Name    | Type                        | Readable| Writable| Description              |
6958| -------- | ---------------------------- | ---- | ---- | ------------------ |
6959| size     | [Size](#size)                | Yes  | No  | Image size.        |
6960| capacity | number                       | Yes  | No  | Maximum number of images that can be accessed at the same time.|
6961| format   | [ImageFormat](#imageformat9) | Yes  | No  | Image format.        |
6962
6963### getReceivingSurfaceId<sup>9+</sup>
6964
6965getReceivingSurfaceId(callback: AsyncCallback\<string>): void
6966
6967Obtains a surface ID for the camera or other components. This API uses an asynchronous callback to return the result.
6968
6969**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
6970
6971**Parameters**
6972
6973| Name  | Type                  | Mandatory| Description                      |
6974| -------- | ---------------------- | ---- | -------------------------- |
6975| callback | AsyncCallback\<string> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the surface ID obtained. Otherwise, **err** is an error object.|
6976
6977**Example**
6978
6979```ts
6980import { BusinessError } from '@kit.BasicServicesKit';
6981
6982receiver.getReceivingSurfaceId((err: BusinessError, id: string) => {
6983  if (err) {
6984    console.error(`Failed to get the ReceivingSurfaceId.code ${err.code},message is ${err.message}`);
6985  } else {
6986    console.info('Succeeded in getting the ReceivingSurfaceId.');
6987  }
6988});
6989```
6990
6991### getReceivingSurfaceId<sup>9+</sup>
6992
6993getReceivingSurfaceId(): Promise\<string>
6994
6995Obtains a surface ID for the camera or other components. This API uses a promise to return the result.
6996
6997**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
6998
6999**Return value**
7000
7001| Type            | Description                |
7002| ---------------- | -------------------- |
7003| Promise\<string> | Promise used to return the surface ID.|
7004
7005**Example**
7006
7007```ts
7008import { BusinessError } from '@kit.BasicServicesKit';
7009
7010receiver.getReceivingSurfaceId().then((id: string) => {
7011  console.info('Succeeded in getting the ReceivingSurfaceId.');
7012}).catch((error: BusinessError) => {
7013  console.error(`Failed to get the ReceivingSurfaceId.code ${error.code},message is ${error.message}`);
7014})
7015```
7016
7017### readLatestImage<sup>9+</sup>
7018
7019readLatestImage(callback: AsyncCallback\<Image>): void
7020
7021Reads the latest image from the **ImageReceiver** instance. This API uses an asynchronous callback to return the result.
7022
7023**NOTE**: This API can be called to receive data only after the [on](#on9) callback is triggered. When the [Image](#image9) object returned by this API is no longer needed, call [release](#release9-4) to release the object. New data can be received only after the release.
7024
7025**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7026
7027**Parameters**
7028
7029| Name    | Type                           | Mandatory| Description                    |
7030| -------- | ------------------------------- | ---- | ------------------------ |
7031| callback | AsyncCallback<[Image](#image9)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the latest image obtained; otherwise, **err** is an error object. |
7032
7033**Example**
7034
7035```ts
7036import { BusinessError } from '@kit.BasicServicesKit';
7037
7038receiver.readLatestImage((err: BusinessError, img: image.Image) => {
7039  if (err) {
7040    console.error(`Failed to read the latest Image.code ${err.code},message is ${err.message}`);
7041  } else {
7042    console.info('Succeeded in reading the latest Image.');
7043  }
7044});
7045```
7046
7047### readLatestImage<sup>9+</sup>
7048
7049readLatestImage(): Promise\<Image>
7050
7051Reads the latest image from the **ImageReceiver** instance. This API uses a promise to return the result.
7052
7053**NOTE**: This API can be called to receive data only after the [on](#on9) callback is triggered. When the [Image](#image9) object returned by this API is no longer needed, call [release](#release9-4) to release the object. New data can be received only after the release.
7054
7055**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7056
7057**Return value**
7058
7059| Type                     | Description              |
7060| ------------------------- | ------------------ |
7061| Promise<[Image](#image9)> | Promise used to return the latest image.|
7062
7063**Example**
7064
7065```ts
7066import { BusinessError } from '@kit.BasicServicesKit';
7067
7068receiver.readLatestImage().then((img: image.Image) => {
7069  console.info('Succeeded in reading the latest Image.');
7070}).catch((error: BusinessError) => {
7071  console.error(`Failed to read the latest Image.code ${error.code},message is ${error.message}`);
7072})
7073```
7074
7075### readNextImage<sup>9+</sup>
7076
7077readNextImage(callback: AsyncCallback\<Image>): void
7078
7079Reads the next image from the **ImageReceiver** instance. This API uses an asynchronous callback to return the result.
7080
7081**NOTE**: This API can be called to receive data only after the [on](#on9) callback is triggered. When the [Image](#image9) object returned by this API is no longer needed, call [release](#release9-4) to release the object. New data can be received only after the release.
7082
7083**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7084
7085**Parameters**
7086
7087| Name  | Type                           | Mandatory| Description                      |
7088| -------- | ------------------------------- | ---- | -------------------------- |
7089| callback | AsyncCallback<[Image](#image9)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the next image obtained. Otherwise, **err** is an error object. |
7090
7091**Example**
7092
7093```ts
7094import { BusinessError } from '@kit.BasicServicesKit';
7095
7096receiver.readNextImage((err: BusinessError, img: image.Image) => {
7097  if (err) {
7098    console.error(`Failed to read the next Image.code ${err.code},message is ${err.message}`);
7099  } else {
7100    console.info('Succeeded in reading the next Image.');
7101  }
7102});
7103```
7104
7105### readNextImage<sup>9+</sup>
7106
7107readNextImage(): Promise\<Image>
7108
7109Reads the next image from the **ImageReceiver** instance. This API uses a promise to return the result.
7110
7111**NOTE**: This API can be called to receive data only after the [on](#on9) callback is triggered. When the [Image](#image9) object returned by this API is no longer needed, call [release](#release9-4) to release the object. New data can be received only after the release.
7112
7113**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7114
7115**Return value**
7116
7117| Type                     | Description                |
7118| ------------------------- | -------------------- |
7119| Promise<[Image](#image9)> | Promise used to return the next image.|
7120
7121**Example**
7122
7123```ts
7124import { BusinessError } from '@kit.BasicServicesKit';
7125
7126receiver.readNextImage().then((img: image.Image) => {
7127  console.info('Succeeded in reading the next Image.');
7128}).catch((error: BusinessError) => {
7129  console.error(`Failed to read the next Image.code ${error.code},message is ${error.message}`);
7130})
7131```
7132
7133### on<sup>9+</sup>
7134
7135on(type: 'imageArrival', callback: AsyncCallback\<void>): void
7136
7137Listens for image arrival events.
7138
7139**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7140
7141**Parameters**
7142
7143| Name  | Type                | Mandatory| Description                                                  |
7144| -------- | -------------------- | ---- | ------------------------------------------------------ |
7145| type     | string               | Yes  | Type of event to listen for. The value is fixed at **'imageArrival'**, which is triggered when an image is received.|
7146| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.                                       |
7147
7148**Example**
7149
7150```ts
7151receiver.on('imageArrival', () => {
7152  // image arrival, do something.
7153})
7154```
7155
7156### off<sup>13+</sup>
7157
7158off(type: 'imageArrival', callback?: AsyncCallback\<void>): void
7159
7160Unregisters the callback function that is triggered when the buffer is released.
7161
7162**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7163
7164**Parameters**
7165
7166| Name  | Type                | Mandatory| Description                                    |
7167| -------- | -------------------- |----|----------------------------------------|
7168| type     | string               | Yes | Type of event, which is **'imageArrival'**.|
7169| callback | AsyncCallback\<void> | No | Callback to unregister.        |
7170
7171**Example**
7172
7173```ts
7174let callbackFunc = ()=>{
7175    // do something
7176}
7177receiver.on('imageArrival', callbackFunc)
7178receiver.off('imageArrival', callbackFunc)
7179```
7180
7181### release<sup>9+</sup>
7182
7183release(callback: AsyncCallback\<void>): void
7184
7185Releases this **ImageReceiver** instance. This API uses an asynchronous callback to return the result.
7186
7187ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImageReceiver** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
7188
7189**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7190
7191**Parameters**
7192
7193| Name  | Type                | Mandatory| Description                    |
7194| -------- | -------------------- | ---- | ------------------------ |
7195| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
7196
7197**Example**
7198
7199```ts
7200import { BusinessError } from '@kit.BasicServicesKit';
7201
7202receiver.release((err: BusinessError) => {
7203  if (err) {
7204    console.error(`Failed to release the receiver.code ${err.code},message is ${err.message}`);
7205  } else {
7206    console.info('Succeeded in releasing the receiver.');
7207  }
7208})
7209```
7210
7211### release<sup>9+</sup>
7212
7213release(): Promise\<void>
7214
7215Releases this **ImageReceiver** instance. This API uses a promise to return the result.
7216
7217ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImageReceiver** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
7218
7219**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
7220
7221**Return value**
7222
7223| Type          | Description              |
7224| -------------- | ------------------ |
7225| Promise\<void> |  Promise that returns no value.|
7226
7227**Example**
7228
7229```ts
7230import { BusinessError } from '@kit.BasicServicesKit';
7231
7232receiver.release().then(() => {
7233  console.info('Succeeded in releasing the receiver.');
7234}).catch((error: BusinessError) => {
7235  console.error(`Failed to release the receiver.code ${error.code},message is ${error.message}`);
7236})
7237```
7238
7239## image.createImageCreator<sup>11+</sup>
7240
7241createImageCreator(size: Size, format: ImageFormat, capacity: number): ImageCreator
7242
7243Creates an **ImageCreator** instance by specifying the image size, format, and capacity.
7244
7245**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7246
7247**Parameters**
7248
7249| Name  | Type  | Mandatory| Description                  |
7250| -------- | ------ | ---- | ---------------------- |
7251| size    | [Size](#size)  | Yes  | Default size of the image.      |
7252| format   | [ImageFormat](#imageformat9) | Yes  | Image format, for example, YCBCR_422_SP or JPEG.            |
7253| capacity | number | Yes  | Maximum number of images that can be accessed at the same time.|
7254
7255**Return value**
7256
7257| Type                          | Description                                   |
7258| ------------------------------ | --------------------------------------- |
7259| [ImageCreator](#imagecreator9) | Returns an **ImageCreator** instance if the operation is successful.|
7260
7261
7262**Error codes**
7263
7264For details about the error codes, see [Image Error Codes](errorcode-image.md).
7265
7266| ID| Error Message|
7267| ------- | --------------------------------------------|
7268| 401| Parameter error.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types;          |
7269
7270**Example**
7271
7272```ts
7273let size: image.Size = {
7274  height: 8192,
7275  width: 8
7276}
7277let creator: image.ImageCreator = image.createImageCreator(size, image.ImageFormat.JPEG, 8);
7278```
7279
7280## image.createImageCreator<sup>(deprecated)</sup>
7281
7282createImageCreator(width: number, height: number, format: number, capacity: number): ImageCreator
7283
7284Creates an **ImageCreator** instance by specifying the image width, height, format, and capacity.
7285
7286> **NOTE**
7287>
7288> This API is deprecated since API version 11. You are advised to use [createImageCreator](#imagecreateimagecreator11).
7289
7290**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7291
7292**Parameters**
7293
7294| Name  | Type  | Mandatory| Description                  |
7295| -------- | ------ | ---- | ---------------------- |
7296| width    | number | Yes  | Default image width.      |
7297| height   | number | Yes  | Default image height.      |
7298| format   | number | Yes  | Image format, for example, YCBCR_422_SP or JPEG.            |
7299| capacity | number | Yes  | Maximum number of images that can be accessed at the same time.|
7300
7301**Return value**
7302
7303| Type                          | Description                                   |
7304| ------------------------------ | --------------------------------------- |
7305| [ImageCreator](#imagecreator9) | Returns an **ImageCreator** instance if the operation is successful.|
7306
7307**Example**
7308
7309```ts
7310let creator: image.ImageCreator = image.createImageCreator(8192, 8, image.ImageFormat.JPEG, 8);
7311```
7312
7313## ImageCreator<sup>9+</sup>
7314
7315Provides APIs for applications to request an image native data area and compile native image data.
7316Before calling any APIs in **ImageCreator**, you must create an [ImageCreator](#imagecreator9) instance. **ImageCreator** does not support multiple threads.
7317
7318### Properties
7319
7320**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7321
7322| Name    | Type                        | Readable| Writable| Description              |
7323| -------- | ---------------------------- | ---- | ---- | ------------------ |
7324| capacity | number                       | Yes  | No  | Maximum number of images that can be accessed at the same time.|
7325| format   | [ImageFormat](#imageformat9) | Yes  | No  | Image format.        |
7326
7327### dequeueImage<sup>9+</sup>
7328
7329dequeueImage(callback: AsyncCallback\<Image>): void
7330
7331Obtains an image buffer from the idle queue and writes image data into it. This API uses an asynchronous callback to return the result.
7332
7333**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7334
7335**Parameters**
7336
7337| Name       | Type                                   | Mandatory| Description                |
7338| ------------- | ---------------------------------------| ---- | -------------------- |
7339| callback      | AsyncCallback\<[Image](#image9)>  | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the latest image obtained; otherwise, **err** is an error object. |
7340
7341**Example**
7342
7343```ts
7344import { BusinessError } from '@kit.BasicServicesKit';
7345
7346creator.dequeueImage((err: BusinessError, img: image.Image) => {
7347  if (err) {
7348    console.error(`Failed to dequeue the Image.code ${err.code},message is ${err.message}`);
7349  } else {
7350    console.info('Succeeded in dequeuing the Image.');
7351  }
7352});
7353```
7354
7355### dequeueImage<sup>9+</sup>
7356
7357dequeueImage(): Promise\<Image>
7358
7359Obtains an image buffer from the idle queue and writes image data into it. This API uses a promise to return the result.
7360
7361**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7362
7363**Return value**
7364
7365| Type            | Description          |
7366| --------------- | ------------- |
7367| Promise\<[Image](#image9)> | Promise used to return the latest image.|
7368
7369**Example**
7370
7371```ts
7372import { BusinessError } from '@kit.BasicServicesKit';
7373
7374creator.dequeueImage().then((img: image.Image) => {
7375  console.info('Succeeded in dequeuing the Image.');
7376}).catch((error: BusinessError) => {
7377  console.error(`Failed to dequeue the Image.code ${error.code},message is ${error.message}`);
7378})
7379```
7380
7381### queueImage<sup>9+</sup>
7382
7383queueImage(interface: Image, callback: AsyncCallback\<void>): void
7384
7385Places the drawn image in the dirty queue. This API uses an asynchronous callback to return the result.
7386
7387**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7388
7389**Parameters**
7390
7391| Name       | Type                    | Mandatory| Description                |
7392| ------------- | -------------------------| ---- | -------------------- |
7393| interface     | [Image](#image9)                    | Yes  | Drawn image.|
7394| callback      | AsyncCallback\<void>     | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
7395
7396**Example**
7397
7398```ts
7399import { BusinessError } from '@kit.BasicServicesKit';
7400
7401creator.dequeueImage().then((img: image.Image) => {
7402  // Draw the image.
7403  img.getComponent(4).then((component : image.Component) => {
7404    let bufferArr: Uint8Array = new Uint8Array(component.byteBuffer);
7405    for (let i = 0; i < bufferArr.length; i += 4) {
7406      bufferArr[i] = 0; //B
7407      bufferArr[i + 1] = 0; //G
7408      bufferArr[i + 2] = 255; //R
7409      bufferArr[i + 3] = 255; //A
7410    }
7411  })
7412  creator.queueImage(img, (err: BusinessError) => {
7413    if (err) {
7414      console.error(`Failed to queue the Image.code ${err.code},message is ${err.message}`);
7415    } else {
7416      console.info('Succeeded in queuing the Image.');
7417    }
7418  })
7419})
7420
7421```
7422
7423### queueImage<sup>9+</sup>
7424
7425queueImage(interface: Image): Promise\<void>
7426
7427Places the drawn image in the dirty queue. This API uses a promise to return the result.
7428
7429**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7430
7431**Parameters**
7432
7433| Name         | Type    | Mandatory| Description               |
7434| ------------- | --------| ---- | ------------------- |
7435| interface     | [Image](#image9)   | Yes  | Drawn image.|
7436
7437**Return value**
7438
7439| Type           | Description          |
7440| -------------- | ------------- |
7441| Promise\<void> | Promise that returns no value.|
7442
7443**Example**
7444
7445```ts
7446import { BusinessError } from '@kit.BasicServicesKit';
7447
7448creator.dequeueImage().then((img: image.Image) => {
7449  // Draw the image.
7450  img.getComponent(4).then((component: image.Component) => {
7451    let bufferArr: Uint8Array = new Uint8Array(component.byteBuffer);
7452    for (let i = 0; i < bufferArr.length; i += 4) {
7453      bufferArr[i] = 0; //B
7454      bufferArr[i + 1] = 0; //G
7455      bufferArr[i + 2] = 255; //R
7456      bufferArr[i + 3] = 255; //A
7457    }
7458  })
7459  creator.queueImage(img).then(() => {
7460    console.info('Succeeded in queuing the Image.');
7461  }).catch((error: BusinessError) => {
7462    console.error(`Failed to queue the Image.code ${error.code},message is ${error.message}`);
7463  })
7464})
7465
7466```
7467
7468### on<sup>9+</sup>
7469
7470on(type: 'imageRelease', callback: AsyncCallback\<void>): void
7471
7472Listens for image release events. This API uses an asynchronous callback to return the result.
7473
7474**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7475
7476**Parameters**
7477
7478| Name       | Type                    | Mandatory| Description                |
7479| ------------- | -------------------------| ---- | -------------------- |
7480| type          | string                   | Yes  | Type of event, which is **'imageRelease'**.|
7481| callback      | AsyncCallback\<void>     | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
7482
7483**Example**
7484
7485```ts
7486import { BusinessError } from '@kit.BasicServicesKit';
7487
7488creator.on('imageRelease', (err: BusinessError) => {
7489  if (err) {
7490    console.error(`Failed to get the imageRelease callback.code ${err.code},message is ${err.message}`);
7491  } else {
7492    console.info('Succeeded in getting imageRelease callback.');
7493  }
7494})
7495```
7496
7497### off<sup>13+</sup>
7498
7499off(type: 'imageRelease', callback?: AsyncCallback\<void>): void
7500
7501Unregisters the callback function that is triggered when the buffer is released.
7502
7503**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7504
7505**Parameters**
7506
7507| Name       | Type                    | Mandatory| Description                                        |
7508| ------------- | -------------------------|----|--------------------------------------------|
7509| type          | string                   | Yes | Type of event, which is **'imageRelease'**.                   |
7510| callback      | AsyncCallback\<void>     | No | Callback to unregister.|
7511
7512**Example**
7513
7514```ts
7515let callbackFunc = ()=>{
7516    // do something
7517}
7518creator.on('imageRelease', callbackFunc)
7519creator.off('imageRelease', callbackFunc)
7520```
7521
7522### release<sup>9+</sup>
7523
7524release(callback: AsyncCallback\<void>): void
7525
7526Releases this **ImageCreator** instance. This API uses an asynchronous callback to return the result.
7527
7528ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImageCreator** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
7529
7530**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7531
7532**Parameters**
7533
7534| Name          | Type                    | Mandatory| Description                |
7535| ------------- | -------------------------| ---- | -------------------- |
7536| callback      | AsyncCallback\<void>     | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
7537
7538**Example**
7539
7540```ts
7541import { BusinessError } from '@kit.BasicServicesKit';
7542
7543creator.release((err: BusinessError) => {
7544  if (err) {
7545    console.error(`Failed to release the creator.code ${err.code},message is ${err.message}`);
7546  } else {
7547    console.info('Succeeded in releasing creator.');
7548  }
7549});
7550```
7551### release<sup>9+</sup>
7552
7553release(): Promise\<void>
7554
7555Releases this **ImageCreator** instance. This API uses a promise to return the result.
7556
7557ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **ImageCreator** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
7558
7559**System capability**: SystemCapability.Multimedia.Image.ImageCreator
7560
7561**Return value**
7562
7563| Type           | Description          |
7564| -------------- | ------------- |
7565| Promise\<void> | Promise that returns no value.|
7566
7567**Example**
7568
7569```ts
7570import { BusinessError } from '@kit.BasicServicesKit';
7571
7572creator.release().then(() => {
7573  console.info('Succeeded in releasing creator.');
7574}).catch((error: BusinessError) => {
7575  console.error(`Failed to release the creator.code ${error.code},message is ${error.message}`);
7576})
7577```
7578
7579## Image<sup>9+</sup>
7580
7581Provides APIs for basic image operations, including obtaining image information and reading and writing image data. An **Image** instance is returned when [readNextImage](#readnextimage9) and [readLatestImage](#readlatestimage9) are called.
7582
7583### Properties
7584
7585**System capability**: SystemCapability.Multimedia.Image.Core
7586
7587| Name    | Type              | Readable| Writable| Description                                              |
7588| -------- | ------------------ | ---- | ---- | -------------------------------------------------- |
7589| clipRect | [Region](#region8) | Yes  | Yes  | Image area to be cropped.                                |
7590| size     | [Size](#size)      | Yes  | No  | Image size. If the **image** object stores the camera preview stream data (YUV image data), the width and height in **size** obtained correspond to those of the YUV image. If the **image** object stores the camera photo stream data (JPEG image data, which is already encoded), the width in **size** obtained is the JPEG data size, and the height is 1. The type of data stored in the **image** object depends on whether the application passes the surface ID in the receiver to a **previewOutput** or **captureOutput** object of the camera. For details about the best practices of camera preview and photo capture, see [Dual-Channel Preview (ArkTS)](../../media/camera/camera-dual-channel-preview.md) and [Photo Capture Sample (ArkTS)](../../media/camera/camera-shooting-case.md).                               |
7591| format   | number             | Yes  | No  | Image format. For details, see [OH_NativeBuffer_Format](../apis-arkgraphics2d/_o_h___native_buffer.md#oh_nativebuffer_format).|
7592| timestamp<sup>12+</sup> | number         | Yes     | No  | Image timestamp. Timestamps, measured in nanoseconds, are usually monotonically increasing. The specific meaning and baseline of these timestamps are determined by the image producer, which is the camera in the camera preview and photo scenarios. As a result, images from different producers may carry timestamps with distinct meanings and baselines, making direct comparison between them infeasible. To obtain the generation time of a photo, you can use [getImageProperty](#getimageproperty11) to read the related EXIF information.|
7593
7594### getComponent<sup>9+</sup>
7595
7596getComponent(componentType: ComponentType, callback: AsyncCallback\<Component>): void
7597
7598Obtains the component buffer from the **Image** instance based on the color component type. This API uses an asynchronous callback to return the result.
7599
7600**System capability**: SystemCapability.Multimedia.Image.Core
7601
7602**Parameters**
7603
7604| Name       | Type                                   | Mandatory| Description                |
7605| ------------- | --------------------------------------- | ---- | -------------------- |
7606| componentType | [ComponentType](#componenttype9)        | Yes  | Color component type of the image. (Currently, only **ComponentType:JPEG** is supported. The format actually returned is determined by the producer, for example, camera.)   |
7607| callback      | AsyncCallback<[Component](#component9)> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the component buffer obtained; otherwise, **err** is an error object. |
7608
7609**Example**
7610
7611```ts
7612import { BusinessError } from '@kit.BasicServicesKit';
7613
7614img.getComponent(4, (err: BusinessError, component: image.Component) => {
7615  if (err) {
7616    console.error(`Failed to get the component.code ${err.code},message is ${err.message}`);
7617  } else {
7618    console.info('Succeeded in getting component.');
7619  }
7620})
7621```
7622
7623### getComponent<sup>9+</sup>
7624
7625getComponent(componentType: ComponentType): Promise\<Component>
7626
7627Obtains the component buffer from the **Image** instance based on the color component type. This API uses a promise to return the result.
7628
7629**System capability**: SystemCapability.Multimedia.Image.Core
7630
7631**Parameters**
7632
7633| Name       | Type                            | Mandatory| Description            |
7634| ------------- | -------------------------------- | ---- | ---------------- |
7635| componentType | [ComponentType](#componenttype9) | Yes  | Color component type of the image. (Currently, only **ComponentType:JPEG** is supported. The format actually returned is determined by the producer, for example, camera.)|
7636
7637**Return value**
7638
7639| Type                             | Description                             |
7640| --------------------------------- | --------------------------------- |
7641| Promise<[Component](#component9)> | Promise used to return the component buffer.|
7642
7643**Example**
7644
7645```ts
7646import { BusinessError } from '@kit.BasicServicesKit';
7647
7648img.getComponent(4).then((component: image.Component) => {
7649  console.info('Succeeded in getting component.');
7650}).catch((error: BusinessError) => {
7651  console.error(`Failed to get the component.code ${error.code},message is ${error.message}`);
7652})
7653```
7654
7655### release<sup>9+</sup>
7656
7657release(callback: AsyncCallback\<void>): void
7658
7659Releases this **Image** instance. This API uses an asynchronous callback to return the result.
7660
7661The corresponding resources must be released before another image arrives.
7662
7663ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **Image** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
7664
7665**System capability**: SystemCapability.Multimedia.Image.Core
7666
7667**Parameters**
7668
7669| Name  | Type                | Mandatory| Description          |
7670| -------- | -------------------- | ---- | -------------- |
7671| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object. |
7672
7673**Example**
7674
7675```ts
7676import { BusinessError } from '@kit.BasicServicesKit';
7677
7678img.release((err: BusinessError) => {
7679  if (err) {
7680    console.error(`Failed to release the image instance.code ${err.code},message is ${err.message}`);
7681  } else {
7682    console.info('Succeeded in releasing the image instance.');
7683  }
7684})
7685```
7686
7687### release<sup>9+</sup>
7688
7689release(): Promise\<void>
7690
7691Releases this **Image** instance. This API uses a promise to return the result.
7692
7693The corresponding resources must be released before another image arrives.
7694
7695ArkTS supports memory reclamation. Even if the application does not call **release()**, the memory of the **Image** object will be released by the system. However, images usually occupy a large amount of memory. Therefore, it is recommended that the application proactively call the API to release the memory when the object is no longer required.
7696
7697**System capability**: SystemCapability.Multimedia.Image.Core
7698
7699**Return value**
7700
7701| Type          | Description                 |
7702| -------------- | --------------------- |
7703| Promise\<void> |  Promise that returns no value.|
7704
7705**Example**
7706
7707```ts
7708import { BusinessError } from '@kit.BasicServicesKit';
7709
7710img.release().then(() => {
7711  console.info('Succeeded in releasing the image instance.');
7712}).catch((error: BusinessError) => {
7713  console.error(`Failed to release the image instance.code ${error.code},message is ${error.message}`);
7714})
7715```
7716
7717## PositionArea<sup>7+</sup>
7718
7719Describes area information in an image.
7720
7721**Widget capability**: This API can be used in ArkTS widgets since API version 12.
7722
7723**Atomic service API**: This API can be used in atomic services since API version 11.
7724
7725**System capability**: SystemCapability.Multimedia.Image.Core
7726
7727| Name  | Type              | Read Only|  Optional| Description                                                        |
7728| ------ | ------------------ | ---| -----|------------------------------------------------------- |
7729| pixels | ArrayBuffer        | No|   No | Pixels of the image. Only pixel data in BGRA_8888 format is supported.|
7730| offset | number             | No|   No |  Offset for data reading.                                                    |
7731| stride | number             | No|   No | Number of bytes from one row of pixels in memory to the next row of pixels in memory. The value of **stride** must be greater than or equal to the value of **region.size.width** multiplied by 4.                  |
7732| region | [Region](#region8) | No|   No |Region to read or write. The width of the region to write plus the X coordinate cannot be greater than the width of the original image. The height of the region to write plus the Y coordinate cannot be greater than the height of the original image.|
7733
7734## ImageInfo
7735
7736Describes image information.
7737
7738**System capability**: SystemCapability.Multimedia.Image.Core
7739
7740| Name| Type         | Read Only| Optional| Description      |
7741| ---- | ------------- | --- |-----|---------- |
7742| size<sup>6+</sup> | [Size](#size) | No|  No |Image size.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7743| density<sup>9+</sup> | number | No | No|Pixel density, in ppi.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7744| stride<sup>11+</sup> | number | No | No | Number of bytes from one row of pixels in memory to the next row of pixels in memory.stride >= region.size.width*4 <br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7745| pixelFormat<sup>12+</sup> | [PixelMapFormat](#pixelmapformat7) | No |  No| Pixel format.<br>**Atomic service API**: This API can be used in atomic services since API version 12.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7746| alphaType<sup>12+</sup> | [AlphaType](#alphatype9)  | No |  No |Alpha type.<br>**Atomic service API**: This API can be used in atomic services since API version 12.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7747| mimeType<sup>12+</sup> | string  |  No |   No |Actual image format (MIME type). |
7748| isHdr<sup>12+</sup> | boolean  |  No | No | Whether the image is in High Dynamic Range (HDR) format. For [ImageSource](#imagesource), this parameter specifies whether the source image is in HDR format. For [PixelMap](#pixelmap7), this parameter specifies whether the decoded PixelMap is in HDR format.|
7749
7750## Size
7751
7752Describes the size of an image.
7753
7754**Widget capability**: This API can be used in ArkTS widgets since API version 12.
7755
7756**Atomic service API**: This API can be used in atomic services since API version 11.
7757
7758**System capability**: SystemCapability.Multimedia.Image.Core
7759
7760| Name  | Type  | Read Only|  Optional |Description          |
7761| ------ | ------ | -- |-----| -------------- |
7762| height | number | No |  No |Image height, in px.|
7763| width  | number | No |  No| Image width, in px.|
7764
7765## PixelMapFormat<sup>7+</sup>
7766
7767Enumerates the pixel formats of images.
7768
7769**System capability**: SystemCapability.Multimedia.Image.Core
7770
7771| Name                  |   Value  | Description             |
7772| ---------------------- | ------ | ----------------- |
7773| UNKNOWN                | 0      | Unknown format.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.       |
7774| RGB_565                | 2      | RGB_565.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.    |
7775| RGBA_8888              | 3      | RGBA_8888.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7776| BGRA_8888<sup>9+</sup> | 4      | BGRA_8888.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7777| RGB_888<sup>9+</sup>   | 5      | RGB_888.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.  |
7778| ALPHA_8<sup>9+</sup>   | 6      | ALPHA_8.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.  |
7779| RGBA_F16<sup>9+</sup>  | 7      | RGBA_F16.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12. |
7780| NV21<sup>9+</sup>      | 8      | NV21.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.     |
7781| NV12<sup>9+</sup>      | 9      | NV12.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.     |
7782| RGBA_1010102<sup>12+</sup> | 10 | RGBA_1010102.|
7783| YCBCR_P010<sup>12+</sup> | 11 | YCBCR_P010.|
7784| YCRCB_P010<sup>12+</sup> | 12 | YCRCB_P010.|
7785
7786## AlphaType<sup>9+</sup>
7787
7788Enumerates the alpha types of images.
7789
7790**Widget capability**: This API can be used in ArkTS widgets since API version 12.
7791
7792**Atomic service API**: This API can be used in atomic services since API version 11.
7793
7794**System capability**: SystemCapability.Multimedia.Image.Core
7795
7796| Name    |   Value  | Description                   |
7797| -------- | ------ | ----------------------- |
7798| UNKNOWN  | 0      | Unknown alpha type.           |
7799| OPAQUE   | 1      | There is no alpha or the image is opaque.|
7800| PREMUL   | 2      | Premultiplied alpha.        |
7801| UNPREMUL | 3      | RGB non-premultiplied alpha.      |
7802
7803## AuxiliaryPictureType<sup>13+</sup>
7804
7805Enumerates the auxiliary pictures types.
7806
7807**System capability**: SystemCapability.Multimedia.Image.Core
7808
7809| Name         | Value  | Description        |
7810| ------------- | ---- | ------------ |
7811| GAINMAP       | 1    | Gain map, a mechanism for transforming an SDR image into an HDR image capable of display adjustment. It is a set of combinations describing how to apply gain map metadata.    |
7812| DEPTH_MAP     | 2    | Depth map, which stores the depth data of an image. It captures the distance between each pixel and the camera to provide 3D scene structure. It is usually used for 3D modeling and scene comprehension.    |
7813| UNREFOCUS_MAP | 3    | Defocused portrait original image, which provides a method to emphasize background blur in portrait photographing. It helps users select a focus region in post-processing, allowing for greater creative control.  |
7814| LINEAR_MAP    | 4    | Linear map, which is used to provide additional viewpoints or supplementary information. It is usually used to enhance visual effects and can contain linear representations of lighting, colors, or other visual elements in a scene.    |
7815| FRAGMENT_MAP  | 5    | Fragment map, which indicates regions obscured by watermarks in the original image. It is used to remove or correct the watermark interference, thereby enhancing the image completeness and visibility.|
7816
7817## AuxiliaryPictureInfo<sup>13+</sup>
7818
7819Describes the auxiliary picture information.
7820
7821**System capability**: SystemCapability.Multimedia.Image.Core
7822
7823| Name                     | Type                                                        | Read Only| Optional| Description                                                        |
7824| ------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
7825| auxiliaryPictureType      | [AuxiliaryPictureType](#auxiliarypicturetype13)              | No  | No  | Auxiliary picture type.                                          |
7826| size         | [Size](#size)                                                | No  | No  | Image size.|
7827| rowStride                 | number                                                       | No  | No  | Row stride.                                                      |
7828| pixelFormat | [PixelMapFormat](#pixelmapformat7)                           | No  | No  | Pixel format.|
7829| colorSpace                | [colorSpaceManager.ColorSpaceManager](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspacemanager) | No  | No  | Color space.                                              |
7830
7831## MetadataType<sup>13+</sup>
7832
7833Enumerates image metadata types.
7834
7835**System capability**: SystemCapability.Multimedia.Image.Core
7836
7837| Name             | Value  | Description              |
7838| ----------------- | ---- | ------------------ |
7839| EXIF_METADATA     | 1    | EXIF data.        |
7840| FRAGMENT_METADATA | 2    | Fragment map metadata.|
7841
7842## ScaleMode<sup>9+</sup>
7843
7844Enumerates the scale modes of images.
7845
7846**Widget capability**: This API can be used in ArkTS widgets since API version 12.
7847
7848**Atomic service API**: This API can be used in atomic services since API version 11.
7849
7850**System capability**: SystemCapability.Multimedia.Image.Core
7851
7852| Name           |   Value  | Description                                              |
7853| --------------- | ------ | -------------------------------------------------- |
7854| CENTER_CROP     | 1      | Scales the image so that it fills the requested bounds of the target and crops the extra.|
7855| FIT_TARGET_SIZE | 0      | Reduces the image size to the dimensions of the target.                          |
7856
7857## SourceOptions<sup>9+</sup>
7858
7859Defines image source initialization options.
7860
7861**Widget capability**: This API can be used in ArkTS widgets since API version 12.
7862
7863**Atomic service API**: This API can be used in atomic services since API version 11.
7864
7865**System capability**: SystemCapability.Multimedia.Image.Core
7866
7867| Name             | Type                              | Read Only| Optional| Description              |
7868| ----------------- | ---------------------------------- | ---- | ---- | ------------------ |
7869| sourceDensity     | number                             | No  | No  | Pixel density of the image resource, in DPI.<br>If **desiredSize** is not set in [DecodingOptions](# decodingoptions7) and **SourceOptions.sourceDensity** and **DecodingOptions.fitDensity** are not 0, the PixelMap output after decoding will be scaled.<br>The formula for calculating the width after scaling is as follows (the same applies to the height): (width * fitDensity + (sourceDensity >> 1)) / sourceDensity.|
7870| sourcePixelFormat | [PixelMapFormat](#pixelmapformat7) | No  | Yes  | Image pixel format. The default value is **UNKNOWN**.    |
7871| sourceSize        | [Size](#size)                      | No  | Yes  | Image pixel size. The default value is null.    |
7872
7873
7874## InitializationOptions<sup>8+</sup>
7875
7876Defines PixelMap initialization options.
7877
7878**System capability**: SystemCapability.Multimedia.Image.Core
7879
7880| Name                    | Type                              | Read Only|Optional|  Description          |
7881| ------------------------ | ---------------------------------- | ----| -----|  -------------- |
7882| alphaType<sup>9+</sup>   | [AlphaType](#alphatype9)           | No  | Yes| Alpha type. The default value is **IMAGE_ALPHA_TYPE_PREMUL**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.     |
7883| editable                 | boolean                            | No  | Yes| Whether the image is editable. The default value is **false**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7884| srcPixelFormat<sup>12+</sup>  | [PixelMapFormat](#pixelmapformat7) | No| Yes| Pixel format of the passed-in buffer data. The default value is **BGRA_8888**.|
7885| pixelFormat              | [PixelMapFormat](#pixelmapformat7) | No| Yes| Pixel format of the generated PixelMap. The default value is **RGBA_8888**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.    |
7886| scaleMode<sup>9+</sup>   | [ScaleMode](#scalemode9)           | No | Yes| Scale mode. The default value is **0**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.      |
7887| size                     | [Size](#size)                      | No | No|Image size.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7888
7889## DecodingOptions<sup>7+</sup>
7890
7891Describes the image decoding options.
7892
7893**System capability**: SystemCapability.Multimedia.Image.ImageSource
7894
7895| Name              | Type                              | Read Only| Optional| Description            |
7896| ------------------ | ---------------------------------- | ---- | ---- | ---------------- |
7897| sampleSize         | number                             | No  | Yes  | Sampling size of the thumbnail. The default value is **1**. Currently, the value can only be **1**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7898| rotate             | number                             | No  | Yes  | Rotation angle. The default value is **0**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.      |
7899| editable           | boolean                            | No  | Yes  | Whether the image is editable. The default value is **false**. If this option is set to **false**, the image cannot be edited again, and operations such as writing pixels will fail.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12. |
7900| desiredSize        | [Size](#size)                      | No  | Yes  | Expected output size. The default value is null.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.  |
7901| desiredRegion      | [Region](#region8)                 | No  | Yes  | Region to decode. The default value is null.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.      |
7902| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | No  | Yes  | Pixel format for decoding. The default value is **RGBA_8888**. Only RGBA_8888, BGRA_8888, and RGB_565 are supported. RGB_565 is not supported for images with alpha channels, such as PNG, GIF, ICO, and WEBP.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.|
7903| index              | number                             | No  | Yes  | Index of the image to decode. The default value is **0**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.  |
7904| fitDensity<sup>9+</sup> | number                        | No  | Yes  | Pixel density, in ppi. The default value is **0**.<br>**Atomic service API**: This API can be used in atomic services since API version 11.<br>**Widget capability**: This API can be used in ArkTS widgets since API version 12.  |
7905| desiredColorSpace<sup>11+</sup> | [colorSpaceManager.ColorSpaceManager](../apis-arkgraphics2d/js-apis-colorSpaceManager.md#colorspacemanager) | No  | Yes  | Target color space. The default value is **UNKNOWN**.|
7906| desiredDynamicRange<sup>12+</sup> | [DecodingDynamicRange](#decodingdynamicrange12) | No  | Yes  | Desired dynamic range. The default value is **SDR**.<br>This property cannot be set for an image source created using [CreateIncrementalSource](#imagecreateincrementalsource9). By default, the image source is decoded as SDR content.<br>If the platform does not support HDR, the setting is invalid and the content is decoded as SDR content by default.|
7907
7908## DecodingOptionsForPicture<sup>13+</sup>
7909
7910Describes the image decoding options.
7911
7912**System capability**: SystemCapability.Multimedia.Image.ImageSource
7913
7914| Name                    | Type                                                   | Read Only| Optional| Description                                                        |
7915| ------------------------ | ------------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
7916| desiredAuxiliaryPictures | Array\<[AuxiliaryPictureType](#auxiliarypicturetype13)> | No  | No  | Auxiliary picture type. By default, all auxiliary picture types are decoded.|
7917
7918## Region<sup>8+</sup>
7919
7920Describes the region information.
7921
7922**Widget capability**: This API can be used in ArkTS widgets since API version 12.
7923
7924**Atomic service API**: This API can be used in atomic services since API version 11.
7925
7926**System capability**: SystemCapability.Multimedia.Image.Core
7927
7928| Name| Type         | Read Only| Optional| Description        |
7929| ---- | ------------- | ---- | ---- | ------------ |
7930| size<sup>7+</sup> | [Size](#size) | No  | No  | Region size.  |
7931| x<sup>7+</sup>    | number        | No  | No | X coordinate of the region.|
7932| y<sup>7+</sup>    | number        | No | No | Y coordinate of the region.|
7933
7934## PackingOption
7935
7936Describes the options for image packing.
7937
7938**System capability**: SystemCapability.Multimedia.Image.ImagePacker
7939
7940| Name   | Type  | Read Only| Optional| Description                                               |
7941| ------- | ------ | ---- | ---- | --------------------------------------------------- |
7942| format  | string | No  | No  | Format of the packed image.<br>Currently, only image/jpeg, image/webp, image/png, and image/heic (or image/heif)<sup>12+</sup> (depending on the hardware) are supported.<br>**NOTE**: The JPEG format does not support the alpha channel. If the JPEG format with the alpha channel is used for data encoding, the transparent color turns black.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
7943| quality | number | No  | No  | Quality of the output image in JPEG encoding. The value ranges from 0 to 100. The value **0** means the lowest quality, and **100** means the highest quality. The higher the quality, the larger the space occupied by the generated image.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
7944| bufferSize<sup>9+</sup> | number | No  | Yes  | Size of the buffer for receiving the encoded data, in bytes. If this parameter is not set, the default value 25 MB is used. If the size of an image exceeds 25 MB, you must specify the size. The value of **bufferSize** must be greater than the size of the encoded image. The use of [packToFile](#packtofile11) is not restricted by this parameter.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
7945| desiredDynamicRange<sup>12+</sup> | [PackingDynamicRange](#packingdynamicrange12) | No  | Yes  | Desired dynamic range. The default value is **SDR**.|
7946| needsPackProperties<sup>12+</sup> | boolean | No  | Yes  | Whether to encode image property information, for example, EXIF. The default value is **false**.|
7947
7948## PackingOptionsForSequence<sup>13+</sup>
7949
7950Describes the image sequence packaging options.
7951
7952**System capability**: SystemCapability.Multimedia.Image.ImagePacker
7953
7954| Name         | Type          | Read Only| Optional| Description                                                        |
7955| ------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
7956| frameCount    | number         | No  | No  | Number of frames specified in GIF encoding.                                       |
7957| delayTimeList | Array\<number> | No  | No  | Delay of each frame of the output image in GIF encoding. If the value is not 0, this field specifies the percentage of seconds to wait before continuing to process the data stream.<br>If the length is less than **frameCount**, the missing part is filled with the last value of **delayTimeList**.|
7958| disposalTypes | Array\<number> | No  | Yes  | Parameter for setting the frame transition mode of the output image during GIF encoding. The value ranges from 0 to 3.<br>0: No operation is required.<br>1: Keeps the image unchanged.<br>2: Restores the background color.<br>3: Restores to the previous state.|
7959| loopCount     | number         | No  | Yes  | Number of times that the output image is played cyclically during GIF encoding. The value ranges from 0 to 65535.<br>The value **0** means an infinite loop. If this field is not carried, loop playback is not performed.|
7960
7961## ImagePropertyOptions<sup>11+</sup>
7962
7963Describes the image properties.
7964
7965**System capability**: SystemCapability.Multimedia.Image.ImageSource
7966
7967| Name        | Type  | Read Only| Optional| Description        |
7968| ------------ | ------ | ---- | ---- | ------------ |
7969| index        | number | Yes  | Yes  | Index of the image. The default value is **0**.  |
7970| defaultValue | string | Yes  | Yes  | Default property value. The default value is null.|
7971
7972## GetImagePropertyOptions<sup>(deprecated)</sup>
7973
7974Describes the image properties.
7975
7976> **NOTE**
7977>
7978> This API is deprecated since API version 11. You are advised to use [ImagePropertyOptions](#imagepropertyoptions11).
7979
7980**System capability**: SystemCapability.Multimedia.Image.ImageSource
7981
7982| Name        | Type  | Read Only| Optional| Description        |
7983| ------------ | ------ | ---- | ---- | ------------ |
7984| index        | number | No  | Yes  | Index of the image. The default value is **0**.  |
7985| defaultValue | string | No  | Yes  | Default property value. The default value is null.|
7986
7987## PropertyKey<sup>7+</sup>
7988
7989Describes the exchangeable image file format (EXIF) data of an image.
7990
7991**System capability**: SystemCapability.Multimedia.Image.Core
7992
7993| Name              |   Value                   |   Description                   |
7994| ----------------- | ----------------------- |---------------------------|
7995| NEW_SUBFILE_TYPE <sup>12+</sup>           | "NewSubfileType"            | **Read/Write capability**: readable and writable<br> Data type of a subfile, such as a full-resolution image, a thumbnail, or a part of a multi-frame image. The value is a bit mask. The value 0 indicates a full-resolution image, **1** indicates a thumbnail, and **2** indicates a part of a multi-frame image.|
7996| SUBFILE_TYPE <sup>12+</sup>               | "SubfileType"               | **Read/Write capability**: readable and writable<br> Type of data contained in this subfile. This tag has been deprecated. Use **NewSubfileType** instead.|
7997| IMAGE_WIDTH                               | "ImageWidth"                | **Read/Write capability**: readable and writable<br> Image width.|
7998| IMAGE_LENGTH                              | "ImageLength"               | **Read/Write capability**: readable and writable<br> Image length.|
7999| BITS_PER_SAMPLE                           | "BitsPerSample"             | **Read/Write capability**: readable and writable<br> Number of bits per sample. For example, for RGB, which has three components, the format is 8, 8, 8.|
8000| COMPRESSION <sup>12+</sup>                | "Compression"               | **Read/Write capability**: readable and writable<br> Compression scheme used on the image data.|
8001| PHOTOMETRIC_INTERPRETATION <sup>12+</sup> | "PhotometricInterpretation" | **Read/Write capability**: readable and writable<br> Color space of the image data, for example, RGB or YCbCr.|
8002| IMAGE_DESCRIPTION<sup>10+</sup>           | "ImageDescription"          | **Read/Write capability**: readable and writable<br> Image description.|
8003| MAKE<sup>10+</sup>                        | "Make"                      | **Read/Write capability**: readable and writable<br> Manufacturer.|
8004| MODEL<sup>10+</sup>                       | "Model"                     | **Read/Write capability**: readable and writable<br> Device model.|
8005| STRIP_OFFSETS <sup>12+</sup>              | "StripOffsets"              | **Read/Write capability**: readable and writable<br> Byte offset of each strip.|
8006| ORIENTATION                               | "Orientation"               | **Read/Write capability**: readable and writable<br> Image orientation.<br>- 1: **Top-left**: The image is not rotated.<br>- 2: **Top-right**: The image is flipped horizontally.<br>- 3: **Bottom-right**: The image is rotated by 180°.<br>- 4: **Bottom-left**: The image is flipped vertically.<br>- 5: **Left-top**: The image is flipped horizontally and then rotated clockwise by 270°.<br>- 6: **Right-top**: The image is rotated clockwise by 90°.<br>- 7: **Right-bottom**: The image is vertically flipped and then rotated clockwise by 90°.<br>- 8: **Left-bottom**: The image is rotated clockwise by 270°.<br>- **Unknown Value**: No value is defined.|
8007| SAMPLES_PER_PIXEL <sup>12+</sup>          | "SamplesPerPixel"           | **Read/Write capability**: readable and writable<br> Number of components per pixel. The value is 3 for RGB and YCbCr images. The **JPEG** key is used in JPEG compressed data.|
8008| ROWS_PER_STRIP <sup>12+</sup>             | "RowsPerStrip"              | **Read/Write capability**: readable and writable<br> Number of rows per strip.|
8009| STRIP_BYTE_COUNTS <sup>12+</sup>          | "StripByteCounts"           | **Read/Write capability**: readable and writable<br> Number of bytes in each strip after compression.|
8010| X_RESOLUTION <sup>12+</sup>               | "XResolution"               | **Read/Write capability**: readable and writable<br> Number of pixels per ResolutionUnit in the image width (X) direction.|
8011| Y_RESOLUTION <sup>12+</sup>               | "YResolution"               | **Read/Write capability**: readable and writable<br> Number of pixels per ResolutionUnit in the image height (Y) direction.|
8012| PLANAR_CONFIGURATION <sup>12+</sup>       | "PlanarConfiguration"       | **Read/Write capability**: readable and writable<br> Storage format of components of each pixel, which can be chunky or planar.|
8013| RESOLUTION_UNIT <sup>12+</sup>            | "ResolutionUnit"            | **Read/Write capability**: readable and writable<br> Unit of measurement for XResolution and YResolution.|
8014| TRANSFER_FUNCTION <sup>12+</sup>          | "TransferFunction"          | **Read/Write capability**: readable and writable<br> Transfer function for the image, which is usually used for color correction.|
8015| SOFTWARE <sup>12+</sup>                   | "Software"                  | **Read/Write capability**: readable and writable<br> Name and version number of the software used to create the image.|
8016| DATE_TIME<sup>10+</sup>                   | "DateTime"                  | **Read/Write capability**: readable and writable<br> Date and time of image creation. An example in the correct format is 2024:01:25 05:51:34.|
8017| ARTIST <sup>12+</sup>                     | "Artist"                    | **Read/Write capability**: readable and writable<br> Person who created the image.|
8018| WHITE_POINT <sup>12+</sup>                | "WhitePoint"                | **Read/Write capability**: readable and writable<br> Chromaticity of the white point of the image.|
8019| PRIMARY_CHROMATICITIES <sup>12+</sup>     | "PrimaryChromaticities"     | **Read/Write capability**: readable and writable<br> Chromaticities of the primaries of the image.|
8020| PHOTO_MODE<sup>10+</sup>                  | "PhotoMode"                 | **Read/Write capability**: readable and writable<br> Photographing mode.|
8021| JPEG_INTERCHANGE_FORMAT <sup>12+</sup>    | "JPEGInterchangeFormat"     | **Read/Write capability**: readable and writable<br> Offset of the SOI marker of a JPEG interchange format bitstream.|
8022| JPEG_INTERCHANGE_FORMAT_LENGTH <sup>12+</sup> | "JPEGInterchangeFormatLength" | **Read/Write capability**: readable and writable<br> Number of bytes of the JPEG stream.|
8023| YCBCR_COEFFICIENTS <sup>12+</sup>         | "YCbCrCoefficients"         | **Read/Write capability**: readable and writable<br> Transformation from RGB to YCbCr image data.|
8024| YCBCR_SUB_SAMPLING <sup>12+</sup>         | "YCbCrSubSampling"          | **Read/Write capability**: readable and writable<br> Subsampling factors used for the chrominance components of a YCbCr image.|
8025| YCBCR_POSITIONING <sup>12+</sup>          | "YCbCrPositioning"          | **Read/Write capability**: readable and writable<br> Positioning of subsampled chrominance components relative to luminance samples.|
8026| REFERENCE_BLACK_WHITE <sup>12+</sup>      | "ReferenceBlackWhite"       | **Read/Write capability**: readable and writable<br> A pair of headroom and footroom image data values (codes) for each pixel component.|
8027| COPYRIGHT <sup>12+</sup>                  | "Copyright"                 | **Read/Write capability**: readable and writable<br> Copyright notice of the image.|
8028| EXPOSURE_TIME<sup>9+</sup>                | "ExposureTime"              | **Read/Write capability**: readable and writable<br> Exposure time, for example, 1/33 seconds.|
8029| F_NUMBER<sup>9+</sup>                     | "FNumber"                   | **Read/Write capability**: readable and writable<br> F number, for example, f/1.8.|
8030| EXPOSURE_PROGRAM <sup>12+</sup>           | "ExposureProgram"           | **Read/Write capability**: readable and writable<br> Class of the program used by the camera to set exposure when the image was captured.|
8031| SPECTRAL_SENSITIVITY <sup>12+</sup>       | "SpectralSensitivity"       | **Read/Write capability**: readable and writable<br> Spectral sensitivity of each channel of the camera.|
8032| GPS_VERSION_ID <sup>12+</sup>             | "GPSVersionID"              | **Read/Write capability**: readable and writable<br> Version of GPSInfoIFD.|
8033| GPS_LATITUDE_REF                          | "GPSLatitudeRef"            | **Read/Write capability**: readable and writable<br> Whether the latitude is north or south latitude.|
8034| GPS_LATITUDE                              | "GPSLatitude"               | **Read/Write capability**: readable and writable<br> Image latitude. The value must be in the format of degree,minute,second, for example, 39,54,7.542.|
8035| GPS_LONGITUDE_REF                         | "GPSLongitudeRef"           | **Read/Write capability**: readable and writable<br> Whether the longitude is east or west longitude.|
8036| GPS_LONGITUDE                             | "GPSLongitude"              | **Read/Write capability**: readable and writable<br> Image longitude. The value must be in the format of degree,minute,second, for example, 116,19,42.16.|
8037| GPS_ALTITUDE_REF <sup>12+</sup>           | "GPSAltitudeRef"            | **Read/Write capability**: readable and writable<br> Whether the latitude is north or south latitude.|
8038| GPS_ALTITUDE <sup>12+</sup>               | "GPSAltitude"               | **Read/Write capability**: readable and writable<br> Altitude based on the reference in GPSAltitudeRef.|
8039| GPS_TIME_STAMP<sup>10+</sup>              | "GPSTimeStamp"              | **Read/Write capability**: readable and writable<br> GPS timestamp.|
8040| GPS_SATELLITES <sup>12+</sup>             | "GPSSatellites"             | **Read/Write capability**: readable and writable<br> GPS satellites used for measurement.|
8041| GPS_STATUS <sup>12+</sup>                 | "GPSStatus"                 | **Read/Write capability**: readable and writable<br> Status of the GPS receiver when the image was recorded.|
8042| GPS_MEASURE_MODE <sup>12+</sup>           | "GPSMeasureMode"            | **Read/Write capability**: readable and writable<br> GPS measurement pmode.|
8043| GPS_DOP <sup>12+</sup>                    | "GPSDOP"                    | **Read/Write capability**: readable and writable<br> GPS DOP (data degree of precision)|
8044| GPS_SPEED_REF <sup>12+</sup>              | "GPSSpeedRef"               | **Read/Write capability**: readable and writable<br> Unit used to express the movement speed of the GPS receiver.|
8045| GPS_SPEED <sup>12+</sup>                  | "GPSSpeed"                  | **Read/Write capability**: readable and writable<br> Movement speed of the GPS receiver.|
8046| GPS_TRACK_REF <sup>12+</sup>              | "GPSTrackRef"               | **Read/Write capability**: readable and writable<br> Reference of the movement direction of the GPS receiver.|
8047| GPS_TRACK <sup>12+</sup>                  | "GPSTrack"                  | **Read/Write capability**: readable and writable<br> Movement direction of the GPS receiver.|
8048| GPS_IMG_DIRECTION_REF <sup>12+</sup>      | "GPSImgDirectionRef"        | **Read/Write capability**: readable and writable<br> Reference of the direction of the image when it was captured.|
8049| GPS_IMG_DIRECTION <sup>12+</sup>          | "GPSImgDirection"           | **Read/Write capability**: readable and writable<br> Direction of the image when it was captured.|
8050| GPS_MAP_DATUM <sup>12+</sup>              | "GPSMapDatum"               | **Read/Write capability**: readable and writable<br> Geodetic survey data used by the GPS receiver.|
8051| GPS_DEST_LATITUDE_REF <sup>12+</sup>      | "GPSDestLatitudeRef"        | **Read/Write capability**: readable and writable<br> Whether the latitude of the destination point is north or south latitude.|
8052| GPS_DEST_LATITUDE <sup>12+</sup>          | "GPSDestLatitude"           | **Read/Write capability**: readable and writable<br> Latitude of the destination point.|
8053| GPS_DEST_LONGITUDE_REF <sup>12+</sup>     | "GPSDestLongitudeRef"       | **Read/Write capability**: readable and writable<br> Whether the longitude of the destination point is east or west longitude.|
8054| GPS_DEST_LONGITUDE <sup>12+</sup>         | "GPSDestLongitude"          | **Read/Write capability**: readable and writable<br> Longitude of the destination point.|
8055| GPS_DEST_BEARING_REF <sup>12+</sup>       | "GPSDestBearingRef"         | **Read/Write capability**: readable and writable<br> Reference of the bearing to the destination point.|
8056| GPS_DEST_BEARING <sup>12+</sup>           | "GPSDestBearing"            | **Read/Write capability**: readable and writable<br> Bearing to the destination point.|
8057| GPS_DEST_DISTANCE_REF <sup>12+</sup>      | "GPSDestDistanceRef"        | **Read/Write capability**: readable and writable<br> Unit used to express the distance to the destination point.|
8058| GPS_DEST_DISTANCE <sup>12+</sup>          | "GPSDestDistance"           | **Read/Write capability**: readable and writable<br> Distance to the destination point.|
8059| GPS_PROCESSING_METHOD <sup>12+</sup>      | "GPSProcessingMethod"       | **Read/Write capability**: readable and writable<br> String that records the name of the method used for positioning.|
8060| GPS_AREA_INFORMATION <sup>12+</sup>       | "GPSAreaInformation"        | **Read/Write capability**: readable and writable<br> String that records the name of the GPS area.|
8061| GPS_DATE_STAMP<sup>10+</sup>              | "GPSDateStamp"              | **Read/Write capability**: readable and writable<br> GPS date stamp.|
8062| GPS_DIFFERENTIAL <sup>12+</sup>           | "GPSDifferential"           | **Read/Write capability**: readable and writable<br> Whether differential correction is applied to the GPS receiver. It is critical to accurate location accuracy.|
8063| GPS_H_POSITIONING_ERROR <sup>12+</sup>    | "GPSHPositioningError"      | **Read/Write capability**: readable and writable<br> Horizontal positioning error, in meters.|
8064| ISO_SPEED_RATINGS<sup>9+</sup>            | "ISOSpeedRatings"           | **Read/Write capability**: readable and writable<br> ISO sensitivity or ISO speed, for example, 400.|
8065| PHOTOGRAPHIC_SENSITIVITY <sup>12+</sup>   | "PhotographicSensitivity"   | **Read/Write capability**: readable and writable<br> Sensitivity of the camera or input device when the image was captured.|
8066| OECF <sup>12+</sup>                       | "OECF"                      | **Read/Write capability**: readable and writable<br> Opto-Electric Conversion Function (OECF) specified in ISO 14524.|
8067| SENSITIVITY_TYPE<sup>10+</sup>            | "SensitivityType"           | **Read/Write capability**: readable and writable<br> Sensitivity type.|
8068| STANDARD_OUTPUT_SENSITIVITY<sup>10+</sup> | "StandardOutputSensitivity" | **Read/Write capability**: readable and writable<br> Standard output sensitivity.|
8069| RECOMMENDED_EXPOSURE_INDEX<sup>10+</sup>  | "RecommendedExposureIndex"  | **Read/Write capability**: readable and writable<br> Recommended exposure index.|
8070| ISO_SPEED<sup>10+</sup>                   | "ISOSpeedRatings"           | **Read/Write capability**: readable and writable<br> ISO speed.|
8071| ISO_SPEED_LATITUDE_YYY <sup>12+</sup>     | "ISOSpeedLatitudeyyy"       | **Read/Write capability**: readable and writable<br> ISO speed latitude yyy value of the camera or input device, which is defined in ISO 12232.|
8072| ISO_SPEED_LATITUDE_ZZZ <sup>12+</sup>     | "ISOSpeedLatitudezzz"       | **Read/Write capability**: readable and writable<br> ISO speed latitude zzz value of the camera or input device, which is defined in ISO 12232.|
8073| EXIF_VERSION <sup>12+</sup>               | "ExifVersion"               | **Read/Write capability**: readable and writable<br> Version of the supported EXIF standard.|
8074| DATE_TIME_ORIGINAL<sup>9+</sup>           | "DateTimeOriginal"          | **Read/Write capability**: readable and writable<br> Time when the original image data was generated, for example, 2022:09:06 15:48:00.|
8075| DATE_TIME_DIGITIZED <sup>12+</sup>        | "DateTimeDigitized"         | **Read/Write capability**: readable and writable<br> Date and time when the image was stored as digital data, in the format of YYYY:MM:DD HH:MM:SS.|
8076| OFFSET_TIME <sup>12+</sup>                | "OffsetTime"                | **Read/Write capability**: readable and writable<br> Time with an offset from UTC when the image was captured, in the format of ±HH:MM.|
8077| OFFSET_TIME_ORIGINAL <sup>12+</sup>       | "OffsetTimeOriginal"        | **Read/Write capability**: readable and writable<br> Time with an offset from UTC when the original image was created. It is critical for time-sensitive applications.|
8078| OFFSET_TIME_DIGITIZED <sup>12+</sup>      | "OffsetTimeDigitized"       | **Read/Write capability**: readable and writable<br> Time with an offset from UTC when the image was digitized. It helps to accurately adjust the timestamp.|
8079| COMPONENTS_CONFIGURATION <sup>12+</sup>   | "ComponentsConfiguration"   | **Read/Write capability**: readable and writable<br> Specific information about compressed data.|
8080| COMPRESSED_BITS_PER_PIXEL <sup>12+</sup>  | "CompressedBitsPerPixel"    | **Read/Write capability**: readable and writable<br> Number of bits per pixel. It is specific to compressed data.|
8081| SHUTTER_SPEED <sup>12+</sup>              | "ShutterSpeedValue"         | **Read/Write capability**: readable and writable<br> Shutter speed, expressed in Additive System of Photographic Exposure (APEX) values.|
8082| APERTURE_VALUE<sup>10+</sup>              | "ApertureValue"             | **Read/Write capability**: readable and writable<br> Lens aperture. An example in the correct format is 4/1.|
8083| BRIGHTNESS_VALUE <sup>12+</sup>           | "BrightnessValue"           | **Read/Write capability**: readable and writable<br> Value of brightness, expressed in APEX values.|
8084| EXPOSURE_BIAS_VALUE<sup>10+</sup>         | "ExposureBiasValue"         | **Read/Write capability**: readable and writable<br> Exposure bias.|
8085| MAX_APERTURE_VALUE <sup>12+</sup>         | "MaxApertureValue"          | **Read/Write capability**: readable and writable<br> Smallest F number of the lens.|
8086| SUBJECT_DISTANCE <sup>12+</sup>           | "SubjectDistance"           | **Read/Write capability**: readable and writable<br> Distance to the subject, in meters.|
8087| METERING_MODE<sup>10+</sup>               | "MeteringMode"              | **Read/Write capability**: readable and writable<br> Metering mode.|
8088| LIGHT_SOURCE<sup>10+</sup>                | "LightSource"               | **Read/Write capability**: readable and writable<br> Light source. An example value is **Fluorescent**.|
8089| FLASH <sup>10+</sup>                      | "Flash"                     | **Read/Write capability**: readable and writable<br> Flash status.|
8090| FOCAL_LENGTH <sup>10+</sup>               | "FocalLength"               | **Read/Write capability**: readable and writable<br> Focal length of the lens.|
8091| SUBJECT_AREA <sup>12+</sup>               | "SubjectArea"               | **Read/Write capability**: readable and writable<br> Location and area of the main subject in the entire scene.|
8092| MAKER_NOTE <sup>12+</sup>                 | "MakerNote"                 | **Read/Write capability**: read-only<br> Marker used by EXIF/DCF manufacturers to record any required information.|
8093| SCENE_POINTER <sup>12+</sup>              | "HwMnoteScenePointer"       | **Read/Write capability**: read-only<br> Pointer to the scene.|
8094| SCENE_VERSION <sup>12+</sup>              | "HwMnoteSceneVersion"       | **Read/Write capability**: read-only<br> Scene algorithm version.|
8095| SCENE_FOOD_CONF<sup>11+</sup>             | "HwMnoteSceneFoodConf"      | **Read/Write capability**: read-only<br> Photographing scene: food.|
8096| SCENE_STAGE_CONF<sup>11+</sup>            | "HwMnoteSceneStageConf"     | **Read/Write capability**: read-only<br> Photographing scene: stage.|
8097| SCENE_BLUE_SKY_CONF<sup>11+</sup>         | "HwMnoteSceneBlueSkyConf"   | **Read/Write capability**: read-only<br> Photographing scene: blue sky.|
8098| SCENE_GREEN_PLANT_CONF<sup>11+</sup>      | "HwMnoteSceneGreenPlantConf" | **Read/Write capability**: read-only<br> Photographing scene: green plant.|
8099| SCENE_BEACH_CONF<sup>11+</sup>            | "HwMnoteSceneBeachConf"     | **Read/Write capability**: read-only<br> Photographing scene: beach.|
8100| SCENE_SNOW_CONF<sup>11+</sup>             | "HwMnoteSceneSnowConf"      | **Read/Write capability**: read-only<br> Photographing scene: snow.|
8101| SCENE_SUNSET_CONF<sup>11+</sup>           | "HwMnoteSceneSunsetConf"    | **Read/Write capability**: read-only<br> Photographing scene: sunset.|
8102| SCENE_FLOWERS_CONF<sup>11+</sup>          | "HwMnoteSceneFlowersConf"   | **Read/Write capability**: read-only<br> Photographing scene: flowers.|
8103| SCENE_NIGHT_CONF<sup>11+</sup>            | "HwMnoteSceneNightConf"     | **Read/Write capability**: read-only<br> Photographing scene: night.|
8104| SCENE_TEXT_CONF<sup>11+</sup>             | "HwMnoteSceneTextConf"      | **Read/Write capability**: read-only<br> Photographing scene: text.|
8105| FACE_POINTER <sup>12+</sup>               | "HwMnoteFacePointer"        | **Read/Write capability**: read-only<br> Face pointer.|
8106| FACE_VERSION <sup>12+</sup>               | "HwMnoteFaceVersion"        | **Read/Write capability**: read-only<br> Facial recognition algorithm version.|
8107| FACE_COUNT<sup>11+</sup>                  | "HwMnoteFaceCount"          | **Read/Write capability**: read-only<br> Number of faces.|
8108| FACE_CONF <sup>12+</sup>                  | "HwMnoteFaceConf"           | **Read/Write capability**: read-only<br> Face confidence.|
8109| FACE_SMILE_SCORE <sup>12+</sup>           | "HwMnoteFaceSmileScore"     | **Read/Write capability**: read-only<br> Smile score of for faces.|
8110| FACE_RECT <sup>12+</sup>                  | "HwMnoteFaceRect"           | **Read/Write capability**: read-only<br> Face rectangle.|
8111| FACE_LEYE_CENTER <sup>12+</sup>           | "HwMnoteFaceLeyeCenter"     | **Read/Write capability**: read-only<br> Left eye centered.|
8112| FACE_REYE_CENTER <sup>12+</sup>           | "HwMnoteFaceReyeCenter"     | **Read/Write capability**: read-only<br> Right eye centered.|
8113| FACE_MOUTH_CENTER <sup>12+</sup>          | "HwMnoteFaceMouthCenter"    | **Read/Write capability**: read-only<br> Mouth centered.|
8114| CAPTURE_MODE <sup>10+</sup>               | "HwMnoteCaptureMode"        | **Read/Write capability**: readable and writable<br> Capture mode.|
8115| BURST_NUMBER <sup>12+</sup>               | "HwMnoteBurstNumber"        | **Read/Write capability**: read-only<br> Number of burst shooting times.|
8116| FRONT_CAMERA <sup>12+</sup>               | "HwMnoteFrontCamera"        | **Read/Write capability**: read-only<br> Whether the front camera is used to take a selfie.|
8117| ROLL_ANGLE <sup>11+</sup>                 | "HwMnoteRollAngle"          | **Read/Write capability**: read-only<br> Roll angle.|
8118| PITCH_ANGLE<sup>11+</sup>                 | "HwMnotePitchAngle"         | **Read/Write capability**: read-only<br> Pitch angle.|
8119| PHYSICAL_APERTURE <sup>10+</sup>          | "HwMnotePhysicalAperture"   | **Read/Write capability**: read-only<br> Physical aperture.|
8120| FOCUS_MODE<sup>11+</sup>                  | "HwMnoteFocusMode"          | **Read/Write capability**: read-only<br> Focus mode.|
8121| USER_COMMENT <sup>10+</sup>               | "UserComment"               | **Read/Write capability**: readable and writable<br> User comments.|
8122| SUBSEC_TIME <sup>12+</sup>                | "SubsecTime"                | **Read/Write capability**: readable and writable<br> Tag used to record fractions of seconds for the **DateTime** tag.|
8123| SUBSEC_TIME_ORIGINAL <sup>12+</sup>       | "SubsecTimeOriginal"        | **Read/Write capability**: readable and writable<br> Tag used to record fractions of seconds for the **DateTimeOriginal** tag.|
8124| SUBSEC_TIME_DIGITIZED <sup>12+</sup>      | "SubsecTimeDigitized"       | **Read/Write capability**: readable and writable<br> Tag used to record fractions of seconds for the **DateTimeDigitized** tag.|
8125| FLASHPIX_VERSION <sup>12+</sup>           | "FlashpixVersion"           | **Read/Write capability**: readable and writable<br> FlashPix format version supported by an FPXR file. It is used to enhance device compatibility.|
8126| COLOR_SPACE <sup>12+</sup>                | "ColorSpace"                | **Read/Write capability**: readable and writable<br> Color space information, which is usually recorded as a color space specifier.|
8127| PIXEL_X_DIMENSION <sup>10+</sup>          | "PixelXDimension"           | **Read/Write capability**: readable and writable<br> Pixel X dimension.|
8128| PIXEL_Y_DIMENSION<sup>10+</sup>           | "PixelYDimension"           | **Read/Write capability**: readable and writable<br> Pixel Y dimension.|
8129| RELATED_SOUND_FILE <sup>12+</sup>         | "RelatedSoundFile"          | **Read/Write capability**: readable and writable<br> Name of an audio file related to the image data.|
8130| FLASH_ENERGY <sup>12+</sup>               | "FlashEnergy"               | **Read/Write capability**: readable and writable<br> Strobe energy at the time the image was captured, in Beam Candle Power Seconds (BCPS).|
8131| SPATIAL_FREQUENCY_RESPONSE <sup>12+</sup> | "SpatialFrequencyResponse"  | **Read/Write capability**: readable and writable<br> Spatial frequency table of the camera or input device.|
8132| FOCAL_PLANE_X_RESOLUTION <sup>12+</sup>   | "FocalPlaneXResolution"     | **Read/Write capability**: readable and writable<br> Number of pixels in the image width (X) direction per FocalPlaneResolutionUnit.|
8133| FOCAL_PLANE_Y_RESOLUTION <sup>12+</sup>   | "FocalPlaneYResolution"     | **Read/Write capability**: readable and writable<br> Number of pixels in the image height (Y) direction per FocalPlaneResolutionUnit.|
8134| FOCAL_PLANE_RESOLUTION_UNIT <sup>12+</sup> | "FocalPlaneResolutionUnit"  | **Read/Write capability**: readable and writable<br> Unit for measuring FocalPlaneXResolution and FocalPlaneYResolution.|
8135| SUBJECT_LOCATION <sup>12+</sup>           | "SubjectLocation"           | **Read/Write capability**: readable and writable<br> Location of the main subject relative to the left edge.|
8136| EXPOSURE_INDEX <sup>12+</sup>             | "ExposureIndex"             | **Read/Write capability**: readable and writable<br> Exposure index selected at the time the image is captured.|
8137| SENSING_METHOD <sup>12+</sup>             | "SensingMethod"             | **Read/Write capability**: readable and writable<br> Type of the image sensor on the camera.|
8138| FILE_SOURCE <sup>12+</sup>                | "FileSource"                | **Read/Write capability**: readable and writable<br> Image source.|
8139| SCENE_TYPE<sup>9+</sup>                   | "SceneType"                 | **Read/Write capability**: readable and writable<br> Type of the scene, for example, portrait, scenery, motion, and night.|
8140| CFA_PATTERN <sup>12+</sup>                | "CFAPattern"                | **Read/Write capability**: readable and writable<br> Color Filter Array (CFA) geometric pattern of the image sensor.|
8141| CUSTOM_RENDERED <sup>12+</sup>            | "CustomRendered"            | **Read/Write capability**: readable and writable<br> Special processing on image data.|
8142| EXPOSURE_MODE <sup>12+</sup>              | "ExposureMode"              | **Read/Write capability**: readable and writable<br> Exposure mode set when the image was captured.|
8143| WHITE_BALANCE <sup>10+</sup>              | "WhiteBalance"              | **Read/Write capability**: readable and writable<br> White balance.|
8144| DIGITAL_ZOOM_RATIO <sup>12+</sup>         | "DigitalZoomRatio"          | **Read/Write capability**: readable and writable<br> Digital zoom ratio when the image was captured.|
8145| FOCAL_LENGTH_IN_35_MM_FILM <sup>10+</sup> | "FocalLengthIn35mmFilm"     | **Read/Write capability**: readable and writable<br> Focal length in 35mm film.|
8146| SCENE_CAPTURE_TYPE <sup>12+</sup>         | "SceneCaptureType"          | **Read/Write capability**: readable and writable<br> Type of the scene that was captured.|
8147| GAIN_CONTROL <sup>12+</sup>               | "GainControl"               | **Read/Write capability**: readable and writable<br> Degree of overall image gain adjustment.|
8148| CONTRAST <sup>12+</sup>                   | "Contrast"                  | **Read/Write capability**: readable and writable<br> Direction of contrast processing used by the camera.|
8149| SATURATION <sup>12+</sup>                 | "Saturation"                | **Read/Write capability**: readable and writable<br> Direction of saturation processing used by the camera.|
8150| SHARPNESS <sup>12+</sup>                  | "Sharpness"                 | **Read/Write capability**: readable and writable<br> Direction of sharpness processing used by the camera.|
8151| DEVICE_SETTING_DESCRIPTION <sup>12+</sup> | "DeviceSettingDescription"  | **Read/Write capability**: readable and writable<br> Information about the photographing conditions of a specific camera model.|
8152| SUBJECT_DISTANCE_RANGE <sup>12+</sup>     | "SubjectDistanceRange"      | **Read/Write capability**: readable and writable<br> Distance to the subject.|
8153| IMAGE_UNIQUE_ID <sup>12+</sup>            | "ImageUniqueID"             | **Read/Write capability**: readable and writable<br> Unique identifier assigned to each image.|
8154| CAMERA_OWNER_NAME <sup>12+</sup>          | "CameraOwnerName"           | **Read/Write capability**: readable and writable<br> Name of the camera owner.|
8155| BODY_SERIAL_NUMBER <sup>12+</sup>         | "BodySerialNumber"          | **Read/Write capability**: readable and writable<br> Serial number of the camera body.|
8156| LENS_SPECIFICATION <sup>12+</sup>         | "LensSpecification"         | **Read/Write capability**: readable and writable<br> Specifications of the lens.|
8157| LENS_MAKE <sup>12+</sup>                  | "LensMake"                  | **Read/Write capability**: readable and writable<br> Manufacturer of the lens.|
8158| LENS_MODEL <sup>12+</sup>                 | "LensModel"                 | **Read/Write capability**: readable and writable<br> Model of the lens.|
8159| LENS_SERIAL_NUMBER <sup>12+</sup>         | "LensSerialNumber"          | **Read/Write capability**: readable and writable<br> Serial number of the lens.|
8160| COMPOSITE_IMAGE <sup>12+</sup>            | "CompositeImage"            | **Read/Write capability**: readable and writable<br> Whether the image is a composite image.|
8161| SOURCE_IMAGE_NUMBER_OF_COMPOSITE_IMAGE <sup>12+</sup>   | "SourceImageNumberOfCompositeImage"       | **Read/Write capability**: readable and writable<br> Number of source images of the composite image.|
8162| SOURCE_EXPOSURE_TIMES_OF_COMPOSITE_IMAGE <sup>12+</sup> | "SourceExposureTimesOfCompositeImage"     | **Read/Write capability**: readable and writable<br> Exposure time of source images of the composite image.|
8163| GAMMA <sup>12+</sup>                      | "Gamma"                     | **Read/Write capability**: readable and writable<br> Gamma value.|
8164| DNG_VERSION <sup>12+</sup>                | "DNGVersion"                | **Read/Write capability**: readable and writable<br> DNG version. It encodes the DNG 4-tier version number.|
8165| DEFAULT_CROP_SIZE <sup>12+</sup>          | "DefaultCropSize"           | **Read/Write capability**: readable and writable<br> Size of the final image area, in raw image coordinates, taking into account extra pixels around the edges of the final image.|
8166| GIF_LOOP_COUNT <sup>12+</sup>             | "GIFLoopCount"              | **Read/Write capability**: read-only<br> Number of GIF loops. The value **0** means an infinite loop, and other values means the number of loops.|
8167| IS_XMAGE_SUPPORTED <sup>12+</sup> | "HwMnoteIsXmageSupported" | **Read/Write capability**: readable and writable<br>Whether XMAGE is supported.|
8168| XMAGE_MODE <sup>12+</sup> | "HwMnoteXmageMode" | **Read/Write capability**: readable and writable<br>XMAGE watermark mode.|
8169| XMAGE_LEFT <sup>12+</sup> | "HwMnoteXmageLeft" | **Read/Write capability**: readable and writable<br>X1 coordinate of the watermark region.|
8170| XMAGE_TOP <sup>12+</sup> | "HwMnoteXmageTop" | **Read/Write capability**: readable and writable<br>Y1 coordinate of the watermark region.|
8171| XMAGE_RIGHT <sup>12+</sup> | "HwMnoteXmageRight" | **Read/Write capability**: readable and writable<br>X2 coordinate of the watermark region.|
8172| XMAGE_BOTTOM <sup>12+</sup> | "HwMnoteXmageBottom" | **Read/Write capability**: readable and writable<br>Y2 coordinate of the watermark region.|
8173| CLOUD_ENHANCEMENT_MODE <sup>12+</sup> | "HwMnoteCloudEnhancementMode" | **Read/Write capability**: readable and writable<br>Cloud enhancement mode.|
8174| WIND_SNAPSHOT_MODE <sup>12+</sup> | "HwMnoteWindSnapshotMode" | **Read/Write capability**: read-only<br>Motion snapshot mode.|
8175
8176## FragmentMapPropertyKey<sup>13+</sup>
8177
8178Enumerates the fragment map information.
8179
8180**System capability**: SystemCapability.Multimedia.Image.Core
8181
8182| Name         | Value                   | Description                               |
8183| ------------- | --------------------- | ----------------------------------- |
8184| X_IN_ORIGINAL | "XInOriginal"         | X coordinate of the upper left corner of the fragment map in the original image.|
8185| Y_IN_ORIGINAL | "YInOriginal"         | Y coordinate of the upper left corner of the fragment map in the original image.|
8186| WIDTH         | "FragmentImageWidth"  | Width of the fragment map.                   |
8187| HEIGHT        | "FragmentImageHeight" | Height of the fragment map.                   |
8188
8189## ImageFormat<sup>9+</sup>
8190
8191Enumerates the image formats.
8192
8193**System capability**: SystemCapability.Multimedia.Image.Core
8194
8195| Name        |   Value  | Description                |
8196| ------------ | ------ | -------------------- |
8197| YCBCR_422_SP | 1000   | YCBCR422 semi-planar format.|
8198| JPEG         | 2000   | JPEG encoding format.      |
8199
8200## ComponentType<sup>9+</sup>
8201
8202Enumerates the color component types of images.
8203
8204**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
8205
8206| Name |   Value  | Description       |
8207| ----- | ------ | ----------- |
8208| YUV_Y | 1      | Luminance component. |
8209| YUV_U | 2      | Chrominance component. |
8210| YUV_V | 3      | Chrominance component. |
8211| JPEG  | 4      | JPEG type.|
8212
8213## Component<sup>9+</sup>
8214
8215Describes the color components of an image.
8216
8217**System capability**: SystemCapability.Multimedia.Image.Core
8218
8219| Name         | Type                            | Read Only| Optional| Description        |
8220| ------------- | -------------------------------- | ---- | ---- | ------------ |
8221| componentType | [ComponentType](#componenttype9) | Yes  | No  | Color component type.  |
8222| rowStride     | number                           | Yes  | No  | Row stride. The camera preview stream data needs to be read by stride. For details, see [Dual-Channel Preview (ArkTS)](../../media/camera/camera-dual-channel-preview.md).      |
8223| pixelStride   | number                           | Yes  | No  | Pixel stride.  |
8224| byteBuffer    | ArrayBuffer                      | Yes  | No  | Component buffer.|
8225
8226## DecodingDynamicRange<sup>12+</sup>
8227
8228Describes the desired dynamic range of an image during decoding.
8229
8230**System capability**: SystemCapability.Multimedia.Image.Core
8231
8232| Name         | Value      | Description        |
8233| ------------- | ----------| ------------ |
8234| AUTO          | 0    | The image is decoded based on the format. If the image is in HDR format, it is decoded based on the HDR content; otherwise, it is decoded based on the SDR content. The image source created by calling [CreateIncrementalSource](#imagecreateincrementalsource9) is decoded into SDR content. |
8235| SDR           | 1    | The image is decoded according to the standard dynamic range.  |
8236| HDR           | 2    | The image is decoded according to the high dynamic range. The image source created by calling [CreateIncrementalSource](#imagecreateincrementalsource9) is decoded into SDR content.    |
8237
8238## PackingDynamicRange<sup>12+</sup>
8239
8240Describes the desired dynamic range of an image during encoding.
8241
8242**System capability**: SystemCapability.Multimedia.Image.Core
8243
8244| Name         | Value      | Description        |
8245| ------------- | ----------| ------------ |
8246| AUTO          | 0    | Adaptive. The [pixelmap](#pixelmap7) is encoded based on the format. If the PixelMap is in HDR format, it is encoded based on the HDR content; otherwise, it is encoded based on the SDR content. |
8247| SDR           | 1    | The image is decoded according to the standard dynamic range.  |
8248
8249## HdrMetadataKey<sup>12+</sup>
8250
8251Enumerates the keys of HDR metadata used by [pixelmap](#pixelmap7).
8252
8253**System capability**: SystemCapability.Multimedia.Image.Core
8254
8255| Name         | Value      | Description        |
8256| ------------- | ----------| ------------ |
8257| HDR_METADATA_TYPE    | 0    | Metadata type used by [pixelmap](#pixelmap7). |
8258| HDR_STATIC_METADATA  | 1    | Static metadata.  |
8259| HDR_DYNAMIC_METADATA | 2    | Dynamic metadata.  |
8260| HDR_GAINMAP_METADATA | 3    | Metadata used by gain maps.  |
8261
8262## HdrMetadataType<sup>12+</sup>
8263
8264Enumerates the values available for **HDR_METADATA_TYPE** in [HdrMetadataKey](#hdrmetadatakey12).
8265
8266**System capability**: SystemCapability.Multimedia.Image.Core
8267
8268| Name         | Value      | Description        |
8269| ------------- | ----------| ------------ |
8270| NONE     | 0    | No metadata. |
8271| BASE     | 1    | Metadata used for base graphics.  |
8272| GAINMAP  | 2    | Metadata used for gain maps.  |
8273| ALTERNATE| 3    | Metadata used for synthesized HDR graphics.  |
8274
8275## HdrStaticMetadata<sup>12+</sup>
8276
8277Describes the static metadata keys, that is, the values available for **HDR_STATIC_METADATA** in [HdrMetadataKey](#hdrmetadatakey12).
8278
8279**System capability**: SystemCapability.Multimedia.Image.Core
8280
8281| Name         | Type      | Read Only| Optional| Description        |
8282| ------------- | ----------| -- | -- | ------------ |
8283| displayPrimariesX     | Array\<number>  | No| No| X coordinate of the three primary colors of the display device after normalization. The array length is 3. The unit is 0.00002. The value range is [0.0, 1.0]. |
8284| displayPrimariesY     | Array\<number>  | No| No| Y coordinate of the three primary colors of the display device after normalization. The array length is 3. The unit is 0.00002. The value range is [0.0, 1.0]. |
8285| whitePointX  | number  | No| No| X coordinate of the white point after normalization. The unit is 0.00002. The value range is [0.0, 1.0].  |
8286| whitePointY  | number   | No| No| X coordinate of the white point after normalization. The unit is 0.00002. The value range is [0.0, 1.0].  |
8287| maxLuminance  | number  | No| No| Maximum luminance of the main monitor. The unit is 1, and the maximum value is 65535.  |
8288| minLuminance  | number   | No| No| Minimum luminance of the main monitor. The unit is 0.0001, and the maximum value is 6.55535.  |
8289| maxContentLightLevel  | number  | No| No| Maximum luminance of the displayed content. The unit is 1, and the maximum value is 65535.  |
8290| maxFrameAverageLightLevel  | number  | No| No| Maximum average luminance of the displayed content. The unit is 1, and the maximum value is 65535.|
8291
8292## GainmapChannel<sup>12+</sup>
8293
8294Describes the data content of a single channel of the gain map. For details, see ISO 21496-1.
8295
8296**System capability**: SystemCapability.Multimedia.Image.Core
8297
8298| Name         | Type      | Read Only| Optional| Description        |
8299| ------------- | ----------| -- | -- | ------------ |
8300| gainmapMax     | number   | No| No| Maximum value of the gain map. For details, see ISO 21496-1. |
8301| gainmapMin     | number   | No| No| Minimum value of the gain map. For details, see ISO 21496-1. |
8302| gamma  | number    | No| No| Gamma. For details, see ISO 21496-1.  |
8303| baseOffset  | number     | No| No| Offset of the base graphic. For details, see ISO 21496-1.  |
8304| alternateOffset  | number    | No| No| Offset of the alternative graphic that can be extracted. For details, see ISO 21496-1.   |
8305
8306## HdrGainmapMetadata<sup>12+</sup>
8307
8308Describes the metadata keys used by a gain map, that is, the values available for **HDR_GAINMAP_METADATA** in [HdrMetadataKey](#hdrmetadatakey12). For details, see ISO 21496-1.
8309
8310**System capability**: SystemCapability.Multimedia.Image.Core
8311
8312| Name         | Type      | Read Only| Optional| Description        |
8313| ------------- | ----------| -- | -- | ------------ |
8314| writerVersion     | number   | No| No| Version used by the metadata editor. |
8315| miniVersion     | number   | No| No| Minimum version that needs to be understood for metadata parsing. |
8316| gainmapChannelCount  | number    | No| No| Number of color channels of the gain map. When the value is 3, the metadata values of the RGB channels are different. When the value is 1, the metadata values of the RGB channels are the same. For details, see ISO 21496-1. |
8317| useBaseColorFlag  | boolean     | No| No| Whether to use the color space of the base graphic. For details, see ISO 21496-1.  |
8318| baseHeadroom  | number    | No| No|  Headroom of the base graphic, which means the additional brightness that can be added to the base graphic. For details, see ISO 21496-1.  |
8319| alternateHeadroom  | number     | No| No|  Headroom of the alternate graphic. For details, see ISO 21496-1. |
8320| channels  | Array<[GainmapChannel](#gainmapchannel12)> | No| No| Number of channels. The length is 3. For details, see ISO 21496-1.|
8321
8322## HdrMetadataValue<sup>12+</sup>
8323
8324type HdrMetadataValue = HdrMetadataType | HdrStaticMetadata | ArrayBuffer | HdrGainmapMetadata
8325
8326Describes the HDR metadata values used by a PixelMap, which corresponds to the values available for [HdrMetadataKey](#hdrmetadatakey12).
8327
8328**System capability**: SystemCapability.Multimedia.Image.Core
8329
8330| Type               | Description                                           |
8331| ------------------- | ----------------------------------------------- |
8332| [HdrMetadataType](#hdrmetadatatype12) | Metadata value corresponding to the **HDR_GAINMAP_METADATA** key in [HdrMetadataKey](#hdrmetadatakey12).|
8333| [HdrStaticMetadata](#hdrstaticmetadata12) | Metadata value corresponding to the **HDR_STATIC_METADATA** key in [HdrMetadataKey](#hdrmetadatakey12).|
8334| ArrayBuffer | Metadata value corresponding to the **HDR_DYNAMIC_METADATA** key in [HdrMetadataKey](#hdrmetadatakey12).|
8335| [HdrGainmapMetadata](#hdrgainmapmetadata12) | Metadata value corresponding to the **HDR_GAINMAP_METADATA** key in [HdrMetadataKey](#hdrmetadatakey12).|
8336
8337## AntiAliasingLevel<sup>12+</sup>
8338
8339Enumerates the anti-aliasing levels.
8340
8341**Atomic service API**: This API can be used in atomic services since API version 14.
8342
8343**System capability**: SystemCapability.Multimedia.Image.Core
8344
8345| Name                  |   Value  | Description             |
8346| ---------------------- | ------ | ----------------- |
8347| NONE                | 0      | Nearest neighbor interpolation.  |
8348| LOW                 | 1      | Bilinear interpolation.  |
8349| MEDIUM              | 2      | Bilinear interpolation with mipmap enabled. You are advised to use this value when zooming out an image.  |
8350| HIGH                | 3      | Cubic interpolation.  |
8351
8352## Supplementary Information
8353### SVG Tags
8354
8355The SVG tags are supported since API version 10. The used version is (SVG) 1.1. An XML declaration that starts with **<?xml** needs to be added to an SVG file, and the width and height of the SVG tag need to be set. Currently, the following tags are supported:
8356- a
8357- circla
8358- clipPath
8359- defs
8360- ellipse
8361- feBlend
8362- feColorMatrix
8363- feComposite
8364- feDiffuseLighting
8365- feDisplacementMap
8366- feDistantLight
8367- feFlood
8368- feGaussianBlur
8369- feImage
8370- feMorphology
8371- feOffset
8372- fePointLight
8373- feSpecularLighting
8374- feSpotLight
8375- feTurbulence
8376- filter
8377- g
8378- image
8379- line
8380- linearGradient
8381- mask
8382- path
8383- pattern
8384- polygon
8385- polyline
8386- radialGradient
8387- rect
8388- stop
8389- svg
8390- text
8391- textPath
8392- tspan
8393- use
8394