1
+ /*
2
+ * Copyright 2025 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
package com.google.firebase.ai.type
2
18
3
19
import kotlinx.serialization.Serializable
4
20
21
+ /* *
22
+ * Configuration parameters to use for imagen editing.
23
+ * @property image the base image to be edited.
24
+ * @property editMode specifies the edititing mode for this request.
25
+ * @property mask the mask to specify which sections of the base image can be edited.
26
+ * @property maskDilation a percentage by which to shrink the mask to allow some edge blending.
27
+ * @property editSteps the number of intermediate steps for the edit to take.
28
+ */
5
29
@PublicPreviewAPI
6
30
public class ImagenEditingConfig (
7
31
public val image : ImagenInlineImage ,
@@ -14,6 +38,18 @@ public class ImagenEditingConfig(
14
38
public fun builder (): Builder = Builder ()
15
39
}
16
40
41
+ /* *
42
+ * Builder for creating a [ImagenEditingConfig].
43
+ *
44
+ * Mainly intended for Java interop. Kotlin consumers should use [imagenEditingConfig] for a more
45
+ * idiomatic experience.
46
+ *
47
+ * @property image see [ImagenEditingConfig.image]
48
+ * @property editMode see [ImagenEditingConfig.editMode]
49
+ * @property mask see [ImagenEditingConfig.mask]
50
+ * @property maskDilation see [ImagenEditingConfig.maskDilation]
51
+ * @property editSteps see [ImagenEditingConfig.editSteps]
52
+ */
17
53
public class Builder {
18
54
@JvmField public var image: ImagenInlineImage ? = null
19
55
@JvmField public var editMode: ImagenEditMode ? = null
@@ -33,6 +69,7 @@ public class ImagenEditingConfig(
33
69
34
70
public fun setEditSteps (editSteps : Int ): Builder = apply { this .editSteps = editSteps }
35
71
72
+ /* * Creates a new [ImagenEditingConfig] with the attached arguments */
36
73
public fun build (): ImagenEditingConfig {
37
74
if (image == null ) {
38
75
throw IllegalStateException (" ImagenEditingConfig must contain an image" )
@@ -60,6 +97,19 @@ public class ImagenEditingConfig(
60
97
)
61
98
}
62
99
100
+ /* *
101
+ * Helper method to construct a [ImagenEditingConfig] in a DSL-like manner.
102
+ *
103
+ * Example Usage:
104
+ * ```
105
+ * imagenEditingConfig {
106
+ * image = baseImage
107
+ * mask = imageMask
108
+ * editMode = ImagenEditMode.INPAINTING_REMOVAL
109
+ * maskDilation = 0.05
110
+ * }
111
+ * ```
112
+ */
63
113
@PublicPreviewAPI
64
114
public fun imagenEditingConfig (init : ImagenEditingConfig .Builder .() -> Unit ): ImagenEditingConfig {
65
115
val builder = ImagenEditingConfig .builder()
0 commit comments