| Crates.io | ezk-image |
| lib.rs | ezk-image |
| version | 0.3.0 |
| created_at | 2024-05-14 19:21:51.450569+00 |
| updated_at | 2025-09-14 22:04:28.330667+00 |
| description | Convert pixel and color formats such and RGB, YUV (YCbCr), ICtCp |
| homepage | |
| repository | https://github.com/kbalt/ezk-image |
| max_upload_size | |
| id | 1239993 |
| size | 254,525 |
ezk-image is a crate to perform conversion between common pixel formats and color spaces.
It uses SIMD and multi threading to accelerate the conversion when available, though multi-threading must
be explicitly called with [convert_multi_thread].
Any format can be converted to any other format.
Bit depth of up to 16 bit per component is supported.
use ezk_image::*;
let (width, height) = (1920, 1080);
// Our source image, an RGB buffer
let rgb_image = vec![0u8; PixelFormat::RGB.buffer_size(width, height)];
// Create the image we're converting from
let source = Image::from_buffer(
PixelFormat::RGB,
&rgb_image[..], // RGB only has one plane
None, // No need to define strides if there's no padding between rows
width,
height,
ColorInfo::RGB(RgbColorInfo {
transfer: ColorTransfer::Linear,
primaries: ColorPrimaries::BT709,
}),
).unwrap();
// Create the image buffer we're converting to
let mut destination = Image::blank(
PixelFormat::NV12, // We're converting to NV12
width,
height,
ColorInfo::YUV(YuvColorInfo {
space: ColorSpace::BT709,
transfer: ColorTransfer::Linear,
primaries: ColorPrimaries::BT709,
full_range: false,
}),
);
// Now convert the image data
convert_multi_thread(
&source,
&mut destination,
).unwrap();