Gemini.Types.Generation.Image (GeminiEx v0.8.4)
View SourceType 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 modelimagen-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.
Summary
Types
Aspect ratio for generated images.
Edit mode for image editing operations.
Person generation policy.
Safety filter levels for generated images.
Upscale factor for image enhancement.
Functions
Builds parameters map for image editing API request.
Builds parameters map for image generation API request.
Builds parameters map for image upscaling API request.
Converts edit mode to API format.
Converts person generation policy to API format.
Converts safety filter level atom to API format.
Converts upscale factor to API format.
Parses a generated image from API response.
Converts API-style safety filter level string to atom.
Types
@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)
@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
@type person_generation() :: :allow_adult | :allow_all | :dont_allow
Person generation policy.
:allow_adult- Allow generation of adult humans:allow_all- Allow generation of humans of all ages:dont_allow- Do not generate recognizable people
@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
@type t() :: Gemini.Types.Generation.Image.ImageGenerationConfig.t()
@type upscale_factor() :: :x2 | :x4
Upscale factor for image enhancement.
:x2- 2x upscale (e.g., 1024x1024 -> 2048x2048):x4- 4x upscale (e.g., 1024x1024 -> 4096x4096)
Functions
@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.
@spec build_generation_params( String.t(), Gemini.Types.Generation.Image.ImageGenerationConfig.t() ) :: map()
Builds parameters map for image generation API request.
@spec build_upscale_params( String.t(), Gemini.Types.Generation.Image.UpscaleImageConfig.t() ) :: map()
Builds parameters map for image upscaling API request.
Converts edit mode to API format.
Examples
iex> format_edit_mode(:inpainting)
"inpainting"
@spec format_person_generation(person_generation()) :: String.t()
Converts person generation policy to API format.
Examples
iex> format_person_generation(:allow_adult)
"allowAdult"
@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"
@spec format_upscale_factor(upscale_factor()) :: String.t()
Converts upscale factor to API format.
Examples
iex> format_upscale_factor(:x2)
"x2"
@spec parse_generated_image(map()) :: Gemini.Types.Generation.Image.GeneratedImage.t()
Parses a generated image from API response.
@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