weserv/images

repository·5.x·Indexed 25 days ago

https://github.com/weserv/images

A self-hostable image processing service (formerly images.weserv.nl) that allows developers to manipulate and serve images via a web interface. It features a custom Nginx module with proxy and filter modes, supporting various image formats including JPEG, WebP, AVIF, and JPEG XL. The service provides extensive configuration for image quality, compression effort, and resource limits, and can be deployed via Docker or built from source using libvips.

Tokens
3.8K
Snippets
10
Records
32
Agent score
83%

What's inside weserv/images

  1. Overview of weserv/images

    5.x
    weserv/images (formerly images.weserv.nl) is an image processing service designed to be deployed on your own servers. It provides image handling and manipulation capabilities by leveraging high-performance libraries and web server technologies.
  2. Run weserv/images using the hosted Docker image

    5.x

    You can pull and run the pre-built container from the GitHub Container Registry. This command maps TCP port 80 inside the container to port 8080 on your host and sets the shared memory size to 1GB.

    docker run -d -p 8080:80 --shm-size=1gb --name=weserv ghcr.io/weserv/images:5.x
  3. Build and install weserv/images from source

    5.x

    To build the project, clone the repository with submodules, use meson to configure and compile the build, and then install it. After installing the core project, you must build and install a custom Nginx instance configured with the project's module.

    # Build and install weserv/images
    git clone --recurse-submodules https://github.com/weserv/images.git
    cd images
    meson setup build --prefix=/usr
    meson compile -C build
    meson install -C build
    
    # Build and install custom Nginx with the module
    mkdir nginx
    curl -Ls https://nginx.org/download/nginx-1.31.2.tar.gz | \
      tar xzC nginx --strip-components=1
    cd nginx
    ./configure --add-module=../ --with-http_ssl_module
    make -j$(nproc)
    make install
  4. Install dependencies and libvips on RHEL 10

    5.x

    Follow these steps to configure repositories and install the necessary packages for weserv/images on RHEL 10 systems. This includes setting up EPEL, CodeReady Builder, Remi, and RPM Fusion repositories to ensure all required libraries (like libheif) are available.

    # Install the EPEL repository configuration package
    dnf install epel-release
    
    # Enable the CodeReady Builder repository
    crb enable
    # or:
    # subscription-manager repos --enable "codeready-builder-for-rhel-10-$(uname -m)-rpms"
    
    # Install the Remi repository configuration package
    dnf install https://rpms.remirepo.net/enterprise/remi-release-10.rpm
    
    # Install the RPM Fusion repository configuration package (for libheif)
    dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-10.noarch.rpm
    
    # Enable Remi's RPM repository
    dnf config-manager --set-enabled remi
    
    # Install libvips (+ development files and command-line tools)
    dnf install vips vips-devel vips-tools
    
    # Install optional modules
    dnf install vips-heif vips-jxl vips-magick-im7 vips-poppler
    
    # Install build requirements
    dnf group install 'Development Tools'
    dnf install meson openssl-devel pcre2-devel zlib-devel
  5. Manually build and run the weserv/images container

    5.x
    To build the container from source with a specific Nginx version, use the docker build command with the NGINX_VERSION build argument. Once built, you can run the local image using the same parameters as the hosted image.
  6. Enable the Weserv module in nginx

    5.x

    Use the weserv directive to enable the Weserv module for nginx requests. You must choose between two backend modes:

    • proxy: Processes images from a remote server specified via the ?url= query parameter.
    • filter: Processes images from responses generated by other nginx handlers (such as static content or proxied requests).
  7. Install build dependencies for RHEL 10

    5.x

    To build weserv/images from source on RHEL 10 or its derivatives, ensure the following dependencies are met:

    • meson >= 0.63
    • g++ >= 5.0
    • pcre2 (for nginx rewrite module)
    • zlib (for nginx gzip module)
    • openssl (for SSL support)
    • libvips >= 8.12
  8. Manage nginx configuration inside the container

    5.x

    Use docker exec to perform administrative tasks on the Nginx service running inside the weserv container.

    # Check nginx configuration for correct syntax
    docker exec weserv nginx -t
    
    # Reload the nginx configuration file
    docker exec weserv nginx -s reload
  9. Maintain and inspect the weserv container

    5.x

    Use these commands to manage the container environment, update packages, or inspect system settings.

    # Access the container bash shell
    docker exec -it weserv bash
    
    # Update RPM packages
    docker exec weserv dnf update -y
    
    # Check jemalloc configuration
    docker exec -e MALLOC_CONF="stats_print:true,stats_print_opts:mdablxeh" weserv bash
    
    # Access to logs
    docker logs weserv
    
    # Retrieve the container's IP Address
    docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -f name=weserv -q)
    docker inspect $(docker ps -f name=weserv -q) | grep IPAddress
  10. Configure image quality and compression effort

    5.x

    Adjust the default quality and CPU effort for various image formats. Quality values are 1-100. Effort values vary by format:

    Quality

    • weserv_quality <quality>: Default for JPEG, WebP, TIFF, AVIF, and JPEG XL. Default: 80.
    • Format-specific overrides (if weserv_quality is not set):
      • weserv_avif_quality <quality>
      • weserv_jpeg_quality <quality>
      • weserv_jxl_quality <quality>
      • weserv_tiff_quality <quality>
      • weserv_webp_quality <quality>

    Compression Effort

    • weserv_avif_effort <effort>: 0 (fastest) to 9 (slowest). Default: 4.
    • weserv_jxl_effort <effort>: 1 (fastest) to 10 (slowest). Default: 7.
    • weserv_gif_effort <effort>: 1 (fastest) to 10 (slowest). Default: 7.
    • weserv_webp_effort <effort>: 0 (fastest) to 6 (slowest). Default: 4.
    • weserv_zlib_level <level>: PNG compression level 0 (fastest) to 9 (slowest). Default: 6.