Getting Started with Blazor Image Editor Component

13 Oct 20254 minutes to read

This section explains how to include the Blazor Image Editor component in a Blazor WebAssembly app using Visual Studio and Visual Studio Code.

To get started quickly with the Blazor Image Editor component, refer to this video or the corresponding GitHub sample:

Prerequisites

Create a new Blazor app in Visual Studio

Create a Blazor WebAssembly App using Visual Studio via Microsoft templates or the Syncfusion® Blazor Extension.

Install Syncfusion® Blazor ImageEditor and themes NuGet packages

To add the Blazor Image Editor component, open the NuGet Package Manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), then search for and install Syncfusion.Blazor.ImageEditor and Syncfusion.Blazor.Themes. Alternatively, the following Package Manager commands can be used:

Install-Package Syncfusion.Blazor.ImageEditor -Version 31.2.2
Install-Package Syncfusion.Blazor.Themes -Version 31.2.2

NOTE

Syncfusion® Blazor components are available on nuget.org. Refer to the NuGet packages topic for the list of available packages with component details.

Prerequisites

Create a new Blazor app in Visual Studio Code

Create a Blazor WebAssembly App using Visual Studio Code via Microsoft templates or the Syncfusion® Blazor Extension.

Alternatively, create a WebAssembly application using the following terminal commands (Ctrl+`):

dotnet new blazorwasm -o BlazorApp
cd BlazorApp

Install Syncfusion® Blazor ImageEditor and themes NuGet packages

  • Press Ctrl+` to open the integrated terminal in Visual Studio Code.
  • Ensure the command is run in the project root directory where the .csproj file is located.
  • Run the following commands to install Syncfusion.Blazor.ImageEditor and Syncfusion.Blazor.Themes and restore dependencies.
dotnet add package Syncfusion.Blazor.ImageEditor -v 31.2.2
dotnet add package Syncfusion.Blazor.Themes -v 31.2.2
dotnet restore

NOTE

Syncfusion® Blazor components are available on nuget.org. Refer to the NuGet packages topic for the list of available packages with component details.

Register Syncfusion® Blazor service

Open ~/_Imports.razor and import the Syncfusion.Blazor and Syncfusion.Blazor.ImageEditor namespaces.

@using Syncfusion.Blazor
@using Syncfusion.Blazor.ImageEditor

Register the Syncfusion® Blazor service in ~/Program.cs of the Blazor WebAssembly app.

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Syncfusion.Blazor;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddSyncfusionBlazor();
await builder.Build().RunAsync();
....

Add stylesheet and script resources

The theme stylesheet and script can be accessed from NuGet through Static Web Assets. Include the stylesheet and script references in the <head> section of ~/index.html.

<head>
    ....
    <link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
    <script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
</head>

NOTE

See the Blazor themes topic for methods to reference themes in a Blazor application: Static Web Assets, CDN, and CRG. Also, see Adding script reference for approaches to add script references.

Add Syncfusion® Blazor Image Editor component

Add the Syncfusion® Blazor Image Editor component in ~/Pages/Index.razor.

<SfImageEditor Height="500"></SfImageEditor>
  • Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the app. This renders the Syncfusion® Blazor Image Editor component in the default web browser.
Blazor Image Editor Component

See also

NOTE

Explore the Blazor Image Editor example to see how to render and configure the Image Editor.