Expand description
Image processing utilities — resize, convert, and transform images.
Mirrors packages/coding-agent/src/utils/image-*.ts. Provides cross-platform
image processing for the agent’s vision capabilities.
§Features
- Resize: Scale images while maintaining aspect ratio
- Convert: Convert between image formats (PNG, JPEG, WebP)
- EXIF handling: Strip EXIF data for privacy
- Optimization: Reduce file size for API transmission
§Example
use rpi_tools::image_processing::{process_image, ImageProcessingOptions, OutputFormat};
let options = ImageProcessingOptions {
max_width: Some(1024),
max_height: Some(1024),
format: Some(OutputFormat::Jpeg { quality: 85 }),
strip_exif: true,
};
let processed = process_image(input_bytes, options)?;Structs§
- Image
Processing Options - Options for image processing.
- Inline
Image Processor - Shared processor for the built-in read tool.
Enums§
- Output
Format - Output format for processed images.
Constants§
- INLINE_
IMAGE_ MAX_ BASE64_ BYTES - INLINE_
IMAGE_ MAX_ SIDE - Pi’s default inline limits: 2000 pixels per side and 4.5 MiB of base64.
Functions§
- detect_
image_ mime - Detect the MIME type of an image from its bytes.
- get_
image_ dimensions - Get image dimensions without fully decoding the image.
- normalize_
image_ blocks - Normalize image blocks while retaining order and surfacing omissions as text, rather than sending an invalid image to a provider.
- prepare_
inline_ image - Decode, orient, resize and encode an image for model input. Small supported images retain their original bytes; oversized images fall back to JPEG.
- process_
image - Process an image according to the given options.