# `Gemini.Types.Generation.Image`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L1)

Type definitions for image generation using Google's Imagen models.

Imagen is Google's text-to-image generation model that creates high-quality images
from text descriptions. These types support image generation, editing, and upscaling
operations through the Vertex AI API.

## Supported Models

- `imagegeneration@006` - Latest stable Imagen model
- `imagen-3.0-generate-001` - Imagen 3.0 generation model

## Example

    config = %ImageGenerationConfig{
      number_of_images: 4,
      aspect_ratio: "1:1",
      safety_filter_level: :block_some,
      person_generation: :allow_adult
    }

    {:ok, images} = Gemini.APIs.Images.generate(
      "A serene mountain landscape at sunset",
      config
    )

See `Gemini.APIs.Images` for API functions.

# `aspect_ratio`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L64)

```elixir
@type aspect_ratio() :: String.t()
```

Aspect ratio for generated images.

Common aspect ratios:
- `"1:1"` - Square (1024x1024)
- `"9:16"` - Portrait, mobile (768x1344)
- `"16:9"` - Landscape, desktop (1344x768)
- `"4:3"` - Standard portrait (896x1152)
- `"3:4"` - Standard landscape (1152x896)

# `edit_mode`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L81)

```elixir
@type edit_mode() :: :inpainting | :outpainting | :product_image
```

Edit mode for image editing operations.

- `:inpainting` - Edit specific regions (requires mask)
- `:outpainting` - Extend image beyond original boundaries (requires mask)
- `:product_image` - Product-focused editing

# `person_generation`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L52)

```elixir
@type person_generation() :: :allow_adult | :allow_all | :allow_none | :dont_allow
```

Person generation policy.

- `:allow_adult` - Allow generation of adult humans
- `:allow_all` - Allow generation of humans of all ages
- `:allow_none` - Do not generate recognizable people

Legacy alias: `:dont_allow` (mapped to `:allow_none`)

# `safety_filter_level`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L41)

```elixir
@type safety_filter_level() :: :block_most | :block_some | :block_few | :block_none
```

Safety filter levels for generated images.

- `:block_most` - Strictest filtering, blocks most potentially sensitive content
- `:block_some` - Moderate filtering (recommended for most use cases)
- `:block_few` - Permissive filtering, blocks only highly sensitive content
- `:block_none` - No safety filtering applied

# `t`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L123)

```elixir
@type t() :: Gemini.Types.Generation.Image.ImageGenerationConfig.t()
```

# `upscale_factor`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L72)

```elixir
@type upscale_factor() :: :x2 | :x4
```

Upscale factor for image enhancement.

- `:x2` - 2x upscale (e.g., 1024x1024 -> 2048x2048)
- `:x4` - 4x upscale (e.g., 1024x1024 -> 4096x4096)

# `build_edit_params`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L297)

```elixir
@spec build_edit_params(
  String.t(),
  String.t(),
  String.t() | nil,
  Gemini.Types.Generation.Image.EditImageConfig.t()
) :: map()
```

Builds parameters map for image editing API request.

# `build_generation_params`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L273)

```elixir
@spec build_generation_params(
  String.t(),
  Gemini.Types.Generation.Image.ImageGenerationConfig.t()
) ::
  map()
```

Builds parameters map for image generation API request.

# `build_upscale_params`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L327)

```elixir
@spec build_upscale_params(
  String.t(),
  Gemini.Types.Generation.Image.UpscaleImageConfig.t()
) :: map()
```

Builds parameters map for image upscaling API request.

# `format_edit_mode`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L253)

```elixir
@spec format_edit_mode(edit_mode()) :: String.t()
```

Converts edit mode to API format.

## Examples

    iex> format_edit_mode(:inpainting)
    "inpainting"

# `format_person_generation`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L239)

```elixir
@spec format_person_generation(person_generation()) :: String.t()
```

Converts person generation policy to API format.

## Examples

    iex> format_person_generation(:allow_adult)
    "allowAdult"

# `format_safety_filter_level`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L225)

```elixir
@spec format_safety_filter_level(safety_filter_level()) :: String.t()
```

Converts safety filter level atom to API format.

## Examples

    iex> format_safety_filter_level(:block_some)
    "blockSome"

# `format_upscale_factor`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L266)

```elixir
@spec format_upscale_factor(upscale_factor()) :: String.t()
```

Converts upscale factor to API format.

## Examples

    iex> format_upscale_factor(:x2)
    "x2"

# `parse_generated_image`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L342)

```elixir
@spec parse_generated_image(map()) :: Gemini.Types.Generation.Image.GeneratedImage.t()
```

Parses a generated image from API response.

# `parse_safety_filter_level`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.11.0/lib/gemini/types/generation/image.ex#L208)

```elixir
@spec parse_safety_filter_level(String.t() | atom()) :: safety_filter_level()
```

Converts API-style safety filter level string to atom.

## Examples

    iex> parse_safety_filter_level("BLOCK_SOME")
    :block_some

    iex> parse_safety_filter_level(:block_most)
    :block_most

---

*Consult [api-reference.md](api-reference.md) for complete listing*
