feat(ai): image generation builder with local-file & multi-image support #125

Closed
despiegk wants to merge 0 commits from development_ai_image_generation into development
Owner

Summary

  • Add ImageGenerationRequest builder for text-to-image AND image-conditioned generation (URLs, raw bytes, local paths).
  • New image_io module: MIME detection, format conversion (PNG/JPEG/WebP/GIF), byte-budget resizing.
  • Multi-image response parsing (Vec<GeneratedImage>).
  • Feature-gated behind default-on image-io; legacy generate_image* API unchanged.

Closes #124

Changes

  • crates/ai/Cargo.toml — optional image + base64 deps behind image-io feature.
  • crates/ai/src/error.rsAiError::ImageIo variant.
  • crates/ai/src/image_generation/image_io.rs (new) — loader, format conversion, byte-budget shrink.
  • crates/ai/src/image_generation/request.rs (new) — ImageGenerationRequest builder, ImageInput, GeneratedImage, ImageGenerationResult, multi-image parser.
  • crates/ai/src/client/mod.rsimage_request() entry point; pub(crate) accessors for the builder.
  • crates/ai/src/lib.rs — re-exports.
  • crates/ai/examples/image_generation_builder.rs (new) — runnable example.
  • crates/ai/examples/README.md — entry for the new example.

Test Results

  • cargo check -p herolib_ai: OK
  • cargo build -p herolib_ai --examples: OK
  • cargo test -p herolib_ai: 61 unit + 4 integration + 7 doc-tests, 0 failures.
## Summary - Add `ImageGenerationRequest` builder for text-to-image AND image-conditioned generation (URLs, raw bytes, local paths). - New `image_io` module: MIME detection, format conversion (PNG/JPEG/WebP/GIF), byte-budget resizing. - Multi-image response parsing (`Vec<GeneratedImage>`). - Feature-gated behind default-on `image-io`; legacy `generate_image*` API unchanged. ## Related Issue Closes https://forge.ourworld.tf/lhumina_code/hero_lib/issues/124 ## Changes - `crates/ai/Cargo.toml` — optional `image` + `base64` deps behind `image-io` feature. - `crates/ai/src/error.rs` — `AiError::ImageIo` variant. - `crates/ai/src/image_generation/image_io.rs` (new) — loader, format conversion, byte-budget shrink. - `crates/ai/src/image_generation/request.rs` (new) — `ImageGenerationRequest` builder, `ImageInput`, `GeneratedImage`, `ImageGenerationResult`, multi-image parser. - `crates/ai/src/client/mod.rs` — `image_request()` entry point; `pub(crate)` accessors for the builder. - `crates/ai/src/lib.rs` — re-exports. - `crates/ai/examples/image_generation_builder.rs` (new) — runnable example. - `crates/ai/examples/README.md` — entry for the new example. ## Test Results - `cargo check -p herolib_ai`: OK - `cargo build -p herolib_ai --examples`: OK - `cargo test -p herolib_ai`: 61 unit + 4 integration + 7 doc-tests, 0 failures.
feat(ai): image generation builder with local-file & multi-image support
Some checks failed
Lint / lint-linux (pull_request) Failing after 4s
Tests with Services / test-linux (pull_request) Failing after 39s
19ffd708fa
Add ImageGenerationRequest builder on top of the existing Gemini 3.1
Flash Image Preview integration. Supports text-to-image and
image-conditioned generation from URLs, raw bytes, or local files. The
image-io module loads images from disk, detects MIME, converts between
PNG/JPEG/WebP/GIF, and resizes to fit a max-bytes budget. Response
parsing now returns every image (not just the first). Feature-gated
(image-io) so consumers can opt out.

#124
despiegk closed this pull request 2026-04-17 07:38:17 +00:00
Some checks failed
Lint / lint-linux (pull_request) Failing after 4s
Tests with Services / test-linux (pull_request) Failing after 39s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_lib!125
No description provided.