Skip to main content

Crate vips

Crate vips 

Source
Expand description

vips-rs: Lightweight safety encapsulation of libvips (initialization, concurrency, caching, versioning, and image IO).

§Safety model

  • Raw libvips pointers are private to each wrapper. Use safe methods, or as_ptr() when bridging to lower-level FFI (the pointer is valid only while the wrapper lives; do not unref it).
  • All unsafe blocks are concentrated in this crate with SAFETY: notes.
  • Global init is process-locked; RAII types unref on Drop.
use vips::{init, set_concurrency};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    init(Some("my-app"))?;
    vips::set_concurrency(4);
    vips::set_max_operations(1000);
    vips::set_max_mem_bytes(256 * 1024 * 1024);
    vips::set_max_files(100);
    Ok(())
}

Structs§

VipsImage
Safe RAII wrapper around a libvips VipsImage*.
VipsInstance
A singleton compatibility handle for process-wide libvips initialization. Dropping it leaves libvips available to live images and other threads.
VipsInterpolate
Safe RAII wrapper around a libvips VipsInterpolate*.
VipsInterpolateMethod
Function-pointer wrapper for a VipsInterpolate implementation.
VipsOwnedBuffer
An immutable libvips allocation. Reading it does not copy the pixel or encoded data into the Rust allocator. Drop releases it with g_free.
VipsRegion
Safe RAII wrapper around a libvips VipsRegion*.

Enums§

Error
VipsAccess
VipsAlign
VipsAngle
VipsAngle45
VipsArgumentFlags
VipsBandFormat
VipsBlendMode
VipsCoding
VipsCombine
VipsCombineMode
VipsCompassDirection
VipsDemandStyle
VipsDirection
VipsExtend
VipsForeignDzContainer
VipsForeignDzDepth
VipsForeignDzLayout
VipsForeignFlags
VipsForeignKeep
VipsForeignPdfPageBox
VipsForeignPngFilter
VipsForeignTiffCompression
VipsForeignTiffPredictor
VipsForeignTiffResunit
VipsForeignWebpPreset
VipsFormatFlags
VipsImageType
VipsIntent
VipsInteresting
VipsInterpretation
VipsKernel
VipsOperationBoolean
VipsOperationComplex
VipsOperationComplex2
VipsOperationComplexget
VipsOperationFlags
VipsOperationMath
VipsOperationMath2
VipsOperationMorphology
VipsOperationRelational
VipsOperationRound
VipsPCS
VipsPrecision
VipsSize
VipsToken

Traits§

VipsBuffer
Extension trait for thumbnailing encoded image bytes.

Functions§

black
Create a one-band 8-bit black image (vips_black).
code_to_result
Convert the return code (0=OK, non-0=ERR) convention in libvips to Result
concurrency
Get the current concurrency
find_load
Loader nickname libvips would use for path (e.g. "VipsForeignLoadJpegFile").
find_save
Saver nickname libvips would use for path (e.g. "VipsForeignSaveJpegFile").
gaussnoise
Create Gaussian noise (vips_gaussnoise).
grey
Create a grey ramp image (vips_grey).
init
Initialize libvips (idempotent, thread-safe). app_name is used for logging and diagnostics; defaults to "vips-rs" when None.
interpretation_bands
Number of colour bands used by an interpretation (libvips 8.18+).
is_initialized
Is it currently initialized?
max_files
Get the maximum number of files configured
max_mem_bytes
Get the maximum cache memory (bytes) configured
max_operations
Gets the maximum number of compute nodes configured
perlin
Create a Perlin noise image (vips_perlin).
set_concurrency
Set concurrency (<=0 will fall back to default)
set_max_files
Set the maximum number of files allowed to open at the same time
set_max_mem_bytes
Set the maximum memory allowed in bytes for the cache
set_max_operations
Sets the maximum number of compute nodes that can be retained in the cache
set_trace
Print the diagnostic information for each cache hit/build (1 on, 0 off)
sines
Create a sine-wave test image (vips_sines).
size_operations
Gets the number of compute nodes in the current cache
take_vips_error
Read and empty the error buffer of libvips
tracked_mem_bytes
Currently tracked memory (bytes)
tracked_mem_highwater_bytes
Historical Peak Memory Usage (bytes)
version
Returns the libvips version as a tuple: (major, minor, micro)
version_string
Returns the full version string, such as “8.14.2”
vips_call⚠
xyz
Create a two-band coordinate image (vips_xyz).
zone
Create a zone-plate test image (vips_zone).

Type Aliases§

Result
A specialized Result type for libvips operations
VipsRect