### Install pyvips with Binary Support Source: https://github.com/libvips/pyvips/blob/master/README.rst Install pyvips with a self-contained binary package for common libraries. This is the quickest way to start and should work on most platforms. ```shell pip install "pyvips[binary]" ``` -------------------------------- ### Install pyvips with Binary Support Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Install pyvips using pip, including common libraries for a self-contained package. This is the quickest way to start on most platforms. ```shell $ pip install "pyvips[binary]" ``` -------------------------------- ### Basic Logging Setup Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Configure basic logging to display warning messages and above. Add these lines near the start of your program. ```python import logging logging.basicConfig(level=logging.WARNING) ``` -------------------------------- ### Install pyvips with Binary Dependencies Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Use this command for a local installation with binary dependencies included. ```shell $ pip install -e .[binary] ``` -------------------------------- ### Install Type Checking Tools Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Install mypy and pyvips for type checking. ```shell $ pip install mypy pyvips ``` -------------------------------- ### Install pyvips on macOS Source: https://github.com/libvips/pyvips/blob/master/README.rst Install vips, python, and pkg-config using Homebrew, followed by pyvips. ```shell brew install vips python pkg-config pip install pyvips ``` -------------------------------- ### Install pyvips on Debian/Ubuntu Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Install pyvips on Debian-based Linux systems using apt. Ensure libvips development headers are installed. ```shell $ sudo apt install libvips-dev --no-install-recommends $ pip install pyvips ``` -------------------------------- ### Install pyvips on macOS Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Install pyvips on macOS using Homebrew for vips and Python, followed by pip installation. ```shell $ brew install vips python pkg-config $ pip install pyvips ``` -------------------------------- ### Install pyvips on Linux Source: https://github.com/libvips/pyvips/blob/master/README.rst Install libvips development headers and then pyvips. For Python 3.11+, ensure you are in a virtual environment and add its path to your PATH. ```shell sudo apt install libvips-dev --no-install-recommends pip install pyvips ``` ```shell python3 -m venv ~/.local pip install pyvips ``` -------------------------------- ### Install pyvips with Conda Source: https://github.com/libvips/pyvips/blob/master/README.rst Install pyvips using Conda, which includes a matching libvips binary. ```shell conda install --channel conda-forge pyvips ``` -------------------------------- ### Progress Handler Setup Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Attaches progress handlers to an image to monitor computation. Ensure `set_progress(True)` is called on the image before connecting signals. ```python image = pyvips.Image.black(1, 500) image.set_progress(True) image.signal_connect('preeval', preeval_handler) image.signal_connect('eval', eval_handler) image.signal_connect('posteval', posteval_handler) image.avg() ``` -------------------------------- ### Image Arithmetic and Logic Example Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Demonstrates mixing images, constants, and lists of constants for arithmetic and boolean operations. This allows for complex image manipulations. ```python result_image = ((image * [1, 2, 3]).abs() < 128) | 4 ``` -------------------------------- ### Image Processing Pipeline Example Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Load an image, enhance the green channel, apply a sharpening convolution, and save the result. This demonstrates a typical image processing pipeline in pyvips. ```python import pyvips image = pyvips.Image.new_from_file('some-image.jpg', access='sequential') image *= [1, 2, 1] mask = pyvips.Image.new_from_array([ [-1, -1, -1], [-1, 16, -1], [-1, -1, -1], ], scale=8) image = image.conv(mask, precision='integer') image.write_to_file('x.jpg') ``` -------------------------------- ### Install pyvips with Conda Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Install pyvips and its matching libvips binary using the Conda package manager from the conda-forge channel. ```shell $ conda install --channel conda-forge pyvips ``` -------------------------------- ### Progress Handler Details Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Provides an example of an evaluation handler function, showing the available fields in the `progress` object for monitoring computation status. ```python def eval_handler(image, progress): print(f' run = {progress.run} (seconds of run time)') print(f' eta = {progress.eta} (estimated seconds left)') print(f' tpels = {progress.tpels} (total number of pels)') print(f' npels = {progress.npels} (number of pels computed so far)') print(f' percent = {progress.percent} (percent complete)') ``` -------------------------------- ### Load GIF Image from File Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a GIF image from a file using libnsgif. Supports loading multiple pages, specifying a starting page, and various loading options. ```python out = pyvips.Image.gifload(filename, n=int, page=int, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` -------------------------------- ### Install pyvips with venv on Linux Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Install pyvips within a Python virtual environment on Linux, especially for Python 3.11 and later. This ensures proper PATH configuration. ```shell $ python3 -m venv ~/.local $ pip install pyvips ``` -------------------------------- ### Transform Image to Radiance Coding Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Use this method to convert an image from float RGB to Radiance coding. No specific setup is required beyond having an Image object. ```python out = in.float2rad() ``` -------------------------------- ### Prepare Test Images Source: https://github.com/libvips/pyvips/blob/master/tests/perf/README.rst Commands to create and prepare test images for benchmarking. Ensure you have the 'images/sample2.v' file available. ```bash $ mkdir tmp/ $ vips colourspace images/sample2.v tmp/t1.v srgb $ vips replicate tmp/t1.v tmp/t2.v 20 15 $ vips extract_area tmp/t2.v tmp/x.tif[tile] 0 0 5000 5000 $ vips copy tmp/x.tif tmp/x.jpg $ vipsheader tmp/x.tif ``` -------------------------------- ### Custom File Source and Target Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Shows how to create custom file sources and targets using `SourceCustom` and `TargetCustom` with read and write handlers. ```python import sys input_file = open(sys.argv[1], "rb") def read_handler(size): return input_file.read(size) source = pyvips.SourceCustom() source.on_read(read_handler) output_file = open(sys.argv[2], "wb") def write_handler(chunk): return output_file.write(chunk) target = pyvips.TargetCustom() target.on_write(write_handler) image = pyvips.Image.new_from_source(source, '', access='sequential') image.write_to_target(target, '.png') ``` -------------------------------- ### Basic File Source and Target Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Illustrates loading an image from a file using `Source.new_from_file` and saving it to a file using `Target.new_to_file`. ```python source = pyvips.Source.new_from_file("some/file/name") image = pyvips.Image.new_from_source(source, "", access="sequential") target = pyvips.Target.new_to_file("some/file/name") image.write_to_target(target, ".png") ``` -------------------------------- ### Generate HTML Documentation Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Navigate to the doc directory and build HTML documentation using sphinx-build. ```shell $ cd doc; sphinx-build -bhtml . build/html ``` -------------------------------- ### Regenerate Enums Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Generate enum definitions by running a Python script after installing libvips with optional packages. ```shell $ cd examples; \ ./gen-enums.py ~/GIT/libvips/build/libvips/Vips-8.0.gir > enums.py ``` -------------------------------- ### System Tuning for Benchmarks Source: https://github.com/libvips/pyvips/blob/master/tests/perf/README.rst Tunes the system for stable benchmark execution using pyperf. ```bash # tune your system to run stable benchmarks $ python3 -m pyperf system tune ``` -------------------------------- ### Get Image Metadata Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Retrieves metadata fields from an image. Use get_fields() to discover available metadata keys. ```python image = pyvips.Image.new_from_file('some-image.jpg') ipct_string = image.get('ipct-data') exif_date_string = image.get('exif-ifd0-DateTime') ``` -------------------------------- ### Build PyPI Source Distribution Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Build the source distribution for the pyvips package using the 'build' tool. ```shell $ python3 -m build --sdist ``` -------------------------------- ### gifload_source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a GIF image from a source. Allows specifying the number of pages, starting page, memory usage, access patterns, and error handling. ```APIDOC ## gifload_source ### Description Loads a GIF image from a source. Allows specifying the number of pages, starting page, memory usage, access patterns, and error handling. ### Method `pyvips.Image.gifload_source` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **source** (Source) - Required - Source to load from - **n** (int) - Optional - Number of pages to load, -1 for all - **page** (int) - Optional - First page to load - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response - `Image` or `list[Image, Dict[str, mixed]]` #### Response Example None explicitly provided in source. ### Error Handling - Raises `Error` ``` -------------------------------- ### buildlut Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Builds a look-up table from an image. ```APIDOC ## buildlut ### Description Build a look-up table. ### Method (Implicitly a method of Image class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **Image** - The generated look-up table image. ### Errors - **Error**: Raises an error if the operation fails. ``` -------------------------------- ### Run Performance Tests Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Navigate to the performance test directory and run the test script. ```shell $ cd tests/perf $ ./run.sh ``` -------------------------------- ### Tag and Push Release Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Create a Git tag for the release and push it to the origin. ```shell $ git tag -a v3.0.0 -m "as uploaded to pypi" $ git push origin v3.0.0 ``` -------------------------------- ### pyvips.Image.system Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Runs an external command, optionally taking input images and returning output. ```APIDOC ## pyvips.Image.system ### Description Runs an external command, with options for input/output formats and caching. ### Method (Not specified, likely a static method call) ### Endpoint (Not applicable, SDK method) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters - **cmd_format**: Command to run (str) - **in**: Array of input images (list[Image]) - **in_format**: Format for input filename (str) - **out_format**: Format for output filename (str) - **cache**: Cache this call (bool) - **out**: Enable output: Output image (bool) - **log**: Enable output: Command log (bool) ### Response #### Success Response - Returns a list or a list of dictionaries with mixed types. #### Response Example (Not specified) ``` -------------------------------- ### Upload to PyPI Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Upload the built package to the pyvips repository on PyPI. ```shell $ twine upload --repository pyvips dist/* ``` -------------------------------- ### Run All Tests with tox Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Execute all defined test environments using tox. ```shell $ tox ``` -------------------------------- ### niftiload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a NIfTI volume from a specified file, with options for memory usage, access pattern, error handling, and revalidation. ```APIDOC ## niftiload ### Description Load NIfTI volume. ### Method `niftiload(filename, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool, flags=bool)` ### Parameters #### Path Parameters - **filename** (str | Path) - Required - Filename to load from - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **revalidate** (bool) - Optional - Don't use a cached result for this operation - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response (200) - **Image or list[Image, Dict[str, mixed]]** - The loaded NIfTI image or a list containing the image and associated metadata. #### Response Example ``` out = pyvips.Image.niftiload(filename, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` ``` -------------------------------- ### niftiload_source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads NIfTI volumes from a given source, with options for memory usage, access pattern, and error handling. ```APIDOC ## niftiload_source ### Description Load NIfTI volumes. ### Method `niftiload_source(source, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], flags=bool)` ### Parameters #### Path Parameters - **source** (Source) - Required - Source to load from - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response (200) - **Image or list[Image, Dict[str, mixed]]** - The loaded NIfTI image or a list containing the image and associated metadata. #### Response Example ``` out = pyvips.Image.niftiload_source(source, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` ``` -------------------------------- ### Load, Modify, and Save Image Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Loads an image, boosts the green channel, sharpens it using convolution, and saves the result. Assumes sequential access is appropriate. ```python import pyvips image = pyvips.Image.new_from_file('some-image.jpg', access='sequential') image *= [1, 2, 1] mask = pyvips.Image.new_from_list([[-1, -1, -1], [-1, 16, -1], [-1, -1, -1] ], scale=8) image = image.conv(mask, precision='integer') image.write_to_file('x.jpg') ``` -------------------------------- ### Adjust Black and White Points with pyvips Source: https://github.com/libvips/pyvips/wiki/change-black-and-white-point Use this snippet to remap image intensities to the full dynamic range. It calculates the low and high percentiles and then scales the image accordingly. Ensure the input and output file paths are provided as command-line arguments. ```python import sys import pyvips image = pyvips.Image.new_from_file(sys.argv[1]) low = image.percent(5) high = image.percent(95) image = (image - low) * (255 / (high - low)) image.write_to_file(sys.argv[2]) ``` -------------------------------- ### Run pyvips Benchmarks Source: https://github.com/libvips/pyvips/blob/master/tests/perf/README.rst Executes the main pyvips benchmark script and analyzes the output JSON file using pyperf stats. ```bash $ python3 vips-bench.py -o vips-bench.json $ python3 -m pyperf stats vips-bench.json ``` -------------------------------- ### Compare Benchmark Results Source: https://github.com/libvips/pyvips/blob/master/tests/perf/README.rst Compares two benchmark result files to determine if differences are statistically significant, displaying the results in a table. ```bash # command to test if a difference is significant $ python3 -m pyperf compare_to operation-call2.json operation-call.json --table ``` -------------------------------- ### Generate Thumbnail from File Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Creates a thumbnail image from a specified file. Supports resizing, cropping, and color profile handling. ```python out = pyvips.Image.thumbnail(filename, width, height=int, size=Union[str, Size], no_rotate=bool, crop=Union[str, Interesting], linear=bool, input_profile=str | Path, output_profile=str | Path, intent=Union[str, Intent], fail_on=Union[str, FailOn]) ``` -------------------------------- ### vipsload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Load vips image from a file. ```APIDOC ## vipsload ### Description Load vips from file. ### Method (Implicitly GET or POST, as it loads data) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **filename** (str | Path) - Filename to load from - **memory** (bool) - Force open via memory - **access** (Union[str, Access]) - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Error level to fail on - **revalidate** (bool) - Don't use a cached result for this operation - **flags** (bool) - enable output: Flags for this file ### Response #### Success Response (200) - **Image or list[Image, Dict[str, mixed]]**: The loaded image or a list containing the image and metadata. #### Response Example (Example not provided in source) ``` -------------------------------- ### pyvips.Image.thumbnail Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Generates a thumbnail from a file, with options for dimensions, cropping, and color profiles. ```APIDOC ## pyvips.Image.thumbnail ### Description Generates a thumbnail from a file with specified dimensions and various processing options. ### Method (Not specified, likely a static method call) ### Endpoint (Not applicable, SDK method) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters - **filename**: Filename to read from (str | Path) - **width**: Size to this width (int) - **height**: Size to this height (int) - **size**: Only upsize, only downsize, or both (Union[str, Size]) - **no_rotate**: Don't use orientation tags to rotate image upright (bool) - **crop**: Reduce to fill target rectangle, then crop (Union[str, Interesting]) - **linear**: Reduce in linear light (bool) - **input_profile**: Fallback input profile (str | Path) - **output_profile**: Fallback output profile (str | Path) - **intent**: Rendering intent (Union[str, Intent]) - **fail_on**: Error level to fail on (Union[str, FailOn]) ### Response #### Success Response (Not specified) #### Response Example (Not specified) ``` -------------------------------- ### dcrawload_source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Load RAW camera files from a source. ```APIDOC ## dcrawload_source ### Description Load RAW camera files from a source. ### Method staticmethod ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **source** (Source) - Required - Source to load from - **bitdepth** (int) - Optional - Number of bits per pixel - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response - **Image** or **list[Image, Dict[str, mixed]]** ### Raises - **Error** ``` -------------------------------- ### vipsload_source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Load vips image from a source. ```APIDOC ## vipsload_source ### Description Load vips from source. ### Method (Implicitly GET or POST, as it loads data) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **source** (Source) - Source to load from - **memory** (bool) - Force open via memory - **access** (Union[str, Access]) - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Error level to fail on - **flags** (bool) - enable output: Flags for this file ### Response #### Success Response (200) - **Image or list[Image, Dict[str, mixed]]**: The loaded image or a list containing the image and metadata. #### Response Example (Example not provided in source) ``` -------------------------------- ### Load Image from Source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads an image from a given source, with options to force memory usage, specify access patterns, and define error handling. ```python out = pyvips.Image.radload_source(source, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` -------------------------------- ### Build Look-up Table Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst The buildlut method constructs a look-up table from an image. This is useful for color mapping or other transformations. ```python out = in.buildlut() ``` -------------------------------- ### Run External Command Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Executes an external command, optionally taking input images and producing output. Caching and logging are supported. ```python pyvips.Image.system(cmd_format, in=list[Image], in_format=str, out_format=str, cache=bool) ``` -------------------------------- ### Load OpenSlide Image from Source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads an image from a source using OpenSlide. Similar to openslideload but accepts a source object. ```python out = pyvips.Image.openslideload_source(source, level=int, autocrop=bool, associated=str, attach_associated=bool, rgb=bool, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` -------------------------------- ### Load RAW Camera Files with pyvips Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads RAW camera files using dcraw. Supports specifying bit depth, memory access, and error handling. ```python out = pyvips.Image.dcrawload(filename, bitdepth=int, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` -------------------------------- ### Create pyvips Image from NumPy Array Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Demonstrates creating a pyvips image from a NumPy array. Requires importing both pyvips and numpy. ```python import pyvips import numpy as np ``` -------------------------------- ### LabQ2LabS Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Unpacks a LabQ image to short Lab. ```APIDOC ## LabQ2LabS() ### Description Unpack a LabQ image to short Lab. ### Method LabQ2LabS ### Endpoint N/A (SDK Method) ### Parameters None ### Request Example ```python out = in.LabQ2LabS() ``` ### Response #### Success Response - **Image** (Image) - The unpacked image. #### Response Example ```json { "image": "unpacked_image_data" } ``` ### Error Handling - **Error**: Raised if the unpacking fails. ``` -------------------------------- ### Load PPM Image from Source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PPM image from a source object. Provides options for memory management, access patterns, and error handling. ```python out = pyvips.Image.ppmload_source(source, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` -------------------------------- ### ppmload_source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PPM image from a source, with options for memory usage, access patterns, and error handling. ```APIDOC ## ppmload_source ### Description Load ppm from source. ### Method staticmethod ### Endpoint (Not applicable, SDK method) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```python out = pyvips.Image.ppmload_source(source, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` ### Response #### Success Response (200) (Not specified) #### Response Example (None) ### Parameters - **source**: Source to load from (type: Source) - **memory**: Force open via memory (type: bool) - **access**: Required access pattern for this file (type: Union[str, Access]) - **fail_on**: Error level to fail on (type: Union[str, FailOn]) - **flags**: enable output: Flags for this file (type: bool) ### Returns - Image or list[Image, Dict[str, mixed]] ### Raises - Error ``` -------------------------------- ### Load PDF from Source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PDF document from a source using the poppler backend. Similar to pdfload_buffer, it allows control over page, DPI, scaling, and security settings. ```python out = pyvips.Image.pdfload_source(source, page=int, n=int, dpi=float, scale=float, background=list[float], password=str, page_box=Union[str, ForeignPdfPageBox], memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` -------------------------------- ### gifload(filename, n, page, memory, access, fail_on, revalidate, flags) Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a GIF image from a file using libnsgif, with options for page selection, memory loading, access patterns, error handling, and revalidation. ```APIDOC ## gifload(filename, n, page, memory, access, fail_on, revalidate, flags) ### Description Load GIF with libnsgif. ### Method Image static method ### Parameters #### Path Parameters - **filename** (str | Path) - Required - Filename to load from - **n** (int) - Optional - Number of pages to load, -1 for all - **page** (int) - Optional - First page to load - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **revalidate** (bool) - Optional - Don't use a cached result for this operation - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response - **return value** (Image or list[Image, Dict[str, mixed]]) - The loaded GIF image(s) or image and metadata. ### Example ```python out = pyvips.Image.gifload(filename, n=int, page=int, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` ``` -------------------------------- ### ppmload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PPM image from a specified file, with options to control memory usage, access patterns, error handling, and caching. ```APIDOC ## ppmload ### Description Load ppm from file. ### Method staticmethod ### Endpoint (Not applicable, SDK method) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```python out = pyvips.Image.ppmload(filename, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` ### Response #### Success Response (200) (Not specified) #### Response Example (None) ### Parameters - **filename**: Filename to load from (type: str | Path) - **memory**: Force open via memory (type: bool) - **access**: Required access pattern for this file (type: Union[str, Access]) - **fail_on**: Error level to fail on (type: Union[str, FailOn]) - **revalidate**: Don't use a cached result for this operation (type: bool) - **flags**: enable output: Flags for this file (type: bool) ### Returns - Image or list[Image, Dict[str, mixed]] ### Raises - Error ``` -------------------------------- ### Set PATH for vips DLLs on Windows (Legacy) Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Manually add the vips binary directory to the system's PATH environment variable for older Python versions or specific configurations on Windows. ```python import os vipsbin = r'c:\vips-dev-8.16\bin' os.environ['PATH'] = vipsbin + ';' + os.environ['PATH'] ``` -------------------------------- ### gifload_buffer(buffer, n, page, memory, access, fail_on, flags) Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a GIF image from a buffer using libnsgif, with options for page selection, memory loading, access patterns, and error handling. ```APIDOC ## gifload_buffer(buffer, n, page, memory, access, fail_on, flags) ### Description Load GIF with libnsgif. ### Method Image static method ### Parameters #### Path Parameters - **buffer** (bytes) - Required - Buffer containing GIF data - **n** (int) - Optional - Number of pages to load, -1 for all - **page** (int) - Optional - First page to load - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response - **return value** (Image or list[Image, Dict[str, mixed]]) - The loaded GIF image(s) or image and metadata. ### Example ```python out = pyvips.Image.gifload_buffer(buffer, n=int, page=int, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` ``` -------------------------------- ### Create Laplacian of Gaussian Image Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Generates a Laplacian of Gaussian (LoG) image. Requires specifying the Gaussian radius (sigma) and minimum amplitude. Supports separable Gaussian generation and precision settings. ```python out = pyvips.Image.logmat(sigma, min_ampl, separable=bool, precision=Union[str, Precision]) ``` -------------------------------- ### Load GIF Image from Buffer Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a GIF image from a byte buffer using libnsgif. Similar options to file loading are available, including page selection and error handling. ```python out = pyvips.Image.gifload_buffer(buffer, n=int, page=int, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], flags=bool) ``` -------------------------------- ### Load PNG Image from File Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PNG image from a specified file path. Supports options to disable denial-of-service limits and force loading via memory. ```python out = pyvips.Image.pngload(filename, unlimited=bool, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` -------------------------------- ### grey Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Creates a grayscale ramp image of specified dimensions. ```APIDOC ## grey ### Description Make a grey ramp image. ### Method `Image.grey` ### Parameters - **width** (int) - Required - Image width in pixels - **height** (int) - Required - Image height in pixels - **uchar** (bool) - Optional - Output an unsigned char image ### Returns - Image: A new grayscale ramp image. ### Raises - Error: If an error occurs during image creation. ``` -------------------------------- ### Load PPM Image from File Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PPM image from a specified filename. Allows control over memory usage, access patterns, and error handling. ```python out = pyvips.Image.ppmload(filename, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` -------------------------------- ### Load PPM Image from Buffer Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PPM image directly from a bytes buffer. Similar to loading from a file, with options for memory, access, and error handling. ```python out = pyvips.Image.ppmload_buffer(buffer, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` -------------------------------- ### Run Test Suite with pytest Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Execute the main test suite using pytest. ```shell $ pytest ``` -------------------------------- ### Generate Fractal Surface Image Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Creates a fractal surface image. Requires width, height, and fractal dimension as parameters. ```python out = pyvips.Image.fractsurf(width, height, fractal_dimension) ``` -------------------------------- ### tonelut Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Builds a look-up table for tone manipulation. This static method allows for the creation of a tone-mapping curve based on various parameters controlling input/output ranges and curve shape. ```APIDOC ## staticmethod tonelut ### Description Build a look-up table for tone manipulation. ### Method staticmethod ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **in_max** (int) - Required - Size of LUT to build - **out_max** (int) - Required - Maximum value in output LUT - **Lb** (float) - Required - Lowest value in output - **Lw** (float) - Required - Highest value in output - **Ps** (float) - Required - Position of shadow - **Pm** (float) - Required - Position of mid-tones - **Ph** (float) - Required - Position of highlights - **S** (float) - Required - Adjust shadows by this much - **M** (float) - Required - Adjust mid-tones by this much - **H** (float) - Required - Adjust highlights by this much ### Response #### Success Response (200) - **Image** - The generated look-up table as an Image object. #### Response Example ``` out = pyvips.Image.tonelut(in_max=int, out_max=int, Lb=float, Lw=float, Ps=float, Pm=float, Ph=float, S=float, M=float, H=float) ``` ``` -------------------------------- ### pyvips.Image.matrixload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a matrix from a file with various options. ```APIDOC ## pyvips.Image.matrixload ### Description Load matrix from a file. Supports options for memory usage, access patterns, failure conditions, and revalidation. ### Parameters #### Path Parameters - **filename** (str | Path) - Required - Filename to load from #### Query Parameters - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **revalidate** (bool) - Optional - Don't use a cached result for this operation - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response (200) - **Image or list[Image, Dict[str, mixed]]** - The loaded matrix as an image or a list containing the image and associated metadata. ### Raises - **Error** ``` -------------------------------- ### Load Image from Source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a vips image from a given source object. This method is flexible for loading from different data sources. ```python out = pyvips.Image.vipsload_source(source, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], flags=bool) ``` -------------------------------- ### Render Text to Image Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Creates an image from a given text string. Allows customization of font, size, alignment, and wrapping. ```python out = pyvips.Image.text(text, font=str, width=int, height=int, align=Union[str, Align], justify=bool, dpi=int, spacing=int, fontfile=str, rgba=bool, wrap=Union[str, TextWrap], autofit_dpi=bool) ``` -------------------------------- ### Run Operation Call Benchmarks Source: https://github.com/libvips/pyvips/blob/master/tests/perf/README.rst Executes a benchmark specifically for operation calls and analyzes the results. ```bash $ python3 operation-call.py -o operation-call.json $ python3 -m pyperf stats operation-call.json ``` -------------------------------- ### analyzeload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads an Analyze6 image file. ```APIDOC ## analyzeload ### Description Loads an Analyze6 image file. ### Method Image.analyzeload(filename, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool, flags=bool) ### Parameters #### Path Parameters - **filename** (str | Path) - Required - Filename to load from. - **memory** (bool) - Optional - Force open via memory. - **access** (Union[str, Access]) - Optional - Required access pattern for this file. - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on. - **revalidate** (bool) - Optional - Don't use a cached result for this operation. - **flags** (bool) - Optional - Enable output: Flags for this file. ### Response #### Success Response - **return value** (Image or list[Image, Dict[str, mixed]]) - The loaded image or a list containing the image and metadata. ### Example ```python out = pyvips.Image.analyzeload(filename, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` ``` -------------------------------- ### pyvips.Image.text Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Creates an image from rendered text, with options for font, size, alignment, and wrapping. ```APIDOC ## pyvips.Image.text ### Description Creates an image from rendered text with extensive formatting options. ### Method (Not specified, likely a static method call) ### Endpoint (Not applicable, SDK method) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters - **text**: Text to render (str) - **font**: Font to render with (str) - **width**: Maximum image width in pixels (int) - **height**: Maximum image height in pixels (int) - **align**: Align on the low, centre or high edge (Union[str, Align]) - **justify**: Justify lines (bool) - **dpi**: DPI to render at (int) - **spacing**: Line spacing (int) - **fontfile**: Load this font file (str) - **rgba**: Enable RGBA output (bool) - **wrap**: Wrap lines on word or character boundaries (Union[str, TextWrap]) - **autofit_dpi**: Enable output: DPI selected by autofit (bool) ### Response #### Success Response - Returns an Image object or a list containing an Image and a dictionary of mixed types. #### Response Example (Not specified) ``` -------------------------------- ### pyvips.Image.pdfload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a PDF document from a file using the poppler library. Supports page selection, DPI, scaling, and background color. ```APIDOC ## pyvips.Image.pdfload ### Description Loads a PDF document from a file using the poppler library. Supports page selection, DPI, scaling, and background color. ### Method staticmethod ### Parameters #### Path Parameters - **filename** (str | Path) - Required - Filename to load from #### Query Parameters - **page** (int) - Optional - First page to load - **n** (int) - Optional - Number of pages to load, -1 for all - **dpi** (float) - Optional - DPI to render at - **scale** (float) - Optional - Factor to scale by - **background** (list[float]) - Optional - Background colour - **password** (str) - Optional - Password to decrypt with - **page_box** (Union[str, ForeignPdfPageBox]) - Optional - The region of the page to render - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **revalidate** (bool) - Optional - Don't use a cached result for this operation - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response - **Image or list[Image, Dict[str, mixed]]** - The loaded image or a list containing the image and metadata. #### Error Handling - **Error** - Raises an error if loading fails. ``` -------------------------------- ### Load JPEG from Source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a JPEG image from a given source object. Similar to buffer loading, it allows control over shrinking, rotation, processing limits, memory, access, and error handling. ```python out = pyvips.Image.jpegload_source(source, shrink=int, autorotate=bool, unlimited=bool, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn]) ``` -------------------------------- ### pyvips.Image.openexrload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads an image from an OpenEXR file. Supports memory-based loading and various access patterns. ```APIDOC ## pyvips.Image.openexrload ### Description Loads an image from an OpenEXR file. Supports memory-based loading and various access patterns. ### Method staticmethod ### Parameters #### Path Parameters - **filename** (str | Path) - Required - Filename to load from #### Query Parameters - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **revalidate** (bool) - Optional - Don't use a cached result for this operation - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response - **Image or list[Image, Dict[str, mixed]]** - The loaded image or a list containing the image and metadata. #### Error Handling - **Error** - Raises an error if loading fails. ``` -------------------------------- ### Set PATH for vips DLLs on Windows (Modern) Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Configure the DLL search path for vips on Windows for Python 3.8 and later using os.add_dll_directory. This is a safer method than modifying PATH directly. ```python import os vipsbin = r'c:\vips-dev-8.16\bin' add_dll_dir = getattr(os, 'add_dll_directory', None) if callable(add_dll_dir): add_dll_dir(vipsbin) else: os.environ['PATH'] = os.pathsep.join((vipsbin, os.environ['PATH'])) ``` -------------------------------- ### pyvips.Image.openslideload Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads an image using the OpenSlide library. Allows specifying level, cropping, and associated image loading. ```APIDOC ## pyvips.Image.openslideload ### Description Loads an image using the OpenSlide library. Allows specifying level, cropping, and associated image loading. ### Method staticmethod ### Parameters #### Path Parameters - **filename** (str | Path) - Required - Filename to load from #### Query Parameters - **level** (int) - Optional - Load this level from the file - **autocrop** (bool) - Optional - Crop to image bounds - **associated** (str) - Optional - Load this associated image - **attach_associated** (bool) - Optional - Attach all associated images - **rgb** (bool) - Optional - Output RGB (not RGBA) - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **revalidate** (bool) - Optional - Don't use a cached result for this operation - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response - **Image or list[Image, Dict[str, mixed]]** - The loaded image or a list containing the image and metadata. #### Error Handling - **Error** - Raises an error if loading fails. ``` -------------------------------- ### Load Image from File Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a vips image from a specified file path. Supports various loading options like memory access and error handling. ```python out = pyvips.Image.vipsload(filename, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool, flags=bool) ``` -------------------------------- ### Create Ideal Band Filter Image Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Generates an ideal band filter image. Use this to create frequency-domain filters. ```python out = pyvips.Image.mask_ideal_band(width, height, frequency_cutoff_x, frequency_cutoff_y, radius, uchar=bool, nodc=bool, reject=bool, optical=bool) ``` -------------------------------- ### pyvips.Image.matrixload_source Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Loads a matrix from a source with various options. ```APIDOC ## pyvips.Image.matrixload_source ### Description Load matrix from a source. Supports options for memory usage, access patterns, and failure conditions. ### Parameters #### Path Parameters - **source** (Source) - Required - Source to load from #### Query Parameters - **memory** (bool) - Optional - Force open via memory - **access** (Union[str, Access]) - Optional - Required access pattern for this file - **fail_on** (Union[str, FailOn]) - Optional - Error level to fail on - **flags** (bool) - Optional - enable output: Flags for this file ### Response #### Success Response (200) - **Image or list[Image, Dict[str, mixed]]** - The loaded matrix as an image or a list containing the image and associated metadata. ### Raises - **Error** ``` -------------------------------- ### Load JPEG-XL Image from File Source: https://github.com/libvips/pyvips/blob/master/doc/vimage.rst Use `jxlload` to load a JPEG-XL image from a specified file path. Supports various options for page selection, memory handling, access patterns, and error handling. ```python out = pyvips.Image.jxlload(filename, page=int, n=int, memory=bool, access=Union[str, Access], fail_on=Union[str, FailOn], revalidate=bool) ``` -------------------------------- ### Regenerate Autodocs Source: https://github.com/libvips/pyvips/blob/master/doc/README.rst Generate autodocs by running a Python command and copying the output to the documentation file. ```shell $ cd doc; \ python3 -c "import pyvips; pyvips.Operation.generate_sphinx_all()" > x ``` -------------------------------- ### Create Convolution Mask and Apply Source: https://github.com/libvips/pyvips/blob/master/doc/intro.rst Creates a convolution mask from a list of lists and applies it to the image. The scale parameter divides the result after integer convolution. ```python mask = pyvips.Image.new_from_list([[-1, -1, -1], [-1, 16, -1], [-1, -1, -1] ], scale=8) image = image.conv(mask, precision='integer') ```