Olve.OpenRaster 0.38.0

dotnet add package Olve.OpenRaster --version 0.38.0
                    
NuGet\Install-Package Olve.OpenRaster -Version 0.38.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Olve.OpenRaster" Version="0.38.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Olve.OpenRaster" Version="0.38.0" />
                    
Directory.Packages.props
<PackageReference Include="Olve.OpenRaster" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Olve.OpenRaster --version 0.38.0
                    
#r "nuget: Olve.OpenRaster, 0.38.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Olve.OpenRaster@0.38.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Olve.OpenRaster&version=0.38.0
                    
Install as a Cake Addin
#tool nuget:?package=Olve.OpenRaster&version=0.38.0
                    
Install as a Cake Tool

Olve.OpenRaster

NuGet Docs

Lightweight, read-only access to OpenRaster (.ora) files in native C#. OpenRaster is a layered image format used by digital painting applications like GIMP and Krita.


Installation

dotnet add package Olve.OpenRaster

Overview

Type Description
ReadOpenRasterFile Reads an .ora file and returns an OpenRasterFile model with all metadata, layers, and groups.
ReadLayerAs<T> Loads a specific layer's image data and parses it into a custom type T via an ILayerParser<T>.
ILayerParser<T> Interface for converting a layer's byte stream into T. Bring your own image library.
OpenRasterFile Top-level model: format version, canvas dimensions, resolution, layers, and groups.
Layer Layer metadata: name, source path, opacity, position, visibility, blend mode, and parent groups.
Group Group (stack) metadata: name, visibility, opacity, blend mode, and contained layers.
CompositeOperation Blending/compositing mode combining a BlendingFunction and CompositingOperator.

Usage

Reading an OpenRaster file

ReadOpenRasterFile opens an .ora file, parses stack.xml, and returns the full layer hierarchy.

// ../../tests/Olve.OpenRaster.Tests/ReadmeDemo.cs#L13-L22

var operation = new ReadOpenRasterFile();
var request = new ReadOpenRasterFile.Request(filePath);

var result = operation.Execute(request);
if (result.TryPickValue(out var file, out var problems))
{
    Console.WriteLine($"Version: {file.Version}");
    Console.WriteLine($"Canvas: {file.Width}x{file.Height} @ {file.XResolution} DPI");
    Console.WriteLine($"Layers: {file.Layers.Count}, Groups: {file.Groups.Count}");
}

Inspecting layers and groups

Each Layer carries its metadata from the .ora file. Layers track which Groups they belong to, and groups track their contained Layers.

// ../../tests/Olve.OpenRaster.Tests/ReadmeDemo.cs#L39-L50

foreach (var layer in file!.Layers)
{
    Console.WriteLine($"  {layer.Name} ({layer.Source})");
    Console.WriteLine($"    opacity={layer.Opacity}, visible={layer.Visible}");
    Console.WriteLine($"    position=({layer.X}, {layer.Y})");
    Console.WriteLine($"    blend={layer.CompositeOperation.Key}");
}

foreach (var group in file.Groups)
{
    Console.WriteLine($"  Group: {group.Name} ({group.Layers.Count} layers)");
}

Reading a layer image

The library does not bundle an image decoder. Instead, ReadLayerAs<T> delegates to your ILayerParser<T> implementation, so you can use whichever image library you prefer.

For example, using the BigGustave PNG library:

// ../../tests/Olve.OpenRaster.Tests/ReadmeDemo.cs#L142-L151

public class PngLayerParser : ILayerParser<Png>
{
    public Result<Png> ParseLayer(Stream stream)
    {
        var ms = new MemoryStream();
        stream.CopyTo(ms);
        ms.Position = 0;
        return Png.Open(ms);
    }
}

Then read a specific layer by its source path (found on Layer.Source):

// ../../tests/Olve.OpenRaster.Tests/ReadmeDemo.cs#L63-L70

var parser = new PngLayerParser();
var request = new ReadLayerAs<Png>.Request(filePath, "data/layer0.png", parser);

var result = new ReadLayerAs<Png>().Execute(request);
if (result.TryPickValue(out var png, out _))
{
    Console.WriteLine($"Layer image: {png.Width}x{png.Height}");
}

Composite operations

Each layer and group carries a CompositeOperation describing how it blends with layers beneath it. A CompositeOperation combines a BlendingFunction (how colors mix) with a CompositingOperator (how alpha channels interact), following the W3C Compositing and Blending specification.

All standard OpenRaster blend modes are supported:

Blend modes Compositing modes
SrcOver, Multiply, Screen, Overlay Plus
Darken, Lighten, ColorDodge, ColorBurn DestinationIn, DestinationOut
HardLight, SoftLight, Difference SourceAtop, DestinationAtop
Color, Luminosity, Hue, Saturation

You can also parse a composite operation from its SVG key string:

// ../../tests/Olve.OpenRaster.Tests/ReadmeDemo.cs#L81-L86

var result = CompositeOperation.FromKey("svg:multiply");
if (result.TryPickValue(out var op, out _))
{
    Console.WriteLine(op.BlendingFunction);    // Multiply
    Console.WriteLine(op.CompositingOperator); // SourceOver
}

Error handling

All operations return Result<T> from Olve.Results instead of throwing exceptions. Use TryPickValue or TryPickProblems to inspect outcomes:

// ../../tests/Olve.OpenRaster.Tests/ReadmeDemo.cs#L95-L103

var operation = new ReadOpenRasterFile();
var request = new ReadOpenRasterFile.Request("/nonexistent/file.ora");

var result = operation.Execute(request);
if (result.TryPickProblems(out var problems))
{
    foreach (var problem in problems)
        Console.WriteLine(problem.Message);
}

Documentation

Full API reference: https://olivervea.github.io/Olve.Utilities/api/Olve.OpenRaster.html


License

MIT License © OliverVea

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.38.0 181 2/19/2026
0.37.2 81 2/18/2026
0.37.1 87 2/18/2026
0.1.5 684 3/18/2025
0.1.4 136 3/15/2025
0.1.3 129 3/15/2025
0.1.2 129 3/15/2025
0.1.1 167 3/14/2025
0.1.0 173 3/14/2025