### Run Example with Cargo Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/README.md Demonstrates how to compile and run a Rust example using Cargo. This includes the compilation output and the command to execute the example. ```console $ cargo run --example png_to_jpeg Compiling libvips v2.0.2 (/libvips-rust-bindings) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.44s Running `target/debug/examples/png_to_jpeg` png_to_jpeg.jpg was created within the examples directory! ``` -------------------------------- ### Rewind VipsSource Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Resets the source's read position to the beginning. This is a convenient way to start reading from the start again. ```rust source.rewind()?; ``` -------------------------------- ### Handle Initialization Errors Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/errors.md Catch specific initialization errors when creating a VipsApp instance. This pattern is useful for handling failures during libvips setup. ```rust match VipsApp::new("MyApp", false) { Err(Error::InitializationError(msg)) => { eprintln!("Failed to initialize: {}", msg); } Ok(app) => { /* ... */ } } ``` -------------------------------- ### Project Navigation Structure Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/CONTENTS.md This tree outlines the organization of the documentation for the libvips Rust bindings, guiding users to relevant sections for different needs. ```markdown README.md (overview, quick start) ├── api-reference/ │ ├── vips-app.md (initialization and configuration) │ ├── vips-image.md (image handling) │ ├── vips-source-target.md (I/O and interpolation) │ └── operations.md (468+ operations) ├── types.md (all enums and type aliases) ├── errors.md (error catalog and handling) └── configuration.md (runtime configuration) ``` -------------------------------- ### Usage Example for Core Result Type Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/types.md Demonstrates how to use the custom Result type in a function that processes an image file. Ensure the libvips crate is imported. ```rust use libvips::{Result, VipsImage}; fn process_image(filename: &str) -> Result { VipsImage::new_from_file(filename) } ``` -------------------------------- ### Get libvips Version String Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Retrieves the libvips version string. This is useful for checking compatibility or reporting issues. ```rust let version = app.version_string()?; println!("libvips version: {}", version); ``` -------------------------------- ### Create VipsTarget for File Descriptor Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Use `new_to_descriptor` to create a VipsTarget that writes to an open file descriptor. For example, descriptor `1` typically refers to standard output (stdout). ```rust let target = VipsTarget::new_to_descriptor(1)?; ``` -------------------------------- ### Create a New Empty VipsImage Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `VipsImage::new()` to create a new, empty image representation in memory. This is a basic starting point before loading or generating image data. ```rust let image = VipsImage::new(); ``` -------------------------------- ### Color and Format Information Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Get details about the image's color bands, pixel format, and coding. ```APIDOC ## Color and Format Information ### `get_bands(&self) -> i32` Returns the number of color bands in the image. **Returns:** `i32` - Number of bands (1 for grayscale, 3 for RGB, 4 for RGBA, etc.). ### `get_format(&self) -> Result` Returns the pixel format of the image. **Returns:** `Result` - Pixel format (e.g., `BandFormat::Uchar`, `BandFormat::Float`). ### `get_coding(&self) -> Result` Returns the coding type of the image. **Returns:** `Result` - Coding type (e.g., `Coding::None`, `Coding::Labq`). ``` -------------------------------- ### Enum Type Conversion Example Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/types.md Demonstrates how to convert enum variants to and from i32 using `ToPrimitive` and `FromPrimitive` traits from the `num_traits` crate. This is useful for interacting with underlying C APIs or for serialization. ```rust use num_traits::{FromPrimitive, ToPrimitive}; let dir = Direction::Horizontal; let value = dir.to_i32(); // Some(0) let back = Direction::from_i32(0); // Some(Direction::Horizontal) ``` -------------------------------- ### Seek in VipsSource Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Seeks to a specific position within the source. Supports seeking from the start, current position, or end. ```rust source.seek(0, 0)?; ``` -------------------------------- ### Get Maximum Open Files Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Returns the current maximum number of files that libvips will keep open. ```rust app.cache_get_max_files(); ``` -------------------------------- ### Common Image Operations Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Shows examples of common image processing operations like resizing, rotating, blurring, color space conversion, and cropping. ```rust use libvips::ops; // Resize by scale factor let resized = ops::resize(&image, 0.5)?; // Rotate 90 degrees let rotated = ops::rot(&image, ops::Angle::D90)?; // Blur with Gaussian filter let blurred = ops::gaussblur(&image, 2.0)?; // Convert color space let lab = ops::colourspace(&image, ops::Interpretation::Lab)?; // Extract region let cropped = ops::extract_area(&image, 10, 10, 100, 100)?; ``` -------------------------------- ### Get VipsSource Length Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Retrieves the total length of the source in bytes. Useful for pre-allocating buffers or determining file size. ```rust let size = source.length()?; println!("Source size: {} bytes", size); ``` -------------------------------- ### Get Image Statistics Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/00_START_HERE.md Calculates the average, minimum, and maximum pixel values for a VipsImage. These operations are useful for image analysis. ```rust let avg = ops::avg(&image)?; let min = ops::min(&image)?; let max = ops::max(&image)?; ``` -------------------------------- ### Create Default VipsInterpolate Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Creates a new VipsInterpolate instance using the default nearest-neighbor method. This is the simplest way to get an interpolator. ```rust let interpolate = VipsInterpolate::new(); ``` -------------------------------- ### Create VipsSource from Options String Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Use this constructor to create a VipsSource with custom configuration specified via an options string. ```rust let source = VipsSource::new_from_options(option_str)?; ``` -------------------------------- ### Create VipsSource from File Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Use this constructor to create a VipsSource when reading from a file path. ```rust let source = VipsSource::new_from_file("image.jpg")?; ``` -------------------------------- ### Get Y Offset Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the vertical offset of the image in pixels. This is an integer value. ```rust let yoffset = image.get_yoffset(); ``` -------------------------------- ### Initialize VipsApp and Manage Resources in Rust Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Shows how to initialize the VipsApp and load an image. Resources are automatically freed when they go out of scope due to the Drop trait. ```rust { let app = VipsApp::new("MyApp", false)?; let image = VipsImage::new_from_file("photo.jpg")?; // All resources are freed when they go out of scope } ``` -------------------------------- ### Get X Offset Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the horizontal offset of the image in pixels. This is an integer value. ```rust let xoffset = image.get_xoffset(); ``` -------------------------------- ### Load and Resize Image Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/00_START_HERE.md Initializes the libvips application, loads an image from a file, resizes it by 50%, and saves it as a PNG. Ensure 'photo.jpg' exists and the output path is writable. ```rust let app = VipsApp::new("MyApp", false)?; let image = VipsImage::new_from_file("photo.jpg")?; let resized = ops::resize(&image, 0.5)?; // 50% size ops::pngsave(&resized, "output.png")?; ``` -------------------------------- ### Get Current Cache Size Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Returns the current number of operations that are stored in the cache. ```rust app.cache_get_size(); ``` -------------------------------- ### Write Image to Buffer Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `image_write_to_buffer` to get the image data as a byte vector, specifying the desired output format with a suffix (e.g., ".png"). This is useful for network transmission or further in-memory processing. ```rust let png_bytes = image.image_write_to_buffer(".png")?; std::fs::write("output.png", &png_bytes)?; ``` -------------------------------- ### Get Concurrency Threads Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Returns the current number of worker threads configured for libvips. ```rust let threads = app.concurrency_get(); println!("Using {} threads", threads); ``` -------------------------------- ### Create VipsSource from File Descriptor Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Use this constructor to create a VipsSource from an open file descriptor. The descriptor must be seekable. ```rust let source = VipsSource::new_from_descriptor(3)?; // fd 3 ``` -------------------------------- ### Get Y Resolution Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the vertical resolution of the image in pixels per millimeter. This is a floating-point value. ```rust let yres = image.get_yres(); ``` -------------------------------- ### Initialize VipsApp and Set Concurrency Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/README.md Demonstrates how to initialize the libvips library using VipsApp and set the number of threads for the libvips threadpool. The VipsApp must live as long as the library is in use. ```rust let app = VipsApp::new("Test Libvips", false).expect("Cannot initialize libvips"); app.concurrency_set(2); ``` -------------------------------- ### Get Maximum Cached Operations Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Retrieves the maximum number of operations that libvips is configured to cache. ```rust app.cache_get_max() ``` -------------------------------- ### Initialize libvips Application Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Initializes the libvips application and optionally configures threading. This must be done before using other libvips functionalities. ```rust use libvips::{VipsApp, VipsImage, ops}; fn main() -> libvips::Result<()> { // Initialize libvips (automatically cleaned up when app is dropped) let app = VipsApp::new("MyApp", false)?; // Configure threading (optional) app.concurrency_set(4); // ... use libvips ... Ok(()) } ``` -------------------------------- ### Create and Resize Image in Rust Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Demonstrates creating an image from a file and resizing it. The original image remains unmodified due to immutability. ```rust let image = VipsImage::new_from_file("photo.jpg")?; let resized = ops::resize(&image, 0.5)?; // Both `image` and `resized` exist; the original is unmodified ``` -------------------------------- ### Get Maximum Cache Memory Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Returns the current maximum memory limit for caching in bytes. ```rust app.cache_get_max_mem(); ``` -------------------------------- ### Get Maximum Cache Operations Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Returns the current maximum number of operations that libvips will cache. ```rust app.cache_get_max(); ``` -------------------------------- ### Configure for Web Server Thumbnail Generation Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Sets up libvips for a web server scenario, optimizing for thumbnail generation with a large memory cache and a high number of open files. ```rust let app = VipsApp::new("ThumbnailServer", false)?; app.concurrency_set(num_cpus::get()); app.cache_set_max_mem(1024 * 1024 * 1024); // 1 GB cache app.cache_set_max_files(256); ``` -------------------------------- ### Build libvips-builder Docker Image Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/README.md Builds the Docker image required for generating libvips bindings. Run this script before generating the bindings. ```console ./build.sh ``` -------------------------------- ### Get X Resolution Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the horizontal resolution of the image in pixels per millimeter. This is a floating-point value. ```rust let xres = image.get_xres(); ``` -------------------------------- ### VipsImage::new Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Creates a new empty VipsImage. This is a basic constructor for an uninitialized image. ```APIDOC ## VipsImage::new ### Description Creates a new empty `VipsImage`. ### Method Rust function call ### Signature `VipsImage::new() -> VipsImage` ### Returns - `VipsImage` - A new, empty image. ### Example ```rust let image = VipsImage::new(); ``` ``` -------------------------------- ### Create VipsTarget for File Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Use `new_to_file` to create a VipsTarget that writes to a specified file path. Ensure the file path is valid and writable. ```rust let target = VipsTarget::new_to_file("output.png")?; ``` -------------------------------- ### Get Image Height Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the height of the image in pixels. Use this to determine the vertical dimension of the image. ```rust let height = image.get_height(); ``` -------------------------------- ### Create VipsImage from Memory (With Copy) Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `new_from_memory_copy` to create an image from a byte slice, copying the data into a new buffer. This is safer if the original buffer's lifetime is uncertain. ```rust use libvips::ops::BandFormat; let pixels = vec![255; 256 * 256 * 3]; let image = VipsImage::new_from_memory_copy( &pixels, 256, 256, 3, BandFormat::Uchar ?); ``` -------------------------------- ### VipsApp::new Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Constructs a new VipsApp instance and initializes the libvips library. It takes an application name and a boolean to enable memory leak detection. ```APIDOC ## VipsApp::new ### Description Constructs a new `VipsApp` instance and initializes the libvips library. ### Parameters #### Path Parameters - **name** (`&str`) - Required - Name for the libvips instance, typically the application name - **detect_leak** (`bool`) - Required - If `true`, enables memory leak detection (useful for testing); if `false`, disables it ### Returns - `Result` - A new `VipsApp` instance on success, or `Error::InitializationError` if initialization fails. ### Request Example ```rust use libvips::VipsApp; let app = VipsApp::new("MyApp", false)?; // libvips is now initialized and ready for use // When `app` is dropped, libvips is automatically shut down ``` ``` -------------------------------- ### Initialize VipsApp with Default Settings Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Use VipsApp::default to initialize libvips with memory leak detection disabled. The libvips system is automatically shut down when the VipsApp instance is dropped. ```rust let app = VipsApp::default("MyApp")?; ``` -------------------------------- ### Get Image Scale Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the scale factor applied to the image. This is a floating-point value representing the scaling ratio. ```rust let scale = image.get_scale(); ``` -------------------------------- ### VipsApp::new Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Initializes the VipsApp with a specified name and enables or disables memory leak detection. ```APIDOC ## VipsApp::new ### Description Initializes the VipsApp with a specified name and enables or disables memory leak detection. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (`&str`) - Required - Application name used for libvips initialization. This name is used for logging and identification purposes within libvips. - **detect_leak** (`bool`) - Required - If `true`, enables memory leak detection which instruments all allocations and deallocations for debugging. This adds overhead and should only be enabled during testing. ### Request Example ```rust // Production configuration - no leak detection overhead let app = VipsApp::new("MyApplication", false)?; // Development configuration - enable leak detection let app_dev = VipsApp::new("MyApplicationDev", true)?; ``` ### Response #### Success Response - **VipsApp** - The initialized VipsApp instance. #### Response Example None explicitly provided, but returns `Result`. ``` -------------------------------- ### Get Image Width Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the width of the image in pixels. Use this when you need to know the horizontal dimension of the image. ```rust let width = image.get_width(); ``` -------------------------------- ### Get Disc Threshold Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Retrieves the disc threshold in bytes. Operations exceeding this size may be written to disk. ```rust let disc_threshold = app.get_disc_threshold(); ``` -------------------------------- ### Using Optional Parameters for Operations Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Illustrates how to use optional parameters for operations by providing `*Options` structs, such as custom quality for JPEG saving or specific kernels for resizing. ```rust use libvips::ops; // Save JPEG with custom quality let options = ops::JpegsaveOptions { q: 90, optimize_coding: true, strip: true, ..Default::default() }; ops::jpegsave_with_opts(&image, "output.jpg", &options)?; // Resize with interpolation options let options = ops::ResizeOptions { vscale: 0.5, kernel: ops::Kernel::Cubic, ..Default::default() }; ops::resize_with_opts(&image, 0.5, &options)?; ``` -------------------------------- ### VipsSource Constructors Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md These constructors allow you to create a VipsSource from different data origins like files, memory buffers, or file descriptors. ```APIDOC ## VipsSource::new_from_file ### Description Creates a `VipsSource` from a file path. ### Method `VipsSource::new_from_file(filename: &str) -> Result` ### Parameters #### Path Parameters - **filename** (`&str`) - Required - Path to the file ### Response #### Success Response - `Result` - New source, or `InitializationError`. ### Request Example ```rust let source = VipsSource::new_from_file("image.jpg")?; ``` ``` ```APIDOC ## VipsSource::new_from_descriptor ### Description Creates a `VipsSource` from a file descriptor. ### Method `VipsSource::new_from_descriptor(descriptor: i32) -> Result` ### Parameters #### Path Parameters - **descriptor** (`i32`) - Required - Open file descriptor (must be seekable) ### Response #### Success Response - `Result` - New source. ### Request Example ```rust let source = VipsSource::new_from_descriptor(3)?; ``` ``` ```APIDOC ## VipsSource::new_from_memory ### Description Creates a `VipsSource` from a byte buffer. ### Method `VipsSource::new_from_memory(buffer: &[u8]) -> Result` ### Parameters #### Path Parameters - **buffer** (`&[u8]`) - Required - Byte buffer to read from ### Response #### Success Response - `Result` - New source. ### Request Example ```rust let data = b"...image bytes..."; let source = VipsSource::new_from_memory(data)?; ``` ``` ```APIDOC ## VipsSource::new_from_options ### Description Creates a `VipsSource` from an option string. ### Method `VipsSource::new_from_options(option_str: &str) -> Result` ### Parameters #### Path Parameters - **option_str** (`&str`) - Required - Options string for source configuration ### Response #### Success Response - `Result` - New source. ### Request Example ```rust let source = VipsSource::new_from_options("option=value")?; ``` ``` -------------------------------- ### Create VipsSource from Memory Buffer Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Use this constructor to create a VipsSource from a byte buffer in memory. ```rust let data = b"...image bytes..."; let source = VipsSource::new_from_memory(data)?; ``` -------------------------------- ### Get Image Offset Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the offset value for the image. This is a floating-point value that might be used in conjunction with scaling or positioning. ```rust let offset = image.get_offset(); ``` -------------------------------- ### Get Page Height Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the page height for multi-page images like animated GIFs. Use this for frame-specific dimensions. ```rust let page_height = image.get_page_height(); ``` -------------------------------- ### Load Raw Binary Image Data from File Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `VipsImage::new_from_file_raw()` to load raw binary image data from a file without relying on format detection. You must specify the image dimensions, number of bands, and an optional offset. ```rust // Load 512x512 RGB image from offset 0 let image = VipsImage::new_from_file_raw("raw.bin", 512, 512, 3, 0)?; ``` -------------------------------- ### error_buffer Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Retrieves the current error message from the thread-local buffer. This is useful for getting detailed error information after an operation fails. ```APIDOC ## error_buffer ### Description Retrieves the current error message from the thread-local buffer. ### Method `&self.error_buffer()` ### Returns `Result<&str>` - Error message or `InitializationError`. ### Use Case After an operation fails, get detailed error information. ### Example ```rust match ops::resize(&image, 0.5) { Err(_) => { if let Ok(msg) = app.error_buffer() { eprintln!("Error details: {}", msg); } } Ok(result) => { /* ... */ } } ``` ``` -------------------------------- ### Generate libvips Rust Bindings Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/README.md Executes the process to generate the Rust bindings for libvips. This script should be run after the Docker image is built. ```console ./generate.sh ``` -------------------------------- ### Get Total Allocations Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Returns the total number of memory allocations made by libvips. This can be used for debugging or performance analysis. ```rust let total_allocs = app.tracked_get_allocs(); ``` -------------------------------- ### Configure Multi-Core Server (8 cores) Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Optimize for a server environment with multiple cores by utilizing all available cores and increasing cache settings for concurrent requests. ```rust let app = VipsApp::new("ImageServer", false)?; app.concurrency_set(8); // All cores app.cache_set_max_mem(1024 * 1024 * 1024); // 1 GB cache app.cache_set_max_files(256); // More open files for concurrent requests ``` -------------------------------- ### Set Maximum Cache Memory Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Sets the maximum amount of memory in bytes that libvips will use for caching. For example, 500 MB. ```rust app.cache_set_max_mem(1024 * 1024 * 500); // 500 MB ``` -------------------------------- ### Prepare Image for Writing Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md The `image_write_prepare` method is used to prepare an image for subsequent writing operations. It returns `Ok(())` on success. ```rust image.image_write_prepare()?; ``` -------------------------------- ### Get Image Metadata as String Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves a specific image metadata field as a string. This is useful for accessing information like EXIF data. ```APIDOC ## get_as_string ### Description Gets image metadata as a string. ### Method Signature `get_as_string(&self, name: &str) -> Result` ### Parameters #### Path Parameters - **name** (string) - Required - Metadata field name (e.g., "exif-data") ### Response #### Success Response - **Result** - Metadata value. ### Example ```rust let exif = image.get_as_string("exif-data")?; ``` ``` -------------------------------- ### Initialize VipsApp with Leak Detection Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Use VipsApp::new to initialize the libvips library. Set detect_leak to true for memory leak detection during testing. The libvips system is automatically shut down when the VipsApp instance is dropped. ```rust use libvips::VipsApp; let app = VipsApp::new("MyApp", false)?; // libvips is now initialized and ready for use // When `app` is dropped, libvips is automatically shut down ``` -------------------------------- ### Get Image Filename Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the filename from which the image was loaded. Returns a `Result` that can contain a string slice or a `Utf8Error` if the filename is not valid UTF-8. ```rust let filename = image.get_filename()?; ``` -------------------------------- ### Get Image Orientation Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the EXIF orientation tag, indicating how the image should be rotated for display. Values range from 1 (normal) to 8. ```rust let orientation = image.get_orientation(); ``` -------------------------------- ### Initialize VipsApp with Leak Detection Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Use this constructor for production environments where performance is critical and leak detection is not needed. For development, set `detect_leak` to `true` to enable memory leak detection, which adds overhead. ```rust let app = VipsApp::new("MyApplication", false)?; let app_dev = VipsApp::new("MyApplicationDev", true)?; ``` -------------------------------- ### Get Image Interpretation Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the interpretation of the image, which defines its color space or other meaning. This function returns a `Result` and requires error handling. ```rust let interp = image.get_interpretation()?; ``` -------------------------------- ### Get Current Memory Usage Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Retrieves the current amount of memory being tracked by libvips in bytes. Use this to monitor real-time memory consumption. ```rust let mem_usage = app.tracked_get_mem(); println!("Using {} bytes", mem_usage); ``` -------------------------------- ### text(text: &str, font: &str, size: i32, dpi: i32) -> Result Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/operations.md Renders the given text to an image using the specified font, size, and DPI. ```APIDOC ## text(text: &str, font: &str, size: i32, dpi: i32) -> Result ### Description Renders the given text to an image using the specified font, size, and DPI. ### Parameters #### Path Parameters - **text** (&str) - Required - The text string to render. - **font** (&str) - Required - The font to use for rendering. - **size** (i32) - Required - The font size. - **dpi** (i32) - Required - The resolution in dots per inch. ### Response #### Success Response - **VipsImage** - The generated image with rendered text. ``` -------------------------------- ### Create a Memory-Backed VipsImage Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `VipsImage::new_memory()` to create an image that is exclusively backed by memory, avoiding disk usage for its primary storage. This is useful for intermediate image processing steps. ```rust let image = VipsImage::new_memory()?; ``` -------------------------------- ### Generate Thumbnail from File Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/operations.md Creates a thumbnail by specifying the input file path and desired dimensions. Requires the input file to exist. ```rust let thumb = ops::thumbnail("image.jpg", 128, 128)?; ``` -------------------------------- ### Handle Operation Errors Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/errors.md Catch errors that occur during image processing operations. This example shows how to handle a generic OperationError, printing the associated message. ```rust match ops::resize(&image, 0.5) { Err(Error::OperationError(msg)) => { eprintln!("Operation failed: {}", msg); } Ok(result) => { /* use result */ } } ``` -------------------------------- ### VipsSource Methods Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md These methods provide functionality to interact with the VipsSource, including reading data, seeking, mapping, and managing memory. ```APIDOC ## VipsSource::map ### Description Maps the source to a byte slice if it is mappable. ### Method `map(&self) -> Result<&[u8]>` ### Response #### Success Response - `Result<&[u8]>` - Slice of data, or `OperationError`. ### Request Example ```rust let data = source.map()?; println!("Source size: {} bytes", data.len()); ``` ``` ```APIDOC ## VipsSource::read ### Description Reads a specified number of bytes from the source. ### Method `read(&mut self, length: u64) -> Result>` ### Parameters #### Path Parameters - **length** (`u64`) - Required - Number of bytes to read ### Response #### Success Response - `Result>` - Bytes read, or `OperationError`. ### Request Example ```rust let bytes = source.read(1024)?; ``` ``` ```APIDOC ## VipsSource::seek ### Description Seeks to a position in the source if it is seekable. ### Method `seek(&mut self, offset: i64, whence: i32) -> Result` ### Parameters #### Path Parameters - **offset** (`i64`) - Required - Offset to seek to - **whence** (`i32`) - Required - Seek mode: 0=start, 1=current, 2=end ### Response #### Success Response - `Result` - New position, or `OperationError`. ### Request Example ```rust source.seek(0, 0)?; ``` ``` ```APIDOC ## VipsSource::rewind ### Description Resets the source position to the beginning. ### Method `rewind(&mut self) -> Result<()>` ### Response #### Success Response - `Result<()>` - `Ok(())` or `OperationError`. ### Request Example ```rust source.rewind()?; ``` ``` ```APIDOC ## VipsSource::length ### Description Returns the total length of the source in bytes. ### Method `length(&self) -> Result` ### Response #### Success Response - `Result` - Length in bytes, or `OperationError`. ### Request Example ```rust let size = source.length()?; println!("Source size: {} bytes", size); ``` ``` ```APIDOC ## VipsSource::is_mappable ### Description Returns `true` if the source can be memory-mapped. ### Method `is_mappable(&self) -> bool` ### Response #### Success Response - `bool` - `true` if mappable. ### Request Example ```rust if source.is_mappable() { let data = source.map()?; } ``` ``` ```APIDOC ## VipsSource::minimise ### Description Minimizes memory usage by freeing cached data. ### Method `minimise(&mut self)` ### Request Example ```rust source.minimise(); ``` ``` ```APIDOC ## VipsSource::unminimise ### Description Restores minimized data. ### Method `unminimise(&mut self) -> Result<()>` ### Response #### Success Response - `Result<()>` - `Ok(())` or `OperationError`. ### Request Example ```rust source.unminimise()?; ``` ``` ```APIDOC ## VipsSource::decode ### Description Decodes the source data. ### Method `decode(&mut self) -> Result<()>` ### Response #### Success Response - `Result<()>` - `Ok(())` or `OperationError`. ### Request Example ```rust source.decode()?; ``` ``` -------------------------------- ### Get Number of Pages Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the total number of pages or frames within a multi-page image. Useful for iterating through frames of an animation or a multi-page document. ```rust let n_pages = image.get_n_pages(); ``` -------------------------------- ### Load VipsImage from File in Read-Write Mode Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `VipsImage::new_from_file_rw()` to load an image from a file and open it with read-write access. This allows for modifications to be saved back to the file. ```rust let image = VipsImage::new_from_file_rw("photo.jpg")?; ``` -------------------------------- ### Get Image Coding Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the coding type of the image, such as `Coding::None` or `Coding::Labq`. This function returns a `Result` and requires error handling. ```rust let coding = image.get_coding()?; ``` -------------------------------- ### Create VipsTarget for Memory Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Use `new_to_memory` to create a VipsTarget that writes data directly into memory. This is useful for in-memory image processing or when a file is not needed. ```rust let target = VipsTarget::new_to_memory()?; ``` -------------------------------- ### Get Image Format Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the pixel format of the image, such as `BandFormat::Uchar` or `BandFormat::Float`. This function returns a `Result` and requires error handling. ```rust let format = image.get_format()?; ``` -------------------------------- ### Create VipsImage from Memory (No Copy) Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `new_from_memory` to create an image directly from a byte slice without copying the data. Ensure the buffer remains valid for the image's lifetime. ```rust use libvips::ops::BandFormat; let pixels: Vec = vec![255; 256 * 256 * 3]; // RGB image let image = VipsImage::new_from_memory( &pixels, 256, 256, 3, BandFormat::Uchar )?; ``` -------------------------------- ### Load and Save Images Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Demonstrates loading images from files or buffers and saving them to files or buffers. Supports auto-detection of image formats. ```rust use libvips::VipsImage; // Load from file (auto-detects format) let image = VipsImage::new_from_file("input.jpg")?; // Load from buffer let bytes = std::fs::read("input.png")?; let image = VipsImage::new_from_buffer(&bytes, "")?; // Save to file image.image_write_to_file("output.png")?; // Save to buffer with format let png_bytes = image.image_write_to_buffer(".png")?; ``` -------------------------------- ### Get Error Buffer Message Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Retrieves the current error message from libvips's error buffer. Use this after an operation fails to diagnose the issue. ```rust match some_operation() { Err(_) => println!("Error: {}", app.error_buffer()?), Ok(_) => println!("Success"), } ``` -------------------------------- ### Load VipsImage from File Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `VipsImage::new_from_file()` to load an image from a specified file path. This method supports various image formats depending on the libvips compilation. ```rust let image = VipsImage::new_from_file("photo.jpg")?; ``` -------------------------------- ### Save Image as PNG with Options Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/operations.md Saves the given VipsImage to a PNG file with customizable options. Options include compression level, interlacing, and filter type. ```rust ops::pngsave_with_opts(&image, "output.png", &options)?; ``` -------------------------------- ### freeze_error_buffer and error_thaw Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Allows temporarily preventing new errors from overwriting existing ones in the error buffer. Use `freeze_error_buffer` to start protection and `error_thaw` to end it. ```APIDOC ## freeze_error_buffer and error_thaw ### Description Freezes and unfreezes the error buffer, temporarily preventing new errors from overwriting existing ones. ### Method `&self.freeze_error_buffer()` and `&self.error_thaw()` ### Use Case Temporarily prevent new errors from overwriting existing ones. ### Example ```rust app.freeze_error_buffer(); // Operations that might fail let result = some_operation(); // Error buffer is now protected let msg = app.error_buffer()?; app.error_thaw(); ``` ``` -------------------------------- ### Get Peak Memory Usage Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-app.md Retrieves the peak memory usage tracked by libvips since initialization in bytes. Useful for identifying maximum memory requirements. ```rust let peak_mem = app.tracked_get_mem_highwater(); println!("Peak memory: {} bytes", peak_mem); ``` -------------------------------- ### Configure for Memory-Constrained Environments Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/README.md Sets up libvips for environments with limited memory, restricting concurrency to a single thread and significantly reducing the maximum memory cache size. ```rust let app = VipsApp::new("LowMemory", false)?; app.concurrency_set(1); app.cache_set_max_mem(50 * 1024 * 1024); // 50 MB ``` -------------------------------- ### VipsImage::new_from_file Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Loads an image from a file on disk. Supports various image formats depending on libvips compilation. ```APIDOC ## VipsImage::new_from_file ### Description Loads an image from a file on disk. ### Method Rust function call ### Signature `VipsImage::new_from_file(filename: &str) -> Result` ### Parameters #### Path Parameters - **filename** (`&str`) - Required - Path to the image file ### Returns - `Result` - Loaded image, or `InitializationError` if the file cannot be read. ### Supported Formats JPEG, PNG, GIF, TIFF, WebP, HEIF, and others depending on libvips compilation. ### Example ```rust let image = VipsImage::new_from_file("photo.jpg")?; ``` ``` -------------------------------- ### Load VipsImage from Byte Buffer Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `VipsImage::new_from_buffer()` to load an image directly from a byte slice. An optional `option_str` can be provided for format hints or specific parsing options. ```rust let image_bytes = std::fs::read("photo.jpg")?; let image = VipsImage::new_from_buffer(&image_bytes, "")?; ``` -------------------------------- ### Get Image Metadata as String Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `get_as_string` to retrieve specific metadata fields from an image. Ensure the metadata field name is provided correctly. This method returns a `Result`. ```rust let exif = image.get_as_string("exif-data")?; ``` -------------------------------- ### Configure Memory-Constrained Environment Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Adjust settings for environments with limited memory by reducing concurrency and cache sizes. ```rust let app = VipsApp::new("LowMemory", false)?; app.concurrency_set(2); // Limited parallelization app.cache_set_max_mem(50 * 1024 * 1024); // 50 MB cache app.cache_set_max(32); // Fewer cached operations ``` -------------------------------- ### Get Image Bands Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Retrieves the number of color bands in the image. This is useful for identifying image types like grayscale (1 band), RGB (3 bands), or RGBA (4 bands). ```rust let bands = image.get_bands(); if bands == 3 { println!("RGB image"); } ``` -------------------------------- ### Basic Error Handling with Match Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/errors.md Demonstrates basic error handling by matching on the Result of an image operation. ```rust match image_operation() { Ok(result) => println!("Success: {:?}", result), Err(e) => eprintln!("Operation failed: {}", e), } ``` -------------------------------- ### black(width: i32, height: i32, bands: i32) -> Result Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/operations.md Creates a black image with the specified width, height, and number of bands. ```APIDOC ## black(width: i32, height: i32, bands: i32) -> Result ### Description Creates a black image with the specified width, height, and number of bands. ### Parameters #### Path Parameters - **width** (i32) - Required - The width of the image. - **height** (i32) - Required - The height of the image. - **bands** (i32) - Required - The number of bands (e.g., color channels) for the image. ### Request Example ```rust let black = ops::black(512, 512, 3)?; ``` ### Response #### Success Response - **VipsImage** - The generated black image. ``` -------------------------------- ### Create Image from Existing Image and Array Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `new_from_image` to create a new image using the dimensions and metadata of a template image, populated with pixel values from a provided `f64` array. ```rust let image = VipsImage::new_from_file("photo.jpg")?; let new_image = VipsImage::new_from_image(&image, &data)?; ``` -------------------------------- ### Construct Default Options Struct Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/README.md Shows how to construct an options struct for an operation, initializing it with default values and then overriding specific fields. This is useful for operations with many optional parameters. ```rust let options = ops::Composite2Options { x: 10, y: 10, .. Composite2Options::default() } ``` -------------------------------- ### image_write_prepare Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Prepares the image for writing operations. This is a preparatory step before actual writing. ```APIDOC ## image_write_prepare ### Description Prepares the image for writing. ### Method `image_write_prepare` ### Response #### Success Response - `Result<()>` ### Source `src/image.rs:466` ``` -------------------------------- ### Configure Development with Debugging Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/configuration.md Enable debugging features like leak detection and cache operation tracing for development purposes. ```rust let app = VipsApp::new("Development", true)?; app.progress_set(true); app.vips_cache_set_trace(true); // Trace cache operations ``` -------------------------------- ### VipsTarget::new_to_memory Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Creates a VipsTarget for writing image data directly to memory. ```APIDOC ## VipsTarget::new_to_memory ### Description Creates a `VipsTarget` for writing to memory. ### Method Rust constructor ### Response #### Success Response - **VipsTarget** - New target instance ### Request Example ```rust let target = VipsTarget::new_to_memory()?; ``` ``` -------------------------------- ### add Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/operations.md Adds two images pixel-wise. This operation takes two VipsImage references as input and returns a Result containing a VipsImage. ```APIDOC ## add ### Description Adds two images pixel-wise. ### Method Rust Function ### Signature `add(left: &VipsImage, right: &VipsImage) -> Result` ### Parameters - **left** (`&VipsImage`) - Required - The left operand image. - **right** (`&VipsImage`) - Required - The right operand image. ### Response - **Success Response** (`Result`) - The resulting image after addition. ### Request Example ```rust let result = ops::add(&image1, &image2)?; ``` ``` -------------------------------- ### Load Image from File Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/README.md Loads an image from the specified file path. This function returns a VipsImage object. ```rust let image = VipsImage::new_from_file("test.png").unwrap(); ``` -------------------------------- ### Create Matrix Image from Array Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `image_new_matrix_from_array` to initialize a matrix image with values from a provided `f64` slice. The array length must match the specified width times height. ```rust let data = vec![1.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1.0]; // 3x3 sobel let kernel = VipsImage::image_new_matrix_from_array(3, 3, &data)?; ``` -------------------------------- ### Load VipsImage with Specific Access and Memory Mode Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Use `VipsImage::new_from_file_access()` to load an image from a file with fine-grained control over access patterns (Random, Sequential, SequentialUnbuffered) and memory management (in-memory vs. disk caching). ```rust use libvips::ops::Access; let image = VipsImage::new_from_file_access("photo.jpg", Access::Sequential, true)?; ``` -------------------------------- ### Save Image as WebP Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/operations.md Saves the given VipsImage to a WebP file. Ensure the filename has a .webp extension. ```rust ops::webpsave(&image, "output.webp")?; ``` -------------------------------- ### Catch Any Initialization Error Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/errors.md A general pattern to catch any InitializationError, regardless of the specific message. Useful when only the fact of an initialization failure needs to be handled. ```rust match result { Err(Error::InitializationError(_)) => { /* handle */ } _ => {} } ``` -------------------------------- ### VipsImage::new_from_file_rw Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Loads an image from a file and opens it in read-write mode, allowing modifications to be saved back to the file. ```APIDOC ## VipsImage::new_from_file_rw ### Description Loads an image from a file and opens it in read-write mode. ### Method Rust function call ### Signature `VipsImage::new_from_file_rw(filename: &str) -> Result` ### Parameters #### Path Parameters - **filename** (`&str`) - Required - Path to the image file ### Returns - `Result` - Loaded image with read-write access. ### Example ```rust let image = VipsImage::new_from_file_rw("photo.jpg")?; ``` ``` -------------------------------- ### VipsImage::new_from_file_raw Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-image.md Loads raw binary image data from a file without format detection, requiring explicit image dimensions and band information. ```APIDOC ## VipsImage::new_from_file_raw ### Description Loads raw binary image data from a file without format detection. ### Method Rust function call ### Signature `VipsImage::new_from_file_raw(filename: &str, x_size: i32, y_size: i32, bands: i32, offset: u64) -> Result` ### Parameters #### Path Parameters - **filename** (`&str`) - Required - Path to the raw binary file - **x_size** (`i32`) - Required - Image width in pixels - **y_size** (`i32`) - Required - Image height in pixels - **bands** (`i32`) - Required - Number of color bands (1 for grayscale, 3 for RGB, 4 for RGBA) - **offset** (`u64`) - Required - Byte offset to start reading from ### Returns - `Result` - Loaded raw image. ### Example ```rust // Load 512x512 RGB image from offset 0 let image = VipsImage::new_from_file_raw("raw.bin", 512, 512, 3, 0)?; ``` ``` -------------------------------- ### VipsTarget::new_to_file Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/vips-source-target.md Creates a VipsTarget for writing image data to a specified file path. ```APIDOC ## VipsTarget::new_to_file ### Description Creates a `VipsTarget` for writing to a file. ### Method Rust constructor ### Parameters #### Path Parameters - **filename** (`&str`) - Required - Output file path ### Response #### Success Response - **VipsTarget** - New target instance ### Request Example ```rust let target = VipsTarget::new_to_file("output.png")?; ``` ``` -------------------------------- ### grey(width: i32, height: i32) -> Result Source: https://github.com/olxgroup-oss/libvips-rust-bindings/blob/master/_autodocs/api-reference/operations.md Creates a grey image with a horizontal gradient from 0 to 255. ```APIDOC ## grey(width: i32, height: i32) -> Result ### Description Creates a grey image with a horizontal gradient from 0 to 255. ### Parameters #### Path Parameters - **width** (i32) - Required - The width of the image. - **height** (i32) - Required - The height of the image. ### Response #### Success Response - **VipsImage** - The generated grey image. ```