Skip to main content
Vane Data / Reference

Image accessors

image_width, image_height, image_channel, image_mode, and image_attribute read IMAGE metadata without decoding pixels or opening files. They belong to the base engine, return UINTEGER, and are not affected by image_backend.

Signature

example.py
vane.image_width(image) -> Expression
vane.image_height(image) -> Expression
vane.image_channel(image) -> Expression
vane.image_mode(image) -> Expression
vane.image_attribute(image, name) -> Expression

SQL: image_width(image), image_height(image), image_channel(image), image_mode(image), and image_attribute(image, name). All five have Expression methods.

Parameters

FunctionReturns
image_width(image)Width in pixels
image_height(image)Height in pixels
image_channel(image)Channel count
image_mode(image)Numeric mode code (see below)
image_attribute(image, name)Property named by name: height, width, channel, or mode

image_mode returns the mode code, which follows the mode order and covers all ten modes:

ModeCodeChannelsPixel dtype
L11UInt8
LA22UInt8
RGB33UInt8
RGBA44UInt8
L1651UInt16
LA1662UInt16
RGB1673UInt16
RGBA1684UInt16
RGB32F93Float32
RGBA32F104Float32

Returns and errors

Each accessor returns UINTEGER; NULL inputs return NULL. image_attribute raises for an unknown property name.

Example

example.py
import vane


con = vane.connect()
con.sql("""
    SELECT image_width(image) AS width,
           image_height(image) AS height,
           image_channel(image) AS channels,
           image_mode(image) AS mode
    FROM (SELECT decode_image_file(image_file('photo.png')) AS image)
""").show()