Files
luma/Sources/LumaCore/ImageProcessor.swift
Ole André Vadla Ravnås 8d6f91fe1e Plumb image attachments through to the LLM
Console widgets get an appendImage / respond.image API on the
agent. read_widget_state surfaces image entries as attachments
scaled to at most max_dimension pixels (default 1568) on the
longest edge. Anthropic nests image blocks inside tool_result;
OpenAI gets a synthetic follow-up user message. The host scales
via CoreImage on macOS and GdkPixbuf on GTK.
2026-05-22 12:15:53 +02:00

24 lines
765 B
Swift

import Foundation
public struct ProcessedImage: Sendable, Equatable {
public var mediaType: String
public var data: Data
public var width: Int
public var height: Int
public init(mediaType: String, data: Data, width: Int, height: Int) {
self.mediaType = mediaType
self.data = data
self.width = width
self.height = height
}
}
public protocol ImageProcessor: Sendable {
/// Decode `data` (PNG, JPEG, etc.) and return a re-encoded PNG whose
/// longest edge is at most `maxDimension`. If the image already fits,
/// the original may be returned unchanged. Returns nil if the input
/// cannot be decoded.
func scaleDown(data: Data, mediaType: String, maxDimension: Int) -> ProcessedImage?
}