ThumbHash 2.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ThumbHash --version 2.1.0                
NuGet\Install-Package ThumbHash -Version 2.1.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="ThumbHash" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ThumbHash --version 2.1.0                
#r "nuget: ThumbHash, 2.1.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.
// Install ThumbHash as a Cake Addin
#addin nuget:?package=ThumbHash&version=2.1.0

// Install ThumbHash as a Cake Tool
#tool nuget:?package=ThumbHash&version=2.1.0                

ThumbHash

ThumbHash nuget package CI build-test-pack

This library is a .NET implementation of ThumbHash.

What is a thumbhash?

A very compact representation of a placeholder for an image. Store it inline with your data and show it while the real image is loading for a smoother loading experience.

Image ThumbHash ThumbHash Image
Flower <p>93 4A 06 2D 06 92 56 C3 74 05 58 67 DA 8A B6 67 94 90 51 07 19</p>21 bytes <img alt="Flower ThumbHash" src="/assets/flower_thumbhash_rust.png" width=75 height=100>
Tux <p>A1 19 8A 1C 02 38 3A 25 D7 27 F6 8B 97 1F F7 F9 71 7F 80 37 67 58 98 79 06</p>25 bytes <img alt="Tux ThumbHash" src="/assets/tux_thumbhash_rust.png" width=84 height=100>

See a demo of ThumbHash for .NET in Blazor here

Learn more about ThumbHashes here.

Usage

The ThumbHash library has no external dependencies and can be used on its own, or with your choice of image library (e.g., SkiaSharp, ImageSharp) for rendering.

Images must be in the format of unpremultiplied RGBA8888 before working with ThumbHash.

Convert an image into a thumbhash (SkiaSharp)

using SkiaSharp;
using ThumbHashes;

using var original = SKBitmap.Decode("original.png");
using var rgba8888 = original.Copy(SKColorType.Rgba8888);
var thumbhash = ThumbHash.FromImage(rgba8888.Width, rgba8888.Height, rgba8888.GetPixelSpan());

Load a thumbhash and render it to RGBA

using ThumbHashes;

byte[] hash = Convert.FromHexString("934A062D069256C374055867DA8AB6679490510719");
var thumbhash = new ThumbHash(hash);

var (width, height, rgba) = thumbhash.ToImage();

Save a rendered RGBA to a PNG (SkiaSharp)

using SkiaSharp;

var (width, height, rgba) = thumbhash.ToImage();
var image_info = new SKImageInfo(width, height, SKColorType.Rgba8888, SKAlphaType.Unpremul);
using var sk_img = SKImage.FromPixelCopy(image_info, rgba);
using var sk_png_data = sk_img.Encode(SKEncodedImageFormat.Png, 100);

using var fs_png = System.IO.File.Create("test.png");
sk_png_data.SaveTo(fs_png);

Save a ThumbHash to a PNG data url (no dependencies)

string dataUrl = thumbhash.ToDataUrl();
<img src="@dataUrl" />

Support

Discord

Discussion and technical support is available on Discord.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on ThumbHash:

Repository Stars
immichFrame/ImmichFrame
Version Downloads Last updated
2.1.1 6,546 9/21/2023
2.1.0 249 9/11/2023
2.0.0 537 7/26/2023
1.1.0 1,742 5/3/2023
1.0.1 198 5/1/2023
1.0.0 175 5/1/2023