Quickstart
Use native file and image types to inspect dimensions, select images and create thumbnails. SQL and Python below process the same three files and return the same columns. This example uses the Local Runner and needs no Ray runtime, GPU or model credentials.
Complete the Installation guide, then install the image extra in the same activated virtual environment:
uv pip install 'vane-ai[image]'Prepare the Shared Images
Save as prepare_images.py and run python3 prepare_images.py once. Keep the examples below in the same working directory.
from pathlib import Path from PIL import Image folder = Path("quickstart-images") folder.mkdir(exist_ok=True) for name, size in [("large", (640, 480)), ("medium", (320, 240)), ("small", (64, 64))]: Image.new("RGB", size, "#546354").save(folder / f"{name}.png")
SQL Query
Save as quickstart.sql:
WITH images AS ( SELECT image_file(file) AS source FROM list_files('quickstart-images/*.png') ), metadata AS ( SELECT source, image_file_metadata(source) AS info FROM images ), thumbnails AS ( SELECT info.width AS source_width, info.height AS source_height, resize(decode_image_file(source, 'RGB'), 224, 224) AS thumbnail FROM metadata WHERE info.width >= 300 ) SELECT source_width, source_height, image_width(thumbnail) AS width, image_height(thumbnail) AS height FROM thumbnails ORDER BY source_width DESC;
Execute it with Vane using the Local Runner:
python3 -c 'import sys, vane; vane.configure(runner="local"); vane.connect().sql(sys.stdin.read()).show()' < quickstart.sqlPython Relation API
Alternatively, save as quickstart.py and run python3 quickstart.py. It reads the same files independently of the SQL example.
import vane vane.configure(runner="local") con = vane.connect() thumbnails = (vane.from_files("quickstart-images/*.png", connection=con) .select(vane.image_file(vane.col("file")).alias("source")) .select(vane.col("source"), vane.image_file_metadata(vane.col("source")).alias("info")) .filter("info.width >= 300") .project("info.width AS source_width, info.height AS source_height, source") .select(vane.col("source_width"), vane.col("source_height"), vane.resize(vane.decode_image_file(vane.col("source"), "RGB"), 224, 224).alias("thumbnail"))) thumbnails.select( vane.col("source_width"), vane.col("source_height"), vane.image_width(vane.col("thumbnail")).alias("width"), vane.image_height(vane.col("thumbnail")).alias("height"), ).order("source_width DESC").show()
Same Result
| source_width | source_height | width | height |
|---|---|---|---|
| 640 | 480 | 224 | 224 |
| 320 | 240 | 224 | 224 |
The 64 × 64 image is filtered out before pixel decoding. Selected references are decoded into native IMAGE values and resized to 224 × 224. show() executes the query and displays the dimensions; it does not save thumbnail files.
What Just Happened
- list_files / from_files yields FILE references, converted to IMAGEFILE by image_file.
- image_file_metadata reads dimensions before full decoding; the query selects widths of at least 300 pixels.
- decode_image_file and resize operate on native image values in the same query.
- Both interfaces return the same four columns sorted by source width.
Move to Ray When Needed
Ray is Vane's default runner. Remove vane.configure(runner="local") before connecting to use it. With RAY_ADDRESS unset, Ray can start on the current machine. To use an existing cluster, launch from its head node:
RAY_ADDRESS=auto python quickstart.pyFirst replace the local image paths with sources available to all workers. Every worker needs the image dependencies and access to the input files. See Deployment for runtime configuration, shared data access and resource declarations.