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+
117package com.google.firebase.ai.type
218
319import kotlinx.serialization.Serializable
420
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+ */
529@PublicPreviewAPI
630public class ImagenEditingConfig (
731 public val image : ImagenInlineImage ,
@@ -14,6 +38,18 @@ public class ImagenEditingConfig(
1438 public fun builder (): Builder = Builder ()
1539 }
1640
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+ */
1753 public class Builder {
1854 @JvmField public var image: ImagenInlineImage ? = null
1955 @JvmField public var editMode: ImagenEditMode ? = null
@@ -33,6 +69,7 @@ public class ImagenEditingConfig(
3369
3470 public fun setEditSteps (editSteps : Int ): Builder = apply { this .editSteps = editSteps }
3571
72+ /* * Creates a new [ImagenEditingConfig] with the attached arguments */
3673 public fun build (): ImagenEditingConfig {
3774 if (image == null ) {
3875 throw IllegalStateException (" ImagenEditingConfig must contain an image" )
@@ -60,6 +97,19 @@ public class ImagenEditingConfig(
6097 )
6198}
6299
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+ */
63113@PublicPreviewAPI
64114public fun imagenEditingConfig (init : ImagenEditingConfig .Builder .() -> Unit ): ImagenEditingConfig {
65115 val builder = ImagenEditingConfig .builder()
0 commit comments