How to handle high-resolution images with LLaVA
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
Check current image dimensions. Inspects pixel size before deciding on the approach.
identify /path/to/highres.jpgRequires ImageMagick. Alternatively, use
python3 -c "from PIL import Image; print(Image.open('/path/to/highres.jpg').size)".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.jpgResizing preserves most visual information while reducing memory footprint significantly.
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 4096A larger context window prevents truncation of the image encoding tokens.
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_ctxtoo 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.
convertcommand 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.