dlib is a general-purpose library for D language. It implements such common functionality as image manipulation, OpenGL-friendly linear algebra, threading, stream-based I/O, memory management, async event loop, etc. dlib is an ideal solution for writing game engines and rendering pipelines, building simple web apps, quickly prototyping new ideas and algorithms.

dlib is cross-platform, it supports Windows, Linux, OSX and FreeBSD. It is fully written in D2 and has no external dependencies aside D's standard library, Phobos.

Currently dlib contains the following packages:

  • dlib.async - event loop and asynchronous programming capabilities
  • dlib.core - basic functionality used by other modules (manual memory management, streams, OOP for structs, etc.)
  • dlib.container - generic data structures (GC-free dynamic and associative arrays and more)
  • dlib.filesystem - abstract FS interface and its implementations for Windows and POSIX filesystems
  • dlib.functional - some functional programming idioms (HOFs, combiners, quantifiers, etc.)
  • dlib.math - linear algebra and numerical analysis (vectors, matrices, quaternions, linear system solvers etc.)
  • dlib.geometry - computational geometry (ray casting, primitives, intersection, etc.)
  • dlib.image - image processing (8-bit, 16-bit and 32-bit floating point channels, common filters and convolution kernels, resizing, FFT, HDRI, animation, graphics formats I/O: JPEG, PNG/APNG, BMP, TGA, HDR)
  • dlib.audio - sound processing (8 and 16 bits per sample, synthesizers, WAV export and import)
  • dlib.network - networking and web functionality
  • dlib.memory - allocators and memory management functions
  • dlib.text - text processing
  • dlib.serialization - data serialization (currently includes lightweight XML parser)
  • dlib.coding - various data compression and coding algorithms


Head on to releases page and get the latest source tarball. You may also use dub package instead - add the following dependency to your dub.json:

"dlib": "0.12.1"


Load PNG image and save its resized copy:

import dlib;

void main()
    loadPNG("input.png").resampleBilinear(240, 320).savePNG("output.png");

Transform a vector with 4x4 affine matrix:

import dlib;

void main()
    Vector3f v1 = Vector3f(1, 0, 0);
    Vector3f v2 = v1 * translationMatrix(Vector3f(0, 2, 0));


Refer to GitHub wiki. Be aware that documentation is currently incomplete. For support and overall discussions, use our Gitter chat room.


dlib is distributed under the Boost Software License, Version 1.0. You are free to use, copy, modify and redistribute dlib, even in closed-source products. The only requirement is to keep the license and copyright notice in all source code copies.

Found a bug?

Please, create an issue here. Fixing pull requests are welcome.

Worth checking out

  • DGL and Dagon, 3D game frameworks using dlib
  • dmech, a physics engine built on top of dlib.math and dlib.geometry
  • Atrium, a game that uses dlib, DGL and dmech
  • DlangUI, native UI toolkit for D - uses dlib.image
  • Voxelman, voxel game engine - uses dlib.image and dlib.math
  • dlib-webp, WebP loader for dlib.image.