| Crates.io | vips |
| lib.rs | vips |
| version | 0.1.0-alpha.5 |
| created_at | 2018-04-19 05:56:54.55247+00 |
| updated_at | 2025-11-02 07:28:14.160955+00 |
| description | Rust bindings for libvips: fast, low-memory image processing with a safe, ergonomic API. |
| homepage | |
| repository | https://github.com/houseme/vips-rs |
| max_upload_size | |
| id | 61348 |
| size | 351,677 |
Rust bindings for libvips: fast, low-memory image processing with a safe, ergonomic API.
Documentation: https://houseme.github.io/vips-rs/vips/
brew install vipsapt-get install -y pkg-config libvips libvips-dev (or your distro equivalent)Add to your Cargo.toml:
[dependencies]
vips = "*"
use vips::*;
fn main() -> Result<()> {
// Initialize libvips once per process. The boolean usually controls auto-shutdown.
let _instance = VipsInstance::new("app_example", true)?;
// Load an image from file
let img = VipsImage::from_file("./examples/images/kodim01.png")?;
// Create a thumbnail with forced width and height
let thumb = img.thumbnail(320, 240, VipsSize::VIPS_SIZE_FORCE)?;
// Save the result
thumb.write_to_file("kodim01_320x240.jpg")?;
Ok(())
}
let pixels = vec![0u8; 256 * 256 * 3]; // RGB
let img = VipsImage::from_memory(pixels, 256, 256, 3, VipsBandFormat::VIPS_FORMAT_UCHAR) ?;
let thumb = img.thumbnail(200, 200, VipsSize::VIPS_SIZE_FORCE) ?;
thumb.write_to_file("black_200x200.png") ?;
let pixels = vec![0u8; 256 * 256 * 3];
let img = VipsImage::from_memory_reference(&pixels, 256, 256, 3, VipsBandFormat::VIPS_FORMAT_UCHAR) ?; // The returned image lifetime is tied to `pixels`
let thumb = img.thumbnail(200, 200, VipsSize::VIPS_SIZE_FORCE) ?;
thumb.write_to_file("black_ref_200x200.png") ?;
from_file, from_memory) when possible.from_memory_reference) tie the image lifetime to the borrowed slice. Do not let the slice
drop before all derived images are fully used.merge, mosaic, match_, globalbalanceThe API surface is evolving; see the docs for details and more examples.
vips_init/vips_shutdown via VipsInstance and standard library primitives (
OnceLock).self.vips-sys or use vips::call(...)
to invoke libvips operations directly.See CHANGELOG.md.