### Initialize and Process Image with libvips C++ Source: https://www.libvips.org/API/current/cpp/index.html A complete example demonstrating image loading, calculating the average pixel value, and performing an embed operation. ```cpp /* compile with: * g++ -g -Wall example.cc `pkg-config vips-cpp --cflags --libs` */ #include using namespace vips; int main (int argc, char **argv) { if (VIPS_INIT (argv[0])) vips_error_exit (NULL); if (argc != 3) vips_error_exit ("usage: %s input-file output-file", argv[0]); VImage in = VImage::new_from_file (argv[1], VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL)); double avg = in.avg (); printf ("avg = %g\n", avg); printf ("width = %d\n", in.width ()); in = VImage::new_from_file (argv[1], VImage::option ()->set ("access", VIPS_ACCESS_SEQUENTIAL)); VImage out = in.embed (10, 10, 1000, 1000, VImage::option ()-> set ("extend", "background") -> set ("background", 128)); out.write_to_file (argv[2]); vips_shutdown (); return 0; } ``` -------------------------------- ### Wrapper for Vips Operation in C++ Source: https://www.libvips.org/API/current/cpp/index.html Illustrates how to write a C++ wrapper for a libvips operation using the generic VImage::call() function. This example shows the wrapper for VImage::add(). ```cpp VImage VImage::add (VImage right, VOption *options) const { VImage out; call("add", (options ? options : VImage::option())-> set("out", &out)-> set("left", *this)-> set("right", right)); return out; } ``` -------------------------------- ### Image Arithmetic and Band Extraction in C++ Source: https://www.libvips.org/API/current/cpp/index.html Demonstrates image arithmetic using overloaded operators and band extraction using the [] operator. This example creates a circular mask. ```cpp VImage xyz = VImage::xyz (256, 256) - VImage::to_vectorv (2, 128.0, 128.0); VImage mask = (xyz[0].pow (2) + xyz[1].pow (2)).pow (0.5) < 100; ``` -------------------------------- ### Get Pixel Value at Coordinates in C++ Source: https://www.libvips.org/API/current/cpp/index.html Use the () operator overload to get the pixel value at specific coordinates. This example retrieves a point from an image. ```cpp VImage xyz = VImage::xyz (256, 256) - VImage::to_vectorv (2, 128.0, 128.0); // this will have the value [0, 0] std::vector point = xyz (128, 128); ``` -------------------------------- ### Get String Metadata in C++ Source: https://www.libvips.org/API/current/cpp/index.html Retrieve string metadata from an image using the get_string method. Specify the field name to get its value. ```cpp const char *VImage::get_string (const char *field); ``` -------------------------------- ### Create VSource from Options String Source: https://www.libvips.org/API/current/cpp/VConnection8_8h_source.html Initializes a VSource using a string of options. This allows for more complex source configurations. ```cpp static VSource new_from_options(const char *options); ``` -------------------------------- ### Create VImage from Source Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Initializes a new VImage from a VSource object. ```cpp new_from_source(VSource source, const char *option_string, VOption *options = nullptr); ``` -------------------------------- ### VImage Class Members - Functions starting with 'f' Source: https://www.libvips.org/API/current/cpp/functions_f.html This section lists functions belonging to the VImage class whose names start with the letter 'f'. ```APIDOC ## VImage Class Members - Functions starting with 'f' ### Description This section lists functions belonging to the VImage class whose names start with the letter 'f'. ### Method N/A (These are class member functions, not direct API endpoints) ### Endpoint N/A ### Parameters N/A for this overview. Specific parameters depend on individual function calls. ### Request Example N/A ### Response N/A ## falsecolour() ### Description Applies a false colour transformation to the image. ### Method N/A ### Endpoint N/A ## fastcor() ### Description Performs a fast cross-correlation on the image. ### Method N/A ### Endpoint N/A ## filename() ### Description Retrieves the filename associated with the image. ### Method N/A ### Endpoint N/A ## fill_nearest() ### Description Fills image regions using the nearest neighbour method. ### Method N/A ### Endpoint N/A ## find_trim() ### Description Finds the trim boundaries of the image. ### Method N/A ### Endpoint N/A ## fitsload() ### Description Loads an image from a FITS file. ### Method N/A ### Endpoint N/A ## fitsload_source() ### Description Loads an image from a FITS file source. ### Method N/A ### Endpoint N/A ## fitssave() ### Description Saves an image to a FITS file. ### Method N/A ### Endpoint N/A ## flatten() ### Description Flattens the image, removing any alpha channels. ### Method N/A ### Endpoint N/A ## flip() ### Description Flips the image horizontally and vertically. ### Method N/A ### Endpoint N/A ## fliphor() ### Description Flips the image horizontally. ### Method N/A ### Endpoint N/A ## flipver() ### Description Flips the image vertically. ### Method N/A ### Endpoint N/A ## float2rad() ### Description Converts image pixel values from float to radians. ### Method N/A ### Endpoint N/A ## floor() ### Description Applies the floor function to image pixel values. ### Method N/A ### Endpoint N/A ## format() ### Description Retrieves the image format. ### Method N/A ### Endpoint N/A ## fractsurf() ### Description Calculates the fractal surface of the image. ### Method N/A ### Endpoint N/A ## freqmult() ### Description Performs frequency multiplication on the image. ### Method N/A ### Endpoint N/A ## fwfft() ### Description Performs a forward Fast Fourier Transform on the image. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### Create VSource from File Path Source: https://www.libvips.org/API/current/cpp/VConnection8_8h_source.html Creates a VSource object by opening and reading from the specified file path. The file must exist and be readable. ```cpp static VSource new_from_file(const char *filename); ``` -------------------------------- ### GET /height Source: https://www.libvips.org/API/current/cpp/classVImage.html Retrieves the height of the image in pixels. ```APIDOC ## GET /height ### Description Return the height of the image in pixels. ### Method GET ### Endpoint /height ### Response #### Success Response (200) - **height** (int) - The height of the image in pixels. ``` -------------------------------- ### VImage Functions (I) Source: https://www.libvips.org/API/current/cpp/functions_func_i.html Documentation for VImage functions starting with 'i'. ```APIDOC ## VImage Functions (I) ### Description Documentation for VImage functions starting with 'i'. ### Functions - **icc_export()** : VImage - **icc_import()** : VImage - **icc_transform()** : VImage - **identity()** : VImage - **ifthenelse()** : VImage - **imag()** : VImage - **inplace()** : VImage - **insert()** : VImage - **interpretation()** : VImage - **invert()** : VImage - **invertlut()** : VImage - **invfft()** : VImage - **is_null()** : VImage, VObject ``` -------------------------------- ### Image Creation and Loading Methods Source: https://www.libvips.org/API/current/cpp/classVImage.html Methods for initializing VImage objects from different data sources such as files, memory buffers, or raw memory pointers. ```APIDOC ## Static Methods: Image Creation ### Description Methods to create new VImage instances from various sources. ### Methods - **new_from_file** (const char *name, VOption *options=nullptr) - Create an image from a file. - **new_from_buffer** (const void *buf, size_t len, const char *option_string, VOption *options=nullptr) - Create an image from a memory buffer. - **new_from_memory** (const void *data, size_t size, int width, int height, int bands, VipsBandFormat format) - Create an image from raw memory. - **new_matrix** (int width, int height) - Create a new matrix image. ### Parameters - **name/filename** (const char*) - Path to the input file. - **buf/data** (void*) - Pointer to the image data. - **width/height** (int) - Dimensions of the image or matrix. - **options** (VOption*) - Optional configuration parameters. ``` -------------------------------- ### VImage Class Members (Functions starting with 'c') Source: https://www.libvips.org/API/current/cpp/functions_c.html This section lists various functions available for the VImage class in the libvips C++ binding, specifically those whose names start with the letter 'c'. These functions cover a range of image processing operations. ```APIDOC ## VImage Class Members (Functions starting with 'c') ### Description This section lists various functions available for the VImage class in the libvips C++ binding, specifically those whose names start with the letter 'c'. These functions cover a range of image processing operations. ### Method N/A (These are class member functions) ### Endpoint N/A (These are class member functions) ### Parameters N/A (Parameters vary per function, refer to individual function documentation) ### Request Example N/A ### Response N/A (Return types vary per function, refer to individual function documentation) ## Functions ### cache() - **Description**: Caches an image. - **Method**: N/A - **Endpoint**: N/A ### call() - **Description**: Calls a libvips operation. - **Method**: N/A - **Endpoint**: N/A ### call_option_string() - **Description**: Calls a libvips operation with options as a string. - **Method**: N/A - **Endpoint**: N/A ### canny() - **Description**: Applies the Canny edge detector. - **Method**: N/A - **Endpoint**: N/A ### case_image() - **Description**: Converts image to a specified case. - **Method**: N/A - **Endpoint**: N/A ### cast() - **Description**: Casts an image to a different data type. - **Method**: N/A - **Endpoint**: N/A ### ceil() - **Description**: Rounds image pixel values up to the nearest integer. - **Method**: N/A - **Endpoint**: N/A ### clamp() - **Description**: Clamps image pixel values to a specified range. - **Method**: N/A - **Endpoint**: N/A ### CMC2LCh() - **Description**: Converts an image from CMC2000 color space to LCh. - **Method**: N/A - **Endpoint**: N/A ### CMYK2XYZ() - **Description**: Converts an image from CMYK color space to XYZ. - **Method**: N/A - **Endpoint**: N/A ### coding() - **Description**: Gets or sets the coding of an image. - **Method**: N/A - **Endpoint**: N/A ### colourspace() - **Description**: Gets or sets the colourspace of an image. - **Method**: N/A - **Endpoint**: N/A ### compass() - **Description**: Applies a compass filter to an image. - **Method**: N/A - **Endpoint**: N/A ### complex() - **Description**: Creates a complex image from two real images. - **Method**: N/A - **Endpoint**: N/A ### complex2() - **Description**: Creates a complex image from a complex image and a real image. - **Method**: N/A - **Endpoint**: N/A ### complexform() - **Description**: Forms a complex image from real and imaginary parts. - **Method**: N/A - **Endpoint**: N/A ### complexget() - **Description**: Extracts real and imaginary parts from a complex image. - **Method**: N/A - **Endpoint**: N/A ### composite() - **Description**: Composites two images. - **Method**: N/A - **Endpoint**: N/A ### composite2() - **Description**: Composites two images with a mask. - **Method**: N/A - **Endpoint**: N/A ### conj() - **Description**: Computes the complex conjugate of an image. - **Method**: N/A - **Endpoint**: N/A ### conv() - **Description**: Converts an image to a different pixel format. - **Method**: N/A - **Endpoint**: N/A ### conva() - **Description**: Converts an image to a different pixel format with alpha. - **Method**: N/A - **Endpoint**: N/A ### convasep() - **Description**: Converts an image to a different pixel format, separating alpha. - **Method**: N/A - **Endpoint**: N/A ### convf() - **Description**: Converts an image to a float format. - **Method**: N/A - **Endpoint**: N/A ### convi() - **Description**: Converts an image to an integer format. - **Method**: N/A - **Endpoint**: N/A ### convsep() - **Description**: Converts an image to a different pixel format, separating channels. - **Method**: N/A - **Endpoint**: N/A ### copy() - **Description**: Creates a copy of an image. - **Method**: N/A - **Endpoint**: N/A ### copy_memory() - **Description**: Copies image memory. - **Method**: N/A - **Endpoint**: N/A ### cos() - **Description**: Computes the cosine of an image. - **Method**: N/A - **Endpoint**: N/A ### cosh() - **Description**: Computes the hyperbolic cosine of an image. - **Method**: N/A - **Endpoint**: N/A ### countlines() - **Description**: Counts lines in an image. - **Method**: N/A - **Endpoint**: N/A ### crop() - **Description**: Crops an image to a specified region. - **Method**: N/A - **Endpoint**: N/A ### csvload() - **Description**: Loads image data from a CSV file. - **Method**: N/A - **Endpoint**: N/A ### csvload_source() - **Description**: Loads image data from a CSV file source. - **Method**: N/A - **Endpoint**: N/A ### csvsave() - **Description**: Saves image data to a CSV file. - **Method**: N/A - **Endpoint**: N/A ### csvsave_target() - **Description**: Saves image data to a CSV file target. - **Method**: N/A - **Endpoint**: N/A ``` -------------------------------- ### Create New Image from Buffer (C-style) Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Creates a new VImage object from a memory buffer using C-style pointers and length. Supports optional string and VOption parameters. ```cpp static VImage new_from_buffer(const void *buf, size_t len, const char *option_string, VOption *options = nullptr); ``` -------------------------------- ### VImage::get_string() Source: https://www.libvips.org/API/current/cpp/classVImage.html Gets the value of a metadata item as a string. ```APIDOC ## VImage::get_string() ### Description Get the value of a metadata item as a string. You must not free the result. If the item is not of this type, an exception is thrown. ### Method GET ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters - **_field_** (const char *) - Required - The name of the metadata field. ### Request Example N/A ### Response #### Success Response (200) - **const char *** - A pointer to the string value of the metadata item. ``` -------------------------------- ### Image Creation Methods Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Static methods for creating new VImage instances from various sources. ```APIDOC ## new_memory() ### Description Creates a new VImage in memory. ### Response - **VImage** - A new VImage instance. ## new_temp_file(file_format) ### Description Creates a new temporary file-backed VImage. ### Parameters - **file_format** (const char*) - Optional - The file format extension (default: ".v"). ### Response - **VImage** - A new VImage instance. ``` -------------------------------- ### VImage::get_int() Source: https://www.libvips.org/API/current/cpp/classVImage.html Gets the value of a metadata item as an integer. ```APIDOC ## VImage::get_int() ### Description Get the value of a metadata item as an int. If the item is not of this type, an exception is thrown. ### Method GET ### Endpoint N/A (Method within a class) ### Parameters #### Path Parameters - **_field_** (const char *) - Required - The name of the metadata field. ### Request Example N/A ### Response #### Success Response (200) - **int** - The integer value of the metadata item. ``` -------------------------------- ### VRegion Functions (a) Source: https://www.libvips.org/API/current/cpp/functions_func.html Documentation for VRegion functions starting with the letter 'a'. ```APIDOC ## addr() ### Description Gets the address of a region. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### VRegion::prepare() Member Functions Source: https://www.libvips.org/API/current/cpp/classVRegion.html Functions to prepare the VRegion for access, either by specifying a VipsRect or individual coordinates and dimensions. ```APIDOC ## prepare() [1/2] ### Description Prepare the region from VipsRect. ### Method void VRegion::prepare(const VipsRect *rect) const ### Endpoint N/A (Member Function) ### Parameters - **rect** (const VipsRect *) - A pointer to a VipsRect structure defining the area to prepare. ### Request Example ```cpp VipsRect area_to_prepare = {10, 10, 100, 100}; vips_region.prepare(&area_to_prepare); ``` ### Response N/A (void return type) ### Response Example N/A ## prepare() [2/2] ### Description Prepare the region from rectangle coordinates. ### Method void VRegion::prepare(int left, int top, int width, int height) const ### Endpoint N/A (Member Function) ### Parameters - **left** (int) - The left coordinate of the rectangle. - **top** (int) - The top coordinate of the rectangle. - **width** (int) - The width of the rectangle. - **height** (int) - The height of the rectangle. ### Request Example ```cpp vips_region.prepare(10, 10, 100, 100); ``` ### Response N/A (void return type) ### Response Example N/A ``` -------------------------------- ### Create Matrix Images Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Methods for initializing matrix-based images from dimensions or arrays. ```cpp static VImage new_matrix(int width, int height); ``` ```cpp static VImage new_matrix(int width, int height, double *array, int size) { VipsImage *image; if (!(image = vips_image_new_matrix_from_array(width, height, array, size))) throw(VError()); return VImage(image); } ``` ```cpp static VImage new_matrixv(int width, int height, ...); ``` -------------------------------- ### VImage Functions (a) Source: https://www.libvips.org/API/current/cpp/functions_func.html Documentation for VImage functions starting with the letter 'a'. ```APIDOC ## VImage Functions (a) ### Description Provides access to VImage functions starting with 'a'. ### Method N/A (These are function calls within the C++ library) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## abs() ### Description Calculates the absolute value of an image. ### Method N/A ### Endpoint N/A ## acos() ### Description Calculates the arc cosine of an image. ### Method N/A ### Endpoint N/A ## acosh() ### Description Calculates the inverse hyperbolic cosine of an image. ### Method N/A ### Endpoint N/A ## add() ### Description Adds two images or an image and a scalar. ### Method N/A ### Endpoint N/A ## addalpha() ### Description Adds an alpha band to an image. ### Method N/A ### Endpoint N/A ## affine() ### Description Applies an affine transformation to an image. ### Method N/A ### Endpoint N/A ## analyzeload() ### Description Analyzes the load parameters of an image file. ### Method N/A ### Endpoint N/A ## arrayjoin() ### Description Joins an array of images into a single image. ### Method N/A ### Endpoint N/A ## asin() ### Description Calculates the arc sine of an image. ### Method N/A ### Endpoint N/A ## asinh() ### Description Calculates the inverse hyperbolic sine of an image. ### Method N/A ### Endpoint N/A ## atan() ### Description Calculates the arc tangent of an image. ### Method N/A ### Endpoint N/A ## atan2() ### Description Calculates the arc tangent of y/x using the signs of the two arguments. ### Method N/A ### Endpoint N/A ## atanh() ### Description Calculates the inverse hyperbolic tangent of an image. ### Method N/A ### Endpoint N/A ## autorot() ### Description Autorotates an image based on EXIF orientation tag. ### Method N/A ### Endpoint N/A ## avg() ### Description Calculates the average value of an image. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### Load Generic Image from File Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Loads a generic image format from a specified file path. Use this for common image types. ```cpp VImage VImage::vipsload(const char *filename, VOption *options) { VImage out; call("vipsload", (options ? options : VImage::option()) ->set("out", &out) ->set("filename", filename)); return out; } ``` -------------------------------- ### GET /jxlload Source: https://www.libvips.org/API/current/cpp/classVImage.html Loads a JPEG-XL image from a file, buffer, or source. ```APIDOC ## GET /jxlload ### Description Load jpeg-xl image from a file, buffer, or source. ### Method GET ### Endpoint VImage::jxlload(const char *filename, VOption *options) VImage::jxlload_buffer(VipsBlob *buffer, VOption *options) VImage::jxlload_source(VSource source, VOption *options) ### Parameters #### Path Parameters - **filename/buffer/source** (various) - Required - Input source. #### Request Body - **options** (VOption*) - Optional - Set of options including page, n, memory, access, fail_on, and revalidate. ### Response #### Success Response (200) - **image** (VImage) - Output image. ``` -------------------------------- ### complexget() - Get a component from a complex image Source: https://www.libvips.org/API/current/cpp/classVImage.html Extracts a component from a complex image. ```APIDOC ## complexget() ### Description Get a component from a complex image. ### Method `VImage::complexget` ### Parameters #### Path Parameters - **get** (VipsOperationComplexget) - Required - Complex to perform. - **options** (VOption *) - Optional - Set of options. ### Returns - **Output image** (VImage) - Output image. ``` -------------------------------- ### Create VSource from File Descriptor Source: https://www.libvips.org/API/current/cpp/VConnection8_8h_source.html Use this static method to create a VSource object from an existing file descriptor. Ensure the descriptor is valid and open. ```cpp static VSource new_from_descriptor(int descriptor); ``` -------------------------------- ### Get point value from image Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Retrieves the pixel value at a specific coordinate. ```cpp call("getpoint", (options ? options : VImage::option()) ->set("in", *this) ->set("out_array", &out_array) ->set("x", x) ->set("y", y)); return out_array; ``` -------------------------------- ### VRegion Constructor Source: https://www.libvips.org/API/current/cpp/classVRegion.html Documentation for the VRegion constructor, which allows creating a VRegion object by wrapping an existing VipsRegion. ```APIDOC ## VRegion() ### Description Create a VRegion that wraps a VipsRegion object. If steal is STEAL, then this VRegion takes over ownership of the libvips object and will automatically unref it. ### Method VRegion::VRegion ### Parameters - **_region_** (VipsRegion *) - The VipsRegion object to wrap. - **_steal_** (VSteal) - Optional. Specifies whether the VRegion takes ownership of the VipsRegion object. Defaults to STEAL. ### Request Example ```cpp VipsRegion *raw_region = ...; // Get a VipsRegion pointer VRegion vips_region(raw_region, VIPS_STEAL); ``` ### Response N/A (Constructor) ``` -------------------------------- ### Get Type of Property Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Retrieves the GType (enum type) of an image property. ```cpp GType get_typeof(const char *field) const { return vips_image_get_typeof(this->get_image(), field); } ``` -------------------------------- ### Get Image Interpretation Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Returns the interpretation of the image data (e.g., VIPS_INTERPRETATION_RGB). ```cpp VipsInterpretation interpretation() const { return vips_image_get_interpretation(get_image()); } ``` -------------------------------- ### VImage::niftiload Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Loads a NIfTI image from a file. ```APIDOC ## VImage::niftiload ### Description Loads a NIfTI image from the specified filename. ### Parameters - **filename** (const char*) - Path to the NIfTI file. - **options** (VOption*) - Optional parameters. ``` -------------------------------- ### Get String Property Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Retrieves a string property from an image. Throws VError on failure. ```cpp const char * get_string(const char *field) const { const char *value; if (vips_image_get_string(this->get_image(), field, &value)) throw(VError()); return value; } ``` -------------------------------- ### Load Radiance images Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Methods for loading Radiance images from files, buffers, or sources. ```cpp VImage VImage::radload(const char *filename, VOption *options) { VImage out; call("radload", (options ? options : VImage::option()) ->set("out", &out) ->set("filename", filename)); return out; } ``` ```cpp VImage VImage::radload_buffer(VipsBlob *buffer, VOption *options) { VImage out; call("radload_buffer", (options ? options : VImage::option()) ->set("out", &out) ->set("buffer", buffer)); return out; } ``` ```cpp VImage VImage::radload_source(VSource source, VOption *options) { VImage out; call("radload_source", (options ? options : VImage::option()) ->set("out", &out) ->set("source", source)); return out; } ``` -------------------------------- ### Load WebP Image from File Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Loads a WebP image from a specified file path. Use this for WebP encoded images. ```cpp VImage VImage::webpload(const char *filename, VOption *options) { VImage out; call("webpload", (options ? options : VImage::option()) ->set("out", &out) ->set("filename", filename)); return out; } ``` -------------------------------- ### Get Integer Property Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Retrieves an integer property from an image. Throws VError on failure. ```cpp int get_int(const char *field) const { int value; if (vips_image_get_int(this->get_image(), field, &value)) throw(VError()); return value; } ``` -------------------------------- ### Get Image Format Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Returns the pixel format of the image (e.g., VIPS_FORMAT_UCHAR, VIPS_FORMAT_FLOAT). ```cpp VipsBandFormat format() const { return vips_image_get_format(get_image()); } ``` -------------------------------- ### NIfTI format I/O Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Load and save images in NIfTI format. ```cpp VImage VImage::niftiload(const char *filename, VOption *options) { VImage out; call("niftiload", (options ? options : VImage::option()) ->set("out", &out) ->set("filename", filename)); return out; } ``` ```cpp VImage VImage::niftiload_source(VSource source, VOption *options) { VImage out; call("niftiload_source", (options ? options : VImage::option()) ->set("out", &out) ->set("source", source)); return out; } ``` ```cpp void VImage::niftisave(const char *filename, VOption *options) const { call("niftisave", (options ? options : VImage::option()) ->set("in", *this) ->set("filename", filename)); } ``` -------------------------------- ### Thumbnail from Buffer Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Creates a thumbnail image from a raw buffer. Requires a pointer to the buffer, its length, and the desired width. Options can be provided. ```cpp static VImage thumbnail_buffer(void *buf, size_t len, int width, VOption *options = nullptr); ``` -------------------------------- ### VImage Class Members (i) Source: https://www.libvips.org/API/current/cpp/functions_i.html A list of available methods for the VImage class starting with the letter 'i'. ```APIDOC ## VImage Class Members (i) ### Description List of available methods for the VImage class in the libvips C++ binding. ### Methods - **icc_export()** : VImage - **icc_import()** : VImage - **icc_transform()** : VImage - **identity()** : VImage - **ifthenelse()** : VImage - **imag()** : VImage - **inplace()** : VImage - **insert()** : VImage - **interpretation()** : VImage - **invert()** : VImage - **invertlut()** : VImage - **invfft()** : VImage - **is_null()** : VImage, VObject ``` -------------------------------- ### VImage::tonelut Source: https://www.libvips.org/API/current/cpp/classVImage.html Builds a look-up table. ```APIDOC ## POST /VImage/tonelut ### Description Build a look-up table. ### Parameters #### Request Body - **options** (VOption*) - Optional - Set of options including in_max, out_max, Lb, Lw, Ps, Pm, Ph, S, M, and H. ### Response #### Success Response (200) - **VImage** - Output image. ``` -------------------------------- ### Get Double Property Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Retrieves a double-precision floating-point property from an image. Throws VError on failure. ```cpp double get_double(const char *field) const { double value; if (vips_image_get_double(this->get_image(), field, &value)) throw(VError()); return value; } ``` -------------------------------- ### VSource Constructors Source: https://www.libvips.org/API/current/cpp/classVSource.html Documentation for the constructors of the VSource class. ```APIDOC ## Constructor & Destructor Documentation ## ◆ VSource() | VSource::VSource | ( | VipsSource * | _input_ , ---|---|---|--- | | VSteal | _steal_ = `STEAL` | ) | | inlineexplicit Wrap a VSource around an underlying VipsSoure object. ``` -------------------------------- ### Get Filename Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Returns the filename associated with the image. Returns nullptr if the image was not loaded from a file. ```cpp const char * filename() const { return vips_image_get_filename(get_image()); } ``` -------------------------------- ### libvips C++ Binding Overview Source: https://www.libvips.org/API/current/cpp/dir_0fdf89178698c59bcf622970d314168c.html This section provides an overview of the libvips C++ binding structure, including namespaces, classes, and files. ```APIDOC ## libvips C++ Binding (v8.18) ### Description This documentation details the libvips C++ binding, a library for image processing. ### Structure - **Namespaces**: Provides a list of namespaces. - **Classes**: Lists all classes, their hierarchy, and members. - **Class Members**: Includes all members, categorized by functions. - **Files**: Lists the files included in the binding. ### Directory Structure - **vips**: The main directory for libvips. ``` -------------------------------- ### Get Image Coding Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Returns the coding method used for the image (e.g., VIPS_CODING_NONE, VIPS_CODING_LZW). ```cpp VipsCoding coding() const { return vips_image_get_coding(get_image()); } ``` -------------------------------- ### Execute System Command Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Executes a system command formatted with the provided options. ```cpp void VImage::system(const char *cmd_format, VOption *options) { call("system", (options ? options : VImage::option()) ->set("cmd_format", cmd_format)); } ``` -------------------------------- ### Get Image Width Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Returns the width of the image in pixels. Requires a valid VImage object. ```cpp int width() const { return vips_image_get_width(get_image()); } ``` -------------------------------- ### VImage Constructors and Destructor Source: https://www.libvips.org/API/current/cpp/classVImage.html Documentation for the VImage class constructors. ```APIDOC ## VImage() [1/2] | VImage::VImage | ( | VipsImage * | _image_ , ---|---|---|--- | | VSteal | _steal_ = `STEAL` | ) | | inlineexplicit Wrap a VImage around an underlying VipsImage object. If steal is STEAL, then the VImage will take ownership of the reference to the VipsImage. ## VImage() [2/2] | VImage::VImage | ( | | ) | ---|---|---|---| inline An empty (NULL) VImage, eg. "VImage a;" ``` -------------------------------- ### VImage Class Members - z Source: https://www.libvips.org/API/current/cpp/functions_z.html Lists the documented members of the VImage class starting with 'z'. ```APIDOC ## VImage Class Members - z ### Description Provides access to functions within the VImage class that start with the letter 'z'. ### Method N/A (Class Member Documentation) ### Endpoint N/A (Class Member Documentation) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ## zone() ### Description Represents a zone-related operation or property within VImage. ### Method N/A ### Endpoint N/A ## zoom() ### Description Represents a zoom-related operation or property within VImage. ### Method N/A ### Endpoint N/A ``` -------------------------------- ### VImage::thumbnail_source() Source: https://www.libvips.org/API/current/cpp/classVImage.html Generates a thumbnail from a VipsSource. ```APIDOC ## POST /api/thumbnail_source ### Description Generates a thumbnail from a VipsSource. ### Method POST ### Endpoint /api/thumbnail_source ### Parameters #### Query Parameters - **source** (VipsSource) - Required - Source to load from. - **width** (int) - Required - Size to this width. - **options** (VOption *) - Optional - Set of options. #### Request Body - **option_string** (string) - Optional - Options passed to the underlying loader. - **height** (int) - Optional - Size to this height. - **size** (VipsSize) - Optional - Only upsize, only downsize, or both. - **no_rotate** (bool) - Optional - Don't use orientation tags to rotate image upright. - **crop** (VipsInteresting) - Optional - Reduce to fill target rectangle, then crop. - **linear** (bool) - Optional - Reduce in linear light. - **input_profile** (string) - Optional - Fallback input profile. - **output_profile** (string) - Optional - Fallback output profile. - **intent** (VipsIntent) - Optional - Rendering intent. - **fail_on** (VipsFailOn) - Optional - Error level to fail on. ### Response #### Success Response (200) - **Output image** (VImage) - The generated thumbnail image. #### Response Example { "example": "VImage object representing the thumbnail" } ``` -------------------------------- ### VImage Class Members (x) Source: https://www.libvips.org/API/current/cpp/functions_x.html This section lists members of the VImage class starting with 'x'. ```APIDOC ## VImage Class Members (x) ### Description Provides access to various image properties and transformations related to the 'x' dimension or color space conversions. ### Method Various (member functions of VImage) ### Endpoint N/A (Class member functions) ### Parameters None directly applicable to this listing. ### Request Example N/A ### Response N/A ## xoffset() ### Description Gets the x-offset of the image. ### Method Member function of VImage ### Endpoint N/A ## xres() ### Description Gets the horizontal resolution of the image. ### Method Member function of VImage ### Endpoint N/A ## xyz() ### Description Converts the image to the XYZ color space. ### Method Member function of VImage ### Endpoint N/A ## XYZ2CMYK() ### Description Converts the image from XYZ color space to CMYK color space. ### Method Member function of VImage ### Endpoint N/A ## XYZ2Lab() ### Description Converts the image from XYZ color space to Lab color space. ### Method Member function of VImage ### Endpoint N/A ## XYZ2Oklab() ### Description Converts the image from XYZ color space to Oklab color space. ### Method Member function of VImage ### Endpoint N/A ## XYZ2scRGB() ### Description Converts the image from XYZ color space to scRGB color space. ### Method Member function of VImage ### Endpoint N/A ## XYZ2Yxy() ### Description Converts the image from XYZ color space to Yxy color space. ### Method Member function of VImage ### Endpoint N/A ``` -------------------------------- ### Grid image Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Creates a grid layout from the input image. ```cpp VImage VImage::grid(int tile_height, int across, int down, VOption *options) const { VImage out; call("grid", (options ? options : VImage::option()) ->set("in", *this) ->set("out", &out) ->set("tile_height", tile_height) ->set("across", across) ->set("down", down)); return out; } ``` -------------------------------- ### Get Image Height Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Returns the height of the image in pixels. Ensure the VImage object is valid before calling. ```cpp int height() const { return vips_image_get_height(get_image()); } ``` -------------------------------- ### Create New Image from File Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Creates a new VImage object by loading an image from a file. Supports optional VOption parameters. ```cpp static VImage new_from_file(const char *name, VOption *options = nullptr); ``` -------------------------------- ### VImage::draw_flood Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Performs a flood fill operation on an image starting from a given point with a specified color. ```APIDOC ## VImage::draw_flood ### Description Performs a flood fill operation on an image. ### Method const ### Parameters #### Path Parameters - **ink** (std::vector) - Required - The color to fill with. - **x** (int) - Required - The starting x-coordinate for the flood fill. - **y** (int) - Required - The starting y-coordinate for the flood fill. #### Query Parameters - **options** (VOption *) - Optional - Additional options for the flood fill operation. ### Request Example ```json { "ink": [0, 255, 0], "x": 100, "y": 100 } ``` ### Response This method does not return a value (void). ### Error Handling Potential errors include invalid starting coordinates or ink values. ``` -------------------------------- ### Load WebP Image from Source Source: https://www.libvips.org/API/current/cpp/vips-operators_8cpp_source.html Loads a WebP image from a VSource. Use this for custom input streams or network sources. ```cpp VImage VImage::webpload_source(VSource source, VOption *options) { VImage out; call("webpload_source", (options ? options : VImage::option()) ->set("out", &out) ->set("source", source)); return out; } ``` -------------------------------- ### VImage Class Methods (t) Source: https://www.libvips.org/API/current/cpp/functions_t.html A list of available VImage methods for image processing operations starting with 't'. ```APIDOC ## VImage Class Methods ### Description Methods available on the VImage class for image manipulation and processing. ### Methods - **tan()**: VImage - **tanh()**: VImage - **text()**: VImage - **thumbnail()**: VImage - **thumbnail_buffer()**: VImage - **thumbnail_image()**: VImage - **thumbnail_source()**: VImage - **tiffload()**: VImage - **tiffload_buffer()**: VImage - **tiffload_source()**: VImage - **tiffsave()**: VImage - **tiffsave_buffer()**: VImage - **tiffsave_target()**: VImage - **tilecache()**: VImage - **tonelut()**: VImage - **transpose3d()**: VImage ``` -------------------------------- ### Get Double Array Property (Vector) Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Retrieves a double array property and returns it as a std::vector. ```cpp std::vector get_array_double(const char *field) const { int length; double *array; if (vips_image_get_array_double(this->get_image(), field, &array, &length)) throw(VError()); std::vector vector(array, array + length); return vector; } ``` -------------------------------- ### VipsImage Class - Constructors Source: https://www.libvips.org/API/current/cpp/classVImage.html Constructors for the VipsImage class. ```APIDOC ## VImage Constructor ### Description Constructs a VipsImage object. ### Method Constructor ### Parameters #### Path Parameters - **image** (VipsImage *) - A pointer to an existing VipsImage to steal. - **steal** (VSteal) - Enum indicating whether to steal the image data (default is STEAL). ### Description Default constructor for VipsImage. ### Method Constructor ### Parameters None ``` -------------------------------- ### Get Integer Array Property (Vector) Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Retrieves an integer array property and returns it as a std::vector. ```cpp std::vector get_array_int(const char *field) const { int length; int *array; if (vips_image_get_array_int(this->get_image(), field, &array, &length)) throw(VError()); std::vector vector(array, array + length); return vector; } ``` -------------------------------- ### Class Hierarchy Overview Source: https://www.libvips.org/API/current/cpp/hierarchy.html Overview of the primary class inheritance structure in the libvips C++ binding. ```APIDOC ## Class Hierarchy ### Description This section describes the inheritance structure of the libvips C++ binding classes. ### Hierarchy - **std::runtime_error** - **CVError** - **CVObject** - **CVImage** - **CVInterpolate** - **CVRegion** - **CVSource** - **CVTarget** - **CVOption** ``` -------------------------------- ### VImage::thumbnail_buffer() (void *) Source: https://www.libvips.org/API/current/cpp/classVImage.html Generates a thumbnail from a raw buffer. ```APIDOC ## POST /api/thumbnail_buffer/raw ### Description Generates a thumbnail from a raw buffer. ### Method POST ### Endpoint /api/thumbnail_buffer/raw ### Parameters #### Query Parameters - **buf** (void *) - Required - Buffer to load from. - **len** (size_t) - Required - Size of buffer. - **width** (int) - Required - Size to this width. - **options** (VOption *) - Optional - Set of options. #### Request Body - **option_string** (string) - Optional - Options passed to the underlying loader. - **height** (int) - Optional - Size to this height. - **size** (VipsSize) - Optional - Only upsize, only downsize, or both. - **no_rotate** (bool) - Optional - Don't use orientation tags to rotate image upright. - **crop** (VipsInteresting) - Optional - Reduce to fill target rectangle, then crop. - **linear** (bool) - Optional - Reduce in linear light. - **import_profile** (string) - Optional - Fallback import profile. - **export_profile** (string) - Optional - Fallback export profile. - **intent** (VipsIntent) - Optional - Rendering intent. - **fail_on** (VipsFailOn) - Optional - Error level to fail on. ### Response #### Success Response (200) - **Output image** (VImage) - The generated thumbnail image. #### Response Example { "example": "VImage object representing the thumbnail" } ``` -------------------------------- ### Get Gainmap Image Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Retrieves the gainmap image associated with this image, if any. Returns a VImage object representing the gainmap. ```cpp VImage gainmap() const { return VImage(vips_image_get_gainmap(get_image())); } ``` -------------------------------- ### Class Overview Source: https://www.libvips.org/API/current/cpp/annotated.html This section lists the main classes available in the libvips C++ binding. ```APIDOC ## Class Overview This section lists the main classes available in the libvips C++ binding. ### Classes - **CVError** - **CVImage** - **CVInterpolate** - **CVObject** - **CVOption** - **CVRegion** - **CVSource** - **CVTarget** ``` -------------------------------- ### Get Y Offset Source: https://www.libvips.org/API/current/cpp/VImage8_8h_source.html Returns the vertical offset of the image's origin. Used for precise positioning, often with resolution. ```cpp int yoffset() const { return vips_image_get_yoffset(get_image()); } ```