HOW-TO · INF

How to handle high-resolution images with LLaVA

intermediate15 minBy Eruo Fredoline
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

LLaVA installed in Ollama, high-resolution test images, image processing tools (ImageMagick or Python PIL) optionally available

What this does

Provides strategies for processing images that exceed LLaVA default resolution handling, including resizing, tiling, and context window adjustment. After this guide high-resolution images will be analyzable without memory errors.

Steps

  1. Check current image dimensions. Inspects pixel size before deciding on the approach.

    identify /path/to/highres.jpg
    

    Requires ImageMagick. Alternatively, use python3 -c "from PIL import Image; print(Image.open('/path/to/highres.jpg').size)".

  2. Resize large images to a manageable dimension. LLaVA typically processes well at 1024px on the longest edge.

    convert /path/to/highres.jpg -resize 1024x1024 /tmp/resized.jpg
    

    Resizing preserves most visual information while reducing memory footprint significantly.

  3. Increase context window for larger images. Allocates additional tokens for image encoding.

    ollama run llava "Describe this image in detail." /tmp/resized.jpg --num-ctx 4096
    

    A larger context window prevents truncation of the image encoding tokens.

  4. Use image tiling for extremely large images. Splits into quadrants and processes each separately.

    convert /path/to/highres.jpg -crop 2048x2048+0+0 /tmp/tile_1.jpg
    convert /path/to/highres.jpg -crop 2048x2048+2048+0 /tmp/tile_2.jpg
    

Verification

identify /tmp/resized.jpg && ollama run llava "List three details visible in this image." /tmp/resized.jpg --num-ctx 4096
# Expected: Dimensions smaller than original, followed by response referencing specific visual details

Common failures

  • num_ctx too small - Image encoding plus prompt exceeds context; increase to 4096 or higher.
  • resize artifacts - Aggressive downscaling loses details; test multiple resize dimensions (768, 1024, 1280).
  • tiling misalignment - Tiles may miss content at seams; use overlapping crops for critical analyses.
  • OOM on tile processing - Process tiles sequentially rather than all at once.
  • convert command not found - Install ImageMagick or use Python PIL instead.

Operator checkpoint

Before treating this as solved, write down the local runtime, model or package version, hardware/backend if relevant, and the verification output. This keeps the guide useful as a Will-It-Run style decision instead of a one-off command transcript.

Related guides

RELATED GUIDES