Light.SDK
1.0.0
See the version list below for details.
dotnet add package Light.SDK --version 1.0.0
NuGet\Install-Package Light.SDK -Version 1.0.0
<PackageReference Include="Light.SDK" Version="1.0.0" />
<PackageVersion Include="Light.SDK" Version="1.0.0" />
<PackageReference Include="Light.SDK" />
paket add Light.SDK --version 1.0.0
#r "nuget: Light.SDK, 1.0.0"
#:package Light.SDK@1.0.0
#addin nuget:?package=Light.SDK&version=1.0.0
#tool nuget:?package=Light.SDK&version=1.0.0
Light.SDK
Light.SDK is a production-grade .NET SDK for ID photo processing and generation. It provides a clean high-level API for photo matting, background composition, crop layout rules, beauty enhancement, watermarking, printable sheets, template overlays, and export policies.
Why Light.SDK
- Production-focused API surface with fluent request configuration.
- Flexible runtime model loading (external models, no heavyweight NuGet payload).
- Multiple output targets: standard, HD, layout sheet, template render.
- Dynamic template workflow for built-in and user-uploaded templates.
- Designed for app teams shipping desktop, server, and cloud workflows.
Core Features
- ID photo generation with face-aware framing.
- Background matting and color replacement (solid and gradients).
- Face alignment and top-distance/head-ratio controls.
- Beauty pipeline (whitening, brightness, contrast, saturation, sharpen).
- Watermark rendering with rotation, opacity, spacing, and color controls.
- Printable layout sheet generation with cut lines.
- Template rendering similar to Python template plugin behavior.
- Export options for JPEG/PNG, DPI scaling, and target-size compression.
- Strongly-typed presets for size and model selection.
Install from NuGet
dotnet add package Light.SDK
Download Models from GitHub Releases
Light.SDK NuGet package is intentionally lightweight and does not include model binaries.
Create a release workflow like this in your GitHub repository:
- Publish Light.SDK to NuGet.
- Upload model bundle zip files to GitHub Releases.
- Ask users to download the matching model bundle version.
Recommended release asset naming:
- light-sdk-models-v2.0.0.zip
- light-sdk-templates-v2.0.0.zip (optional)
Recommended extracted model folder structure:
models/
detector models/
Light_faceDetect.lsdkm
matting models/
Light.lite.lsdkm
Light.Huma.lsdkm
Light.M01.lsdkm
...
Quick Start
using Light.SDK;
using HivisionIDPhotos.Core.Models.Sdk;
var options = new IdCreatorOptions
{
// Host-managed model root (downloaded from your GitHub Releases).
ModelsRootPath = @"D:\light-sdk\models"
};
using var creator = new IdCreator(options);
var result = creator.CreateFromFile("input.jpg", cfg => cfg
.WithSizePreset(IdPhotoSizePreset.AmericanVisa)
.WithBackgroundColor("FFFFFF")
.WithModels(FaceDetectionModelPreset.LightFaceDetect, MattingModelPreset.LightLite)
.WithFaceLayout(headRatio: 0.2, topDistance: 0.12, faceAlign: true)
.WithBeauty(whitening: 2, brightness: 3, contrast: 3, saturation: 2, sharpen: 1)
.WithWatermark(text: "Light SDK", fontSize: 18, opacity: 0.15, angle: 30, colorHex: "8A8A8A", space: 30)
.TryTemplate("template_1", "templates")
.WithLayoutSheet(LayoutPaperKind.FiveInch, dpi: 300)
.WithStandardExport(OutputImageFormat.Jpeg, dpi: 300)
.WithHdExport(OutputImageFormat.Jpeg, dpi: 300)
.WithLayoutExport(OutputImageFormat.Jpeg, dpi: 300));
File.WriteAllBytes("output_standard.jpg", result.StandardImageBytes);
File.WriteAllBytes("output_hd.jpg", result.HdImageBytes);
if (result.LayoutImageBytes is not null) File.WriteAllBytes("output_layout.jpg", result.LayoutImageBytes);
if (result.TemplateImageBytes is not null) File.WriteAllBytes("output_template.jpg", result.TemplateImageBytes);
Dynamic Path Resolution
Models
Model resolution order:
- IdCreatorOptions.RetinaFaceModelPath and IdCreatorOptions.MattingModelsDirectory
- IdCreatorOptions.ModelsRootPath
- Environment variables RETINAFACE_MODEL_PATH and MATTING_MODEL_DIR
- Runtime auto-discovery near application base directory
Templates
Template assets resolution order:
- TryTemplate(templateName, assetsDirectory)
- Environment variable LIGHT_TEMPLATE_ASSETS_DIR
- Default AppContext.BaseDirectory
Expected template assets in selected directory:
- template_config.json
- template_1.png, template_2.png, ...
Pack and Publish
Pack SDK:
dotnet pack HivisionIDPhotos-CSharp/Light.SDK/Light.SDK.csproj -c Release
Push package:
dotnet nuget push HivisionIDPhotos-CSharp/Light.SDK/bin/Release/Light.SDK.2.0.0.nupkg --api-key <NUGET_API_KEY> --source https://api.nuget.org/v3/index.json
Publish model bundle to GitHub Releases as separate artifact zip.
Final Release Checklist
- Set real repository URLs in project metadata before publishing.
- Bump package version in csproj.
- Build and run sample.
- Pack and push NuGet package.
- Publish GitHub release assets for models and templates.
- Confirm LICENSE and copyright metadata are present.
See full operational flow in COMPLETE_SDK_GUIDE.md.
Documentation Map
- Architecture: ARCHITECTURE.md
- End-to-end release and distribution: COMPLETE_SDK_GUIDE.md
- Full docs index: docs/README.md
| Product | Versions 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. |
-
net10.0
- FaceONNX (>= 4.1.1.3)
- Microsoft.ML.OnnxRuntime (>= 1.24.4)
- OpenCvSharp4 (>= 4.13.0.20260330)
- OpenCvSharp4.runtime.win (>= 4.13.0.20260302)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Unrestricted production SDK. Models are external and provided by host applications via IdCreatorOptions model paths.