Skip to main content

Module image_processing

Module image_processing 

Source
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§

ImageProcessingOptions
Options for image processing.
InlineImageProcessor
Shared processor for the built-in read tool.

Enums§

OutputFormat
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.