All Projects → johannesvollmer → exrs

johannesvollmer / exrs

Licence: other
100% Safe Rust OpenEXR file library

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to exrs

loadkit
Java 资源加载器,充分拓展ClassLoader#getResources(name)的能力,实现递归加载,支持普通风格 / 包名风格 / ANT风格 / 正则风格路径的资源加载同时支持自定义过滤器,通常作为框架的基础类库。
Stars: ✭ 39 (-50.63%)
Mutual labels:  file
MagicaVoxel File Writer
MagicaVoxel File Writer dependency free cpp class
Stars: ✭ 26 (-67.09%)
Mutual labels:  file
codeceptjs-bdd
Javascript BDD UI Automation Framework. Exclusive LWC Shadow DOM Support. Playwright, Webdriver.io, Appium, Saucelabs.
Stars: ✭ 35 (-55.7%)
Mutual labels:  parallel
ElegantData
像操作Room一样操作 SharedPreferences 和 File 文件.
Stars: ✭ 18 (-77.22%)
Mutual labels:  file
esp-idf-parallel-tft
8bit parallel TFT & 4-line resistance touch screen Driver for esp-idf using i2s paralell mode
Stars: ✭ 45 (-43.04%)
Mutual labels:  parallel
gh fsync
🔄 GitHub action to sync files across repos in GitHub
Stars: ✭ 17 (-78.48%)
Mutual labels:  file
twitch-irc-rs
Twitch IRC library for the Rust programming language
Stars: ✭ 58 (-26.58%)
Mutual labels:  crate
opentab
开源的轻应用后端(Open Tiny App Backend),轻量,高效,易部署。
Stars: ✭ 27 (-65.82%)
Mutual labels:  file
cephgeorep
An efficient unidirectional remote backup daemon for CephFS.
Stars: ✭ 27 (-65.82%)
Mutual labels:  parallel
cache
🥌 Deno cache library
Stars: ✭ 38 (-51.9%)
Mutual labels:  file
kafka-workers
Kafka Workers is a client library which unifies records consuming from Kafka and processing them by user-defined WorkerTasks.
Stars: ✭ 30 (-62.03%)
Mutual labels:  parallel
lumen-file-manager
File manager module for the Lumen PHP framework.
Stars: ✭ 40 (-49.37%)
Mutual labels:  file
react-file-input-previews-base64
This package provides an easy to use, ready to go and customizable wrapper around file input, with option for image previews and returning file as base64 string.
Stars: ✭ 15 (-81.01%)
Mutual labels:  file
mat-file-upload
A simple & configurable Angular Material file upload component.
Stars: ✭ 14 (-82.28%)
Mutual labels:  file
ansible-role-glusterfs
Ansible Role - GlusterFS
Stars: ✭ 95 (+20.25%)
Mutual labels:  file
open-ops
Open Optimizing Parallelizing System
Stars: ✭ 21 (-73.42%)
Mutual labels:  parallel
ProtoPromise
Robust and efficient library for management of asynchronous operations in C#/.Net.
Stars: ✭ 20 (-74.68%)
Mutual labels:  parallel
semicon
A collection of icons for the Semantic Web and Linked Open Data world.
Stars: ✭ 20 (-74.68%)
Mutual labels:  file
ZFileManager
Android 文件操作
Stars: ✭ 124 (+56.96%)
Mutual labels:  file
lfimg
Image preview support for lf (list files) using Überzug
Stars: ✭ 174 (+120.25%)
Mutual labels:  file

Rust Docs Crate Crate Rust Lang Version Lines of Code

EXRS

This library is a 100% Rust and 100% safe code library for reading and writing OpenEXR images.

OpenEXR is the de-facto standard image format in animation, VFX, and other computer graphics pipelines, for it can represent an immense variety of pixel data with lossless compression.

Features include:

  • any number of layers placed anywhere in 2d space, like in Photoshop
  • any set of channels in an image (rgb, xyz, lab, depth, motion, mask, anything, ...)
  • three types of high dynamic range values (16bit float, 32bit float, 32bit unsigned integer) per channel
  • uncompressed pixel data for fast file access
  • lossless compression for any image type
  • lossy compression for non-deep image types to produce very small files
  • load specific sections of an image without processing the whole file
  • compress and decompress image pixels on multiple threads in parallel
  • add arbitrary meta data to any image, including custom byte data, with full backwards compatibility
  • any number of samples per pixel ("deep data") (not yet supported)

Current Status

This library has matured quite a bit, but should still be considered incomplete. For example, deep data and DWA compression algorithms are not supported yet.

If you encounter an exr file that cannot be opened by this crate but should be, please leave an issue on this repository, containing the image file.

The focus is set on supporting all feature and correctness; some performance optimizations are to be done.

What we can do:

  • Supported OpenEXR Features
    • custom attributes
    • multi-part images (multiple layers, like Photoshop)
    • multi-resolution images (mip maps, rip maps)
    • access meta data and raw pixel blocks independently
    • automatically crop away transparent pixels of an image (opt-in)
    • channel subsampling
    • deep data
    • compression methods
      • uncompressed
      • zip line (lossless)
      • zip block (lossless)
      • rle (lossless)
      • piz (lossless) (huge thanks to @dgsantana)
      • pxr24 (lossless for f16 and u32)
      • b44, b44a (huge thanks to @narann)
      • dwaa, dwab (help wanted)

Big-endian code is not yet fully implemented. Help wanted.

  • Nice Things
    • no unsafe code, no undefined behaviour
    • no compiling C++, no configuring CMake, no setting up external dependencies or environment variables
    • re-imagined exr api with low barrier of entry (see read_rgba_file, write_rgba_file, read_all_data_from_file), plus embracing common high-level Rust abstractions
    • a full-fledged image data structure that can contain any exr image, can open any image with a single function call (read_all_data_from_file) without knowing anything about the file in advance
    • decompress and decompress image sections either in parallel or with low memory overhead
    • read and write progress callback
    • write blocks streams, one after another
    • memory mapping automatically supported by using the generic std::io::Read and std::io::Write traits

Usage

Add this to your Cargo.toml:

[dependencies]
exr = "1.4.2"

# also, optionally add this to your crate for smaller binary size 
# and better runtime performance
[profile.release]
lto = true

The master branch of this repository always matches the crates.io version, so you could also link the github repository master branch.

Example

Example: generate an rgb exr file.

extern crate exr;

/// To write your image data, you need to specify how to retrieve a single pixel from it.
/// The closure may capture variables or generate data on the fly.
fn main() {
    use exr::prelude::*;

    // write a file, with 32-bit float precision per channel
    write_rgba_file(

        // this accepts paths or &str
        "minimal_rgba.exr",

        // image resolution is 2k
        2048, 2048,

        // generate (or lookup in your own image)
        // an f32 rgb color for each of the 2048x2048 pixels
        |x,y| {
            (
                x as f32 / 2048.0, // red
                y as f32 / 2048.0, // green
                1.0 - (y as f32 / 2048.0), // blue
                1.0 // alpha
            )
        }

    ).unwrap();
}

See the the examples folder for more examples.

Or read the guide.

Motivation

Using Rust bindings to a C++ library unfortunately requires compiling one or more C++ Libraries and possibly setting environment variables, which I didn't quite feel like to do, so I wrote this library instead.

Also, I really wanted to have a library which had an 'X' in its name in my git repositories.

Goals

exrs aims to provide a safe and convenient interface to the OpenEXR file format. It is designed to minimize the possibility of invalid files and runtime errors. It contains a full-fledged image data structure that can contain any exr image, but also grants access a low level block interface.

This library does not try to be a general purpose image file or image processing library. Therefore, color conversion, beautiful subsampling, and mip map generation are left to other crates for now. As the original OpenEXR implementation supports those operations, this library may choose to support them later. Furthermore, this implementation does not try to produce byte-exact file output matching the original implementation, instead, it is only aimed for correct output.

Safety

This library uses no unsafe code. In fact, this crate is annotated with #[forbid(unsafe_code)]. Some dependencies use unsafe code, though this is minimized by selecting dependencies carefully.

All information from a file is handled with caution. Allocations have a safe maximum size that will not be exceeded at once, to reduce memory exhaustion attacks.

What I am proud of

  • Flexible API (choose how to store your data instead of receiving an allocated image)
  • Safe API (almost impossible to accidentally write invalid files)
  • This is a pretty detailed README, yay
  • Awesome Contributors!

Running Tests

To run all fast tests, use cargo test. To start fuzzing indefinitely, use cargo test --package exr --test fuzz fuzz -- --exact --ignored.

Specification

This library is modeled after the official OpenEXRFileLayout.pdf document. Unspecified behavior is concluded from the C++ library.

PRIORITIES

  1. Support all compression formats
  2. Support Deep Data
  3. Simple rendering of common image formats
  4. Profiling and other optimization
  5. Tooling (Image Viewer App)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].