1e41f4b71Sopenharmony_ci# @ohos.app.ability.PhotoEditorExtensionAbility (Image Editing)
2e41f4b71Sopenharmony_ciThe PhotoEditorExtensionAbility, which inherits from the ExtensionAbility, enables your application to provide an image editing page for applications that do not have the image editing capability. After an application uses **startAbilityByType** to start a vertical domain panel with available image editing applications that have implemented the PhotoEditorExtensionAbility, the user can select one of the applications on the panel to display an image editing page.
3e41f4b71Sopenharmony_ci> **NOTE**
4e41f4b71Sopenharmony_ci> 
5e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
6e41f4b71Sopenharmony_ci> 
7e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model.
8e41f4b71Sopenharmony_ci## Modules to Import
9e41f4b71Sopenharmony_ci```ts
10e41f4b71Sopenharmony_ciimport { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
11e41f4b71Sopenharmony_ci```
12e41f4b71Sopenharmony_ci## Properties
13e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
14e41f4b71Sopenharmony_ci|  Name|Type  |Read Only  |Optional  |Description  |
15e41f4b71Sopenharmony_ci| ------------ | ------------ | ------------ | ------------ | ------------ |
16e41f4b71Sopenharmony_ci|  context | [PhotoEditorExtensionContext](./js-apis-app-ability-photoEditorExtensionContext.md)  | No | Yes | Context. |
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## PhotoEditorExtensionAbility.onCreate
19e41f4b71Sopenharmony_cionCreate(): void
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciCalled to initialize the service logic when a PhotoEditorExtensionAbility is created.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Example**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci```ts
30e41f4b71Sopenharmony_ciimport { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ciconst TAG: string = '[testTag] ExamplePhotoEditorAbility';
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ciexport default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
35e41f4b71Sopenharmony_ci  onCreate() {
36e41f4b71Sopenharmony_ci    console.info(TAG, `onCreate`);
37e41f4b71Sopenharmony_ci  }
38e41f4b71Sopenharmony_ci}
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci```
41e41f4b71Sopenharmony_ci## PhotoEditorExtensionAbility.onStartContentEditing
42e41f4b71Sopenharmony_cionStartContentEditing(uri: string, want: Want, session: UIExtensionContentSession): void
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ciCalled when a **UIExtensionContentSession** instance is created for this PhotoEditorExtensionAbility. The instance can be used to read the original image and load a page.
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model.
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci**Parameters**
51e41f4b71Sopenharmony_ci| Name|  Type| Mandatory | Description |
52e41f4b71Sopenharmony_ci| ------------ | ------------ | ------------ | ------------ |
53e41f4b71Sopenharmony_ci|  uri |  string |  Yes| [URI](../apis-core-file-kit/js-apis-file-fileuri.md) of the image to edit. The format is file://\<bundleName>/\<sandboxPath>. |
54e41f4b71Sopenharmony_ci| want  | [Want](./js-apis-app-ability-want.md)  | Yes | Want information, including the ability name and bundle name. |
55e41f4b71Sopenharmony_ci|  session |  [UIExtensionContentSession](./js-apis-app-ability-uiExtensionContentSession.md) | Yes |  UI content information related to the PhotoEditorExtensionAbility.|
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**Example**
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci```ts
61e41f4b71Sopenharmony_ciimport { PhotoEditorExtensionAbility, Want, UIExtensionContentSession } from '@kit.AbilityKit';
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ciconst TAG: string = '[testTag] ExamplePhotoEditorAbility';
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ciexport default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
66e41f4b71Sopenharmony_ci  onStartContentEditing(uri: string, want: Want, session: UIExtensionContentSession) {
67e41f4b71Sopenharmony_ci    console.info(TAG, `onStartContentEditing want: ${JSON.stringify(want)}, uri: ${uri}`);
68e41f4b71Sopenharmony_ci  }
69e41f4b71Sopenharmony_ci}
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci```
72e41f4b71Sopenharmony_ci## PhotoEditorExtensionAbility.onForeground
73e41f4b71Sopenharmony_cionForeground(): void
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ciCalled when this PhotoEditorExtensionAbility is switched from the background to the foreground.
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci**Example**
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci```ts
84e41f4b71Sopenharmony_ciimport { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ciconst TAG: string = '[testTag] ExamplePhotoEditorAbility';
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciexport default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
89e41f4b71Sopenharmony_ci  onForeground() {
90e41f4b71Sopenharmony_ci    console.info(TAG, `onForeground`);
91e41f4b71Sopenharmony_ci  }
92e41f4b71Sopenharmony_ci}
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci```
95e41f4b71Sopenharmony_ci## PhotoEditorExtensionAbility.onBackground
96e41f4b71Sopenharmony_cionBackground(): void
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ciCalled when this PhotoEditorExtensionAbility is switched from the foreground to the background.
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**Example**
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci```ts
107e41f4b71Sopenharmony_ciimport { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ciconst TAG: string = '[testTag] ExamplePhotoEditorAbility';
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ciexport default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
112e41f4b71Sopenharmony_ci  onBackground() {
113e41f4b71Sopenharmony_ci    console.info(TAG, `onBackground`);
114e41f4b71Sopenharmony_ci  }
115e41f4b71Sopenharmony_ci}
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci```
118e41f4b71Sopenharmony_ci## PhotoEditorExtensionAbility.onDestroy
119e41f4b71Sopenharmony_cionDestroy(): void | Promise\<void>
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciCalled to clear resources when this PhotoEditorExtensionAbility is destroyed.
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**Model restriction**: This API can be used only in the stage model.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AppExtension.PhotoEditorExtension
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**Return value**
128e41f4b71Sopenharmony_ci|  Type|Description  |
129e41f4b71Sopenharmony_ci| ------------ | ------------ |
130e41f4b71Sopenharmony_ci|  Promise\<void> |  Promise that returns no value.|
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci**Example**
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci```ts
135e41f4b71Sopenharmony_ciimport { PhotoEditorExtensionAbility } from '@kit.AbilityKit';
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ciconst TAG: string = '[testTag] ExamplePhotoEditorAbility';
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciexport default class ExamplePhotoEditorAbility extends PhotoEditorExtensionAbility {
140e41f4b71Sopenharmony_ci  onDestroy() {
141e41f4b71Sopenharmony_ci    console.info(TAG, `onDestroy`);
142e41f4b71Sopenharmony_ci  }
143e41f4b71Sopenharmony_ci}
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci```
146