Image functions
Image functions decode, inspect, transform, and encode IMAGEFILE and IMAGE values. The connection's image_backend (python by default, native with the loaded native_media extension) selects the Pillow/tifffile/imagecodecs path or the C++ path; EXPLAIN shows native_* names for native plans. Every function and accessor in the table has a Python form, an Expression method form, and a SQL form. Python returns a lazy vane.Expression; name it with .alias(...).
Choose an API
| Function | Python | SQL | Native implementation | Returns |
|---|---|---|---|---|
| image_file_metadata | ✓ | ✓ | native_image_file_metadata | Metadata STRUCT |
| decode_image_file | ✓ | ✓ | native_decode_image_file | IMAGE |
| decode_image | ✓ | ✓ | native_decode_image | IMAGE |
| crop | ✓ | ✓ | native_crop | IMAGE |
| resize | ✓ | ✓ | native_resize | IMAGE |
| convert_image | ✓ | ✓ | native_convert_image | IMAGE |
| encode_image | ✓ | ✓ | native_encode_image | BLOB |
| image_hash | ✓ | ✓ | native_image_hash | FIXEDBINARY(n) |
| image_to_tensor | ✓ | ✓ | — | TENSOR |
| Image accessors | ✓ | ✓ | — | UINTEGER |
image_file is the IMAGEFILE constructor. image_to_tensor and the accessors have no backend-specific implementation.
Python ImageFile values
vane.ImageFile exposes bound methods that always use the Python implementation:
| Method | Returns |
|---|---|
| ImageFile.metadata(*, max_bytes=1048576, max_pixels=100000000) | ImageMetadata |
| ImageFile.decode(mode=None, buffer_size=1048576, *, max_input_bytes=268435456, max_pixels=100000000, max_decoded_bytes=536870912) | Decoded image (PIL Image) |
metadata inspects headers without decoding; decode follows the same mode and limit rules as decode_image_file and raises on failure.
Backends
Both backends follow the same mode, format, and resource-limit rules.
- python (default): Pillow/tifffile/imagecodecs. Install vane-ai[image].
- native: the loaded native_media extension. Set image_backend = 'native' before binding the query. An unavailable extension fails during binding; there is no automatic fallback.
import vane con = vane.connect() vane.load_installed_extension("native_media", connection=con) con.execute("SET image_backend = 'native'")
Returns and errors
NULL inputs produce NULL. Invalid coordinates, modes, formats, resource-limit breaches, missing codec dependencies, and cancellation propagate as errors. Python ImageFile failures raise ImageFileError or its ImageFileFormatError / ImageFileLimitError subclasses. Each operator accepts at most 100 million pixels and 256 MiB of pixel data per input image.