feat(ai): ImageRef abstraction for image_request() builder #128
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_lib#128
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The
image_request()builder accepts raw bytes only. Callers that have image URLs or local file paths must do their own fetching, MIME detection, and resizing before calling the builder. Centralising this inherolib_aikeeps callers — specificallyhero_slides_lib— free ofreqwestandimagedeps. See ADR-0001 for the representation decision.Goals
ImageRefenum (Url(String),Path(PathBuf),Bytes { mime: String, data: Vec<u8> }) to theherolib_aipublic APIImageGenerationRequest::add_image_ref(ImageRef)that resolves the ref synchronously (URL fetch via blocking HTTP, path read viafs::read) before attaching to the requestimage_iobyte-budget resizer and MIME detector for resolved inputsFeasibility
Low-to-medium complexity. The
image_iomodule already handles MIME detection, format conversion, and byte-budget resizing — this issue adds a resolution layer on top. URL fetching needs a sync HTTP client;ureqis the natural fit (small, no tokio dep). Path resolution is trivial.The more significant part is downstream: once
add_image_ref(ImageRef::Path)is available,discovery::image_file_to_png_base64()in hero_slides becomes dead code — it duplicates exactly whatimage_iodoes (resize + PNG-encode). That function and its base64 output should be removed as part of the hero_slides adoption work (see hero_slides S1 issue). This issue should include clear documentation on whatimage_ioexposes so hero_slides can delete the duplicate without ambiguity.