Media

vimage

Edits RGBA pixel buffers in memory. It reads and writes no image files.

Released v1.0.0 · 2026-09-28
Import
use "stdlib/image.ven"

Pixels, filters and transforms on RGBA buffers held in memory, all addressable in plain Venutian.

vimage.ven
print clamp_byte(300)
:: 255
Reference (16 functions)

API reference

clamp_byte(v)

clamp_byte(300)
:: gives: 255

pixel_offset(img, x, y)

Computes the flat pixels List index where pixel (x, y) begins.

img = image_create(4, 4)
pixel_offset(img, 2, 1)
:: gives: 12

check_bounds(img, x, y, who)

Raises when (x, y) falls outside imgs width/height.

img = image_create(3, 2)
attempt
    check_bounds(img, 5, 5, "example")
rescue e
    print(e)
:: prints: example: (5, 5) is out of bounds for a 3x2 image.

image_create(width, height)

Allocates a new opaque black width x height Image.

img = image_create(2, 2)
print(image_get_pixel(img, 0, 0))
:: prints: (0, 0, 0, 255)

image_get_pixel(img, x, y)

img = image_create(2, 2)
image_get_pixel(img, 0, 0)
:: gives: (0, 0, 0, 255)

image_set_pixel(img, x, y, color)

Writes color into (x, y), in place.

img = image_create(1, 1)
image_set_pixel(img, 0, 0, (9, 8, 7, 6))
print(image_get_pixel(img, 0, 0))
:: prints: (9, 8, 7, 6)

image_fill(img, color)

Overwrites every pixel in img with color, in place.

img = image_create(2, 2)
image_fill(img, (11, 22, 33, 255))
print(image_get_pixel(img, 1, 1))
:: prints: (11, 22, 33, 255)

image_resize(img, new_width, new_height)

Resizes img to new_width x new_height by nearest-neighbor sampling.

img = image_create(2, 2)
image_set_pixel(img, 1, 1, (4, 4, 4, 255))
resized = image_resize(img, 4, 4)
print(image_get_pixel(resized, 3, 3))
:: prints: (4, 4, 4, 255)

image_crop(img, x, y, width, height)

Extracts the width x height rectangle starting at (x, y).

img = image_create(3, 2)
image_set_pixel(img, 1, 0, (11, 0, 0, 255))
cropped = image_crop(img, 1, 0, 2, 2)
print(image_get_pixel(cropped, 0, 0))
:: prints: (11, 0, 0, 255)

image_rotate_90(img)

img = image_create(2, 1)
image_set_pixel(img, 1, 0, (20, 20, 20, 255))
rotated = image_rotate_90(img)
print(image_get_pixel(rotated, 0, 1))
:: prints: (20, 20, 20, 255)

image_flip_horizontal(img)

Mirrors img left-to-right.

img = image_create(2, 1)
image_set_pixel(img, 0, 0, (1, 1, 1, 255))
flipped = image_flip_horizontal(img)
print(image_get_pixel(flipped, 1, 0))
:: prints: (1, 1, 1, 255)

image_flip_vertical(img)

Mirrors img top-to-bottom.

img = image_create(1, 2)
image_set_pixel(img, 0, 0, (1, 1, 1, 255))
flipped = image_flip_vertical(img)
print(image_get_pixel(flipped, 0, 1))
:: prints: (1, 1, 1, 255)

image_to_grayscale(img)

Converts img to grayscale using the standard luma weights.

img = image_create(1, 1)
image_set_pixel(img, 0, 0, (100, 150, 200, 255))
gray = image_to_grayscale(img)
print(image_get_pixel(gray, 0, 0))
:: prints: (141, 141, 141, 255)

image_apply_convolution(img, kernel)

img = image_create(1, 1)
image_set_pixel(img, 0, 0, (10, 20, 30, 255))
result = image_apply_convolution(img, [[1]])
print(image_get_pixel(result, 0, 0))
:: prints: (10, 20, 30, 255)

channel_index(channel)

Maps a channel name to its index in a pixel Tuple.

channel_index("blue")
:: gives: 2

image_histogram(img, channel)

Counts how many pixels in img hold each possible value of channel.

img = image_create(2, 1)
image_set_pixel(img, 0, 0, (5, 0, 0, 255))
image_set_pixel(img, 1, 0, (5, 0, 0, 255))
hist = image_histogram(img, "red")
print(hist[5])
:: prints: 2

Get notified when vimage changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.