Home

Awesome

<img src="docs/jpeg_ls_logo.png" alt="JPEG-LS Logo" width="100"/>

CharLS .NET

License Build and Test Coverage Status NuGet

CharLS .NET is a C# JPEG-LS library implementation.
JPEG-LS (ISO-14495-1) is a lossless/near-lossless compression standard for continuous-tone images.

Features

Performance

A couple of benchmarks have been executed to assist to decide which codec to use. The following codecs were measured:

CodecVersionRelease dateDescription
CharLS.Managed0.8.02024-08-23C# implementation
CharLS.Native3.2.02023-09-24C# wrapper around C++ implementation
cscharls0.1.12017-04-24C# implementation
charls-js2.1.12021-10-07WebAssembly implementation based on C++ source

and the following test images were used:

Image nameWidthHeightBits per sampleComponentsDescription
Tulips51251281Monochrome image of tulips
MG130644664121Monochrome medical image
Delta E3072204883Artificial RGB image

The benchmarks were performed on 2 hardware platforms: x86 and ARM64.
The column 'NEAR' defines the allowed error, 0 means lossless encoding.
The column 'ILV' defines the interleave mode used to encode the image.

x86-64 Platform

Characteristics of the test environment: AMD Ryzen 9 5950X, .NET 8.0.8 (X64 RyuJIT AVX2)
WebAssembly engine: Chrome V8 12.8.374.21

OperationNEARILVCharLS.ManagedCharLS.Nativecscharlscharls-js
Decode Tulips0None5.0 ms3.6 ms10.4 ms5.6 ms
Decode MG10None292.3 ms205.0 ms676.3 ms335.2 ms
Decode Delta E0Sample80.0 ms89.4 ms-89.5 ms
Encode Tulips0None7.1 ms4.7 ms11.8 ms-
Encode MG10None404.3 ms256.3 ms695.8 ms-

Arm64 Platform

Characteristics of the test environment: Snapdragon Compute Platform, .NET 8.0.8 (Arm64 RyuJIT AdvSIMD)
WebAssembly engine: Chrome V8 12.8.374.21

OperationNEARILVCharLS.ManagedCharLS.Nativecscharlscharls-js
Decode Tulips0None7.2 ms4.7 ms14.3 ms10.5 ms
Decode MG10None431.7 ms261.8 ms1019.4 ms542.1 ms
Encode Tulips0None9.6 ms5.5 ms15.7 ms-
Encode MG10None564.0 ms318.6 ms1017.2 ms-

How to use

CharLS.Managed can be added to your C# project using the dotnet command line or the NuGet Package Manager in Visual Studio.

Install using the dotnet command line

dotnet add package CharLS.Managed

How to use the C# classes in the NuGet package

A sample application is included in the GitHub repository that demonstrates how to convert common image types like .bmp, .png and .jpg to .jls (JPEG-LS).

General steps to build this repository

 git clone https://github.com/team-charls/charls-dotnet.git

Code signing the assembly and the NuGet package

Building the NuGet package with a signed assembly DLL and NuGet package can only be done on the Window platform with Visual Studio 2022 or with Build tools for Visual Studio 2022. To support code signing with a code signing certificate, stored on a smart card, a Windows command file is available: create-signed-nuget-package.cmd. Instructions:

All assembly DLLs and the NuGet package itself will be signed.

About the JPEG-LS image compression standard

More information about JPEG-LS can be found in the README from the C++ CharLS project.