跳到主要内容
Vane Data / API 参考

IMAGE 访问器

image_width、image_height、image_channel、image_mode 和 image_attribute 读取 IMAGE 元数据,不解码像素、不打开文件。它们属于基础引擎,返回 UINTEGER,不受 image_backend 影响。

签名

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) 和 image_attribute(image, name)。五个函数都有 Expression 方法。

参数

函数返回
image_width(image)像素宽度
image_height(image)像素高度
image_channel(image)通道数
image_mode(image)数值模式编码(见下表)
image_attribute(image, name)由 name 指定的属性:height、width、channel 或 mode

image_mode 返回模式编码,编码顺序覆盖全部十种模式:

模式编码通道像素 dtype
L11UInt8
LA22UInt8
RGB33UInt8
RGBA44UInt8
L1651UInt16
LA1662UInt16
RGB1673UInt16
RGBA1684UInt16
RGB32F93Float32
RGBA32F104Float32

返回值与错误

每个访问器返回 UINTEGER;NULL 输入返回 NULL。image_attribute 遇到未知属性名会报错。

示例

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()

来源与相关页面