Skip to content

image: add shared data URL preparation utilities - #27245

Merged
fjord-oai merged 1 commit into
mainfrom
fjord/responses_strict_mode_v2---4ixxjzu7eaeb3j
Jun 10, 2026
Merged

image: add shared data URL preparation utilities#27245
fjord-oai merged 1 commit into
mainfrom
fjord/responses_strict_mode_v2---4ixxjzu7eaeb3j

Conversation

@fjord-oai

@fjord-oai fjord-oai commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Add shared image-processing primitives needed for centralized image preparation in a follow-up PR.

  • Add load_data_url_for_prompt for decoding and preparing base64 image data URLs.
  • Add configurable maximum-dimension and 32px patch-budget resizing.
  • Enforce a 1 GiB sanity limit on both encoded and decoded data-URL representations.
  • Preserve original PNG, JPEG, and WebP bytes when resizing is unnecessary.
  • Preserve the existing GIF-to-PNG behavior.
  • Move image utility tests into the existing sidecar test module.

Behavior

This PR is intended to be runtime behavior-preserving.

Existing production callers continue using PromptImageMode::ResizeToFit and PromptImageMode::Original with their existing semantics. The new data-URL entrypoint and configurable resize mode have no production callers in this PR; they are used by the next PR in the stack.

This PR does not change user-input handling, view_image, history insertion, request construction, HTTP image URL forwarding, or app-server behavior.

git stack

git-stack-id: fjord/responses_strict_mode_v2---4ixxjzu7eaeb3j
git-stack-title: image: add shared data URL preparation utilities
@fjord-oai
fjord-oai force-pushed the fjord/responses_strict_mode_v2---4ixxjzu7eaeb3j branch from f649806 to 424af29 Compare June 9, 2026 22:03
@fjord-oai
fjord-oai marked this pull request as ready for review June 10, 2026 04:13
///
/// This is a high sanity guard against pathological inputs, not a protocol
/// requirement or target upload size.
pub const MAX_PROMPT_IMAGE_INPUT_BYTES: usize = 1024 * 1024 * 1024;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flagging, responsesapi doesn't throw a direct 400 error for any size (and will just fail later during processing or context construction), but I'm aligned with this max limit, since it would almost certainly fail during processing at this size.

@fjord-oai
fjord-oai merged commit c722052 into main Jun 10, 2026
45 of 48 checks passed
@fjord-oai
fjord-oai deleted the fjord/responses_strict_mode_v2---4ixxjzu7eaeb3j branch June 10, 2026 22:27
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants