Skip to content

Commit 080e7e4

Browse files
Merge pull request #4850 from syncfusion-content/EJ2-908998-feature-ug
908998: Image Editor New feature UG sample for Blazor platform
2 parents e91f378 + 3fd8d86 commit 080e7e4

File tree

4 files changed

+133
-3
lines changed

4 files changed

+133
-3
lines changed

blazor-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,6 +3082,7 @@
30823082
<li> <a href="/blazor/image-editor/frame">Frame</a></li>
30833083
<li> <a href="/blazor/image-editor/resize">Resize</a></li>
30843084
<li> <a href="/blazor/image-editor/z-order">Z-Order</a></li>
3085+
<li> <a href="/blazor/image-editor/redact">Redact</a></li>
30853086
<li> <a href="/blazor/image-editor/localization">Localization</a></li>
30863087
<li> <a href="/blazor/image-editor/accessibility">Accessibility</a></li>
30873088
<li>

blazor/image-editor/annotation.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The [Blazor Image Editor](https://www.syncfusion.com/blazor-components/blazor-im
1515

1616
Text annotation feature in the Blazor Image Editor component provides the capability to add and customize labels, captions, and other text elements directly onto the image. With this feature, you can easily insert text at specific locations within the image and customize various aspects of the text to meet your requirements.
1717

18-
You have control over the customization options including text content, font family, font style and font size for the text annotation.
18+
You have control over the customization options including text content, font family, font style, font color, fill color, stroke color, stroke width and font size for the text annotation.
1919

2020
### Add a text
2121

@@ -39,6 +39,14 @@ The [`DrawTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Im
3939

4040
* isSelected: Specifies to show the text in the selected state.
4141

42+
* degree: Specifies the degree to rotate the text.
43+
44+
* fillColor: Specifies the background color of the text.
45+
46+
* strokeColor: Specifies the outline color of the text annotation.
47+
48+
* strokeWidth: Specifies the outline stroke width of the text annotation.
49+
4250
By utilizing the [`DrawTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawTextAsync_System_Nullable_System_Double__System_Nullable_System_Double__System_String_System_String_System_Nullable_System_Int32__System_Boolean_System_Boolean_System_String_) method with these parameters, you can precisely position and customize text annotations within the image. This provides the flexibility to add labels, captions, or other text elements with specific font styles, sizes, and colors, enhancing the visual presentation and clarity of the image.
4351

4452
Here is an example of adding a text in a button click using [`DrawTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawTextAsync_System_Nullable_System_Double__System_Nullable_System_Double__System_String_System_String_System_Nullable_System_Int32__System_Boolean_System_Boolean_System_String_) method.
@@ -51,6 +59,8 @@ In the following example, you can using the DrawTextAsync method in the button c
5159
5260
<div style="padding-bottom: 15px">
5361
<SfButton OnClick="DrawTextAsync">Draw Text</SfButton>
62+
<SfButton OnClick="DrawTextOutlineAsync">Draw Text Outline</SfButton>
63+
<SfButton OnClick="DrawTextBackgroundColorAsync">Draw Text Background Color</SfButton>
5464
</div>
5565
<SfImageEditor @ref="ImageEditor" Toolbar="customToolbarItem" Height="400">
5666
<ImageEditorEvents Created="OpenAsync"></ImageEditorEvents>
@@ -70,6 +80,16 @@ In the following example, you can using the DrawTextAsync method in the button c
7080
ImageDimension Dimension = await ImageEditor.GetImageDimensionAsync();
7181
await ImageEditor.DrawTextAsync(Dimension.X.Value + 100, Dimension.Y.Value + 100, "Syncfusion");
7282
}
83+
private async void DrawTextOutlineAsync()
84+
{
85+
ImageDimension Dimension = await ImageEditor.GetImageDimensionAsync();
86+
await ImageEditor.DrawTextAsync(Dimension.X.Value + 100, Dimension.Y.Value + 100, 'Syncfusion', 'Arial', 70, false, false, '', false, null, '', 'green', 8);
87+
}
88+
private async void DrawTextBackgroundColorAsync()
89+
{
90+
ImageDimension Dimension = await ImageEditor.GetImageDimensionAsync();
91+
await ImageEditor.DrawTextAsync(Dimension.X.Value + 100, Dimension.Y.Value + 100, 'Syncfusion', 'Arial', 70, false, false, '', false, null, 'red', '', null);
92+
}
7393
}
7494
```
7595

@@ -377,7 +397,7 @@ The Blazor Image Editor component provides the ability to add shape annotations
377397

378398
The [`DrawRectangleAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawRectangleAsync_System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Int32__System_String_System_String_) method is used to draw rectangle in the Blazor Image Editor component. Rectangle annotations are valuable tools for highlighting, emphasizing, or marking specific areas of an image to draw attention or provide additional context.
379399

380-
The [`DrawRectangleAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawRectangleAsync_System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Int32__System_String_System_String_) method in the Image Editor component takes seven parameters to define the properties of the rectangle annotation:
400+
The [`DrawRectangleAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawRectangleAsync_System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Int32__System_String_System_String_) method in the Image Editor component takes ten parameters to define the properties of the rectangle annotation:
381401

382402
* x: Specifies the x-coordinate of the top-left corner of the rectangle.
383403

@@ -397,6 +417,8 @@ The [`DrawRectangleAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blaz
397417

398418
* isSelected: Specifies to show the rectangle in the selected state.
399419

420+
* borderRadius: Specifies the radius to apply border radius to rectangle.
421+
400422
The [`DrawEllipseAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawEllipseAsync_System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Double__System_String_System_String_) method in the Blazor Image Editor component is used to draw an ellipse. Ellipse annotations are valuable for highlighting, emphasizing, or marking specific areas of an image.
401423

402424
The [`DrawEllipseAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawEllipseAsync_System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Double__System_Nullable_System_Double__System_String_System_String_) method in the Image Editor component takes seven parameters to define the properties of the ellipse annotation:
@@ -501,7 +523,7 @@ Here is an example of inserting rectangle, ellipse, arrow, path, and line in a b
501523
502524
private async void RectangleAsync()
503525
{
504-
await ImageEditor.DrawRectangleAsync(250, 50, 120, 120, 4, "#fff", "blue");
526+
await ImageEditor.DrawRectangleAsync(250, 50, 120, 120, 4, "#fff", "blue", null, null, 8);
505527
}
506528
507529
private async void EllipseAsync()
77.4 KB
Loading

blazor/image-editor/redact.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
layout: post
3+
title: Redact with Blazor Image Editor Component | Syncfusion
4+
description: Checkout the Redact available in Blazor Image Editor component in Blazor Server App and Blazor WebAssembly App.
5+
platform: Blazor
6+
control: Image Editor
7+
documentation: ug
8+
---
9+
10+
# Redact in the Blazor Image Editor component
11+
12+
The redact feature in an Image Editor is a valuable tool that empowers users to conceal sensitive information by applying blur or pixel effects to specific areas of an image. This feature is particularly valuable for protecting privacy and complying with data protection regulations, making it easier to securely share images without compromising sensitive information.
13+
14+
## Apply redact to the image
15+
16+
The Image Editor control includes a [`DrawRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method, which allows you to draw redaction on an image. This method takes six parameters that define how the redact should be carried out:
17+
18+
* redactType: Specifies the type of redaction to be drawn on the image such as blur or pixelate. If not specified, the redaction drawing is initiated with the default blur value.
19+
20+
* startX: Specifies x-coordinate of redaction. If not specified, the redaction drawing is initiated with the first parameter.
21+
22+
* startY: Specifies y-coordinate of redaction. If not specified it draws redaction from the center point of the image.
23+
24+
* width: Specifies the width of redaction. The default value is 100.
25+
26+
* height: Specifies the height of redaction. The default value is 50.
27+
28+
* value: Specifies the blur value for blur-type redaction or the pixel size for pixelate-type redaction. Defaults to 20 since the default redaction is blur.
29+
30+
## Selecting a redact
31+
32+
The Image Editor control includes a [`SelectRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_SelectRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method, which allows you to select a redaction based on the given redaction id. Use [`GetRedactsAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_GetRedactsAsync _System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method to get the redaction id which is then passed to perform selection. This method takes one parameter that define how the redact should be carried out:
33+
34+
* id: Specifies the redact id to select a redact on an image.
35+
36+
## Deleting a redact
37+
38+
The Image Editor control includes a [`DeleteRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DeleteRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method, which allows you to delete a redaction based on the given redaction id. Use [`GetRedactsAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_GetRedactsAsync _System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method to get the redaction id which is then passed to perform selection. This method takes one parameter that define how the redact should be carried out:
39+
40+
* id: Specifies the redact id to delete a redact on an image.
41+
42+
## Updating a redact
43+
44+
The Image Editor control includes a [`UpdateRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_UpdateRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method, which allows you to update the existing redacts by changing its height, width, blur, and pixel size in the component. Use [`GetRedactsAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_GetRedactsAsync _System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method to get the redacts which is then passed to change the options of a redacts. This method takes two parameters that define how the redact should be carried out:
45+
46+
* setting: Specifies the redact settings to be updated for the shape on an image.
47+
48+
* isSelected: Specifies to show the redacts in the selected state.
49+
50+
## Getting redacts
51+
52+
The Image Editor control includes a [`GetRedactsAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_GetRedactsAsync _System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) method, which allows you to get all the redact details which is drawn on an image editor.
53+
54+
Here's an example demonstrating how to draw, select, delete, update, and get redacts on an image using the [`DrawRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__), [`SelectRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_SelectRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__), [`DeleteRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DeleteRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__), [`UpdateRedactAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_UpdateRedactAsync_System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) and [`GetRedactsAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_GetRedactsAsync _System_Nullable_System_Int32__System_Nullable_System_Int32__System_Nullable_System_Boolean__) methods.
55+
56+
```cshtml
57+
@using Syncfusion.Blazor.ImageEditor
58+
@using Syncfusion.Blazor.Buttons
59+
60+
<div style="padding-bottom: 15px">
61+
<SfButton OnClick="addRedact">Add Redact</SfButton>
62+
<SfButton OnClick="updateRedact">Update Redact</SfButton>
63+
<SfButton OnClick="selectRedact">Select Redact</SfButton>
64+
<SfButton OnClick="deleteRedact">Delete Redact</SfButton>
65+
</div>
66+
67+
<SfImageEditor @ref="ImageEditor" Toolbar="customToolbarItem" Height="400">
68+
<ImageEditorEvents Created="OpenAsync"></ImageEditorEvents>
69+
</SfImageEditor>
70+
@code {
71+
private SfImageEditor ImageEditor;
72+
private List<ImageEditorToolbarItemModel> customToolbarItem = new List<ImageEditorToolbarItemModel>() { };
73+
private async void OpenAsync()
74+
{
75+
await ImageEditor.OpenAsync("nature.png");
76+
}
77+
private async void addRedact()
78+
{
79+
ImageDimension Dimension = await ImageEditor.GetImageDimensionAsync();
80+
await ImageEditor.DrawRedactAsync(RedactType.Blur, Dimension.X.Value + 100, Dimension.Y.Value + 100, 200, 300);
81+
}
82+
private async void updateRedact()
83+
{
84+
RedactSettings[] redacts = await ImageEditor.GetRedactsAsync();
85+
if (redacts.Length > 0) {
86+
redacts[redacts.Length - 1].BlurIntensity = 100;
87+
await ImageEditor.UpdateRedactAsync(redacts[redacts.Length - 1]);
88+
}
89+
}
90+
private async void selectRedact()
91+
{
92+
RedactSettings[] redacts = await ImageEditor.GetRedactsAsync();
93+
if (redacts.Length > 0) {
94+
await ImageEditor.SelectRedactAsync(redacts[redacts.Length - 1].ID);
95+
}
96+
}
97+
private async void deleteRedact()
98+
{
99+
RedactSettings[] redacts = await ImageEditor.GetRedactsAsync();
100+
if (redacts.Length > 0) {
101+
await ImageEditor.DeleteRedactAsync(redacts[redacts.Length - 1].ID);
102+
}
103+
}
104+
}
105+
```
106+
107+
![Blazor Image Editor with Redaction](./images/blazor-image-editor-redact.png)

0 commit comments

Comments
 (0)