Description
Renders the result of a query as a PNG image. This is useful as a built-in visualization tool. The size of the output image is fixed by the settingsoutput_format_image_width and
output_format_image_height
(both default to 1024). Pixels that are not covered by the result are filled with black
(in RGB and grayscale modes) or with transparent black (in RGBA mode).
The color mode is determined automatically from the column names and types of the result:
Column names are matched case-insensitively. If the color mode cannot be unambiguously
determined (e.g. unknown column names, mixed
v with r/g/b/a, or one of r/g/b missing),
the query throws an exception.
For pixel channels, integer values are clamped to [0, 255] and floating-point values
are clamped to [0, 1] and then scaled to [0, 255].
The position of each record in the image is determined by one of two modes:
- Implicit (the default — when neither
xnoryis present). Each record corresponds to a single pixel; pixels are filled in scanline order: left to right, top to bottom. - Explicit (when
xandycolumns are present, both of integer types). Thexandycolumns give the pixel coordinates. Records with coordinates outside the image are silently ignored. In case of multiple records with the same coordinates, the last one wins (painter’s algorithm).
Example usage
Implicit coordinates (row-per-pixel), RGB
Explicit coordinates, grayscale
Displaying images in the terminal
By default, thePNG format writes the raw image bytes. The setting
output_format_image_terminal_mode
makes the format render the image directly to the terminal using an inline image protocol instead: