turbojpeg-sys

Raw Rust bindings for the turbojpeg library. If you want to work with JPEG files in Rust, you should use the high-level bindings from the turbojpeg crate.

Building

We support multiple options for building the native TurboJPEG library and linking to it. There are three aspects that you can control:

Source

TurboJPEG is written in C, so we must either compile it ourselves, or look up a compiled library on your system. You can control what we do using TURBOJPEG_SOURCE environment variable:

Linking

We can link the compiled library from the previous step to your Rust executable either statically (the library becomes part of the executable) or dynamically (the library is looked up at runtime). You can control this using environment variables:

If you don't specify any of these variables, the default behavior depends on TURBOJPEG_SOURCE. If TURBOJPEG_SOURCE is vendor or explicit, we link statically by default. However, if you use pkg-config, we let the pkg-config crate decide; it typically uses dynamic linking by default.

Binding

To use the C library in Rust, we need some boilerplate "binding" code that exports C symbols (functions and variables) into Rust. We have two options and you control the decision with the TURBOJPEG_BINDING environment variable:

Features

This crate supports multiple features:

Note that the turbojpeg crate "reexports" these features.