For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
  • Getting Started
    • Welcome
    • Contributing
  • Concepts
    • Columns
    • Seed Datasets
    • Agent Rollout Ingestion
    • Custom Columns
    • Validators
    • Processors
    • Person Sampling
    • Traces
    • Architecture & Performance
    • Deployment Options
    • Security
  • Tutorials
    • Overview
    • The Basics
    • Structured Outputs, Jinja Expressions, and Conditional Generation
    • Seeding with an External Dataset
    • Providing Images as Context
    • Generating Images
    • Image-to-Image Editing
  • Recipes
    • Recipe Cards
  • Plugins
    • Overview
    • Example Plugin
    • FileSystemSeedReader Plugins
    • Discover
  • Code Reference
    • Overview
      • Overview
      • models
      • mcp
      • column_configs
      • config_builder
      • data_designer_config
      • run_config
      • sampler_params
      • validator_params
      • seeds
      • processors
      • analysis
      • Config API
        • Analysis
        • Base
        • Column Configs
        • Column Types
        • Config Builder
        • Custom Column
        • Data Designer Config
        • Dataset Metadata
        • Default Model Settings
        • Errors
        • Exportable Config
        • Fingerprint
        • Interface
        • Mcp
        • Models
        • Preview Results
        • Processor Types
        • Processors
        • Run Config
        • Sampler Constraints
        • Sampler Params
        • Seed
        • Seed Source
        • Seed Source Dataframe
        • Seed Source Types
        • Testing
        • Utils
          • Code Lang
          • Constants
          • Errors
          • Image Helpers
          • Info
          • Io Helpers
          • Misc
          • Numerical Helpers
          • Trace Renderer
          • Trace Type
          • Type Helpers
          • Visualization
          • Warning Helpers
        • Validator Params
        • Version
  • Dev Notes
    • Overview
    • Push Datasets to Hugging Face Hub
    • Text-to-SQL for Nemotron Super
    • Async All the Way Down
    • Owning the Model Stack
    • Data Designer Got Skills
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogoNeMo Data Designer
On this page
  • Module Contents
  • Classes
  • Functions
  • Data
  • API
Code ReferenceConfigConfig APIUtils

data_designer.config.utils.image_helpers

||View as Markdown|
Previous

Errors

Next

Info

Helper utilities for working with images.

Module Contents

Classes

NameDescription
ImageFormatSupported image formats for image modality.

Functions

NameDescription
is_image_diffusion_modelReturn True if the model is a diffusion-based image generation model.
extract_base64_from_data_uriExtract base64 from data URI or return as-is.
decode_base64_imageDecode base64 string to image bytes.
detect_image_formatDetect image format from bytes.
is_image_pathCheck if a string is an image file path.
is_base64_imageCheck if a string is base64-encoded image data.
is_image_urlCheck if a string is an image URL.
load_image_path_to_base64Load an image from a file path and return as base64.
load_image_url_to_base64Download an image from a URL and return as base64.
aload_image_url_to_base64Download an image from a URL asynchronously and return as base64.
validate_imageValidate that an image file is readable and not corrupted.

Data

IMAGE_FORMAT_MAGIC_BYTES _PIL_FORMAT_TO_IMAGE_FORMAT _BASE64_PATTERN IMAGE_DIFFUSION_MODEL_PATTERNS SUPPORTED_IMAGE_EXTENSIONS

API

1class data_designer.config.utils.image_helpers.ImageFormat

Bases: data_designer.config.utils.type_helpers.StrEnum

Supported image formats for image modality.

Initialization:

Initialize self. See help(type(self)) for accurate signature.

1PNG = png
1JPG = jpg
1JPEG = jpeg
1GIF = gif
1WEBP = webp
1IMAGE_FORMAT_MAGIC_BYTES
_PIL_FORMAT_TO_IMAGE_FORMAT
dict[str, data_designer.config.utils.image_helpers.ImageFormat]
1_BASE64_PATTERN = compile(...)
1IMAGE_DIFFUSION_MODEL_PATTERNS = ('dall-e-', 'dalle', 'stable-diffusion', 'sd-', 'sd_', 'imagen', 'gpt-image-')
1SUPPORTED_IMAGE_EXTENSIONS
1data_designer.config.utils.image_helpers.is_image_diffusion_model(model_name: str) -> bool

Return True if the model is a diffusion-based image generation model.

Parameters:

model_name
str

Model name or identifier (e.g. from provider).

Returns:

bool

True if the model is detected as diffusion-based, False otherwise.

1data_designer.config.utils.image_helpers.extract_base64_from_data_uri(data: str) -> str

Extract base64 from data URI or return as-is.

Handles data URIs like “data:image/png;base64,iVBORw0…” and returns just the base64 portion.

Parameters:

data
str

Data URI (e.g., “data:image/png;base64,XXX”) or plain base64

Returns:

str

Base64 string without data URI prefix

Raises:

ValueError

If data URI format is invalid

1data_designer.config.utils.image_helpers.decode_base64_image(base64_data: str) -> bytes

Decode base64 string to image bytes.

Automatically handles data URIs by extracting the base64 portion first.

Parameters:

base64_data
str

Base64 string (with or without data URI prefix)

Returns:

bytes

Decoded image bytes

Raises:

ValueError

If base64 data is invalid

1data_designer.config.utils.image_helpers.detect_image_format(image_bytes: bytes) -> data_designer.config.utils.image_helpers.ImageFormat

Detect image format from bytes.

Uses magic bytes for fast detection, falls back to PIL for robust detection.

Parameters:

image_bytes
bytes

Image data as bytes

Returns:

data_designer.config.utils.image_helpers.ImageFormat

Detected ImageFormat

Raises:

ValueError

If the image format cannot be determined

1data_designer.config.utils.image_helpers.is_image_path(value: str) -> bool

Check if a string is an image file path.

Parameters:

value
str

String to check

Returns:

bool

True if the string looks like an image file path, False otherwise

1data_designer.config.utils.image_helpers.is_base64_image(value: str) -> bool

Check if a string is base64-encoded image data.

Parameters:

value
str

String to check

Returns:

bool

True if the string looks like base64-encoded image data, False otherwise

1data_designer.config.utils.image_helpers.is_image_url(value: str) -> bool

Check if a string is an image URL.

Parameters:

value
str

String to check

Returns:

bool

True if the string looks like an image URL, False otherwise

1data_designer.config.utils.image_helpers.load_image_path_to_base64(
2 image_path: str,
3 base_path: str | None = None
4) -> str | None

Load an image from a file path and return as base64.

Parameters:

image_path
str

Relative or absolute path to the image file.

base_path
str | NoneDefaults to None

Optional base path to resolve relative paths from.

Returns:

str | None

Base64-encoded image data or None if loading fails.

1data_designer.config.utils.image_helpers.load_image_url_to_base64(
2 url: str,
3 timeout: int = 60
4) -> str

Download an image from a URL and return as base64.

Parameters:

url
str

HTTP(S) URL pointing to an image.

timeout
intDefaults to 60

Request timeout in seconds.

Returns:

str

Base64-encoded image data.

Raises:

requests.HTTPError

If the download fails with a non-2xx status.

1data_designer.config.utils.image_helpers.aload_image_url_to_base64(
2 url: str,
3 timeout: int = 60
4) -> str

Download an image from a URL asynchronously and return as base64.

Parameters:

url
str

HTTP(S) URL pointing to an image.

timeout
intDefaults to 60

Request timeout in seconds.

Returns:

str

Base64-encoded image data.

Raises:

httpx.HTTPStatusError

If the download fails with a non-2xx status.

1data_designer.config.utils.image_helpers.validate_image(image_path: pathlib.Path) -> None

Validate that an image file is readable and not corrupted.

Parameters:

image_path
pathlib.Path

Path to image file

Raises:

ValueError

If image is corrupted or unreadable