Skip to content

961191: Prepare UG for IE 2025 Vol2 completed features #6150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 132 additions & 1 deletion blazor/image-editor/annotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ The [`DrawTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Im

* transformCollection: Specifies the transform collection of the text annotation.

* underline — Specifies whether the text should be underlined.

* strikethrough — Specifies whether the text should have a strikethrough.

By utilizing the `DrawTextAsync` 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.

Here is an example of adding a text in a button click using `DrawTextAsync` method.
Expand Down Expand Up @@ -251,7 +255,134 @@ Here is an example of adding additional font family using the `ImageEditorFontFa
```

![Blazor Image Editor with Custom font family in an image](./images/blazor-image-editor-font.png)


### Formatting Text with Bold, Italic, Underline, and Strikethrough

The [`DrawTextAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_DrawTextAsync_System_Double_System_Double_System_String_System_String_System_Int32_System_Boolean_System_Boolean_System_String_System_Boolean_System_Int32_System_String_System_String_System_Int32_) method in the Blazor Image Editor component allows you to insert a text annotation into the image with specific customization options. Applying these styles enhances the text by improving readability and emphasizing key information: bold increases visual weight to highlight important points, italic adds a slanted emphasis or creative touch, underline draws a line beneath the text for clarity or separation, and strikethrough places a line through text to indicate removal or outdated content. These formatting options enable users to make their annotations more visually distinctive and effective in conveying information.


Here is an example of adding a text in a button click using `DrawTextAsync` method.

In the following example, you can using the DrawTextAsync method in the button click event.

```cshtml
@using Syncfusion.Blazor.ImageEditor
@using Syncfusion.Blazor.Buttons

<div style="padding-bottom: 15px">
<SfButton OnClick="DrawTextAsync">Draw Text</SfButton>
<SfButton OnClick="BoldAsync">Draw Text Bold</SfButton>
<SfButton OnClick="ItalicAsync">Draw Text Italic Color</SfButton>
<SfButton OnClick="UnderlineAsync">Draw Text Underline</SfButton>
<SfButton OnClick="StrikethroughAsync">Draw Text Strikethrough Color</SfButton>
</div>
<SfImageEditor @ref="ImageEditor" Toolbar="customToolbarItem" Height="400">
<ImageEditorEvents Created="OpenAsync"></ImageEditorEvents>
</SfImageEditor>

@code {
SfImageEditor ImageEditor;
private List<ImageEditorToolbarItemModel> customToolbarItem = new List<ImageEditorToolbarItemModel>() { };

private async void OpenAsync()
{
await ImageEditor.OpenAsync("https://ej2.syncfusion.com/react/demos/src/image-editor/images/bridge.png");
}

private async void DrawTextAsync()
{
ImageDimension Dimension = await ImageEditor.GetImageDimensionAsync();
await ImageEditor.DrawTextAsync(Dimension.X.Value, Dimension.Y.Value, "Syncfusion");
}
private async void BoldAsync()
{
ShapeSettings[] shapes = await ImageEditor.GetShapesAsync();
if (shapes != null && shapes.Length > 0)
{
var shape = shapes[0];
var fontStyles = shape.FontStyle?.ToList();

if (fontStyles.Contains("bold"))
{
fontStyles.Remove("bold");
}
else
{
fontStyles.Add("bold");
}

shape.FontStyle = fontStyles.ToArray();
await ImageEditor.UpdateShapeAsync(shapes[0]);
}
}
private async void ItalicAsync()
{
ShapeSettings[] shapes = await ImageEditor.GetShapesAsync();
if (shapes != null && shapes.Length > 0)
{
var shape = shapes[0];
var fontStyles = shape.FontStyle?.ToList();

if (fontStyles.Contains("italic"))
{
fontStyles.Remove("italic");
}
else
{
fontStyles.Add("italic");
}

shape.FontStyle = fontStyles.ToArray();
await ImageEditor.UpdateShapeAsync(shapes[0]);
}
}
private async void UnderlineAsync()
{
ShapeSettings[] shapes = await ImageEditor.GetShapesAsync();
if (shapes != null && shapes.Length > 0)
{
var shape = shapes[0];
var fontStyles = shape.FontStyle?.ToList();

if (fontStyles.Contains("underline"))
{
fontStyles.Remove("underline");
}
else
{
fontStyles.Add("underline");
}

shape.FontStyle = fontStyles.ToArray();
await ImageEditor.UpdateShapeAsync(shapes[0]);
}
}
private async void StrikethroughAsync()
{
ShapeSettings[] shapes = await ImageEditor.GetShapesAsync();
if (shapes != null && shapes.Length > 0)
{
var shape = shapes[0];
var fontStyles = shape.FontStyle?.ToList();

if (fontStyles.Contains("strikethrough"))
{
fontStyles.Remove("strikethrough");
}
else
{
fontStyles.Add("strikethrough");
}

shape.FontStyle = fontStyles.ToArray();
await ImageEditor.UpdateShapeAsync(shapes[0]);
}
}
}
```

![Blazor Image Editor with Draw text an image](./images/blazor-image-editor-formatting-text.png)

## Freehand drawing

The Freehand Draw annotation tool in the Blazor Image Editor component is a versatile feature that allows users to draw and sketch directly on the image using mouse or touch input. This tool provides a flexible and creative way to add freehand drawings or annotations to the image.
Expand Down
2 changes: 1 addition & 1 deletion blazor/image-editor/end-user-capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To open an image in the image editor, do the following steps.

* Click the Open icon from the left side of the toolbar.

* The file explorer lists only JPEG, PNG, JPG, and WEBP format files.
* The file explorer lists only JPEG, PNG, JPG, WEBP and BMP format files.

* Select the image from the list of the images from the file explorer window.

Expand Down
4 changes: 2 additions & 2 deletions blazor/image-editor/image-restrictions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ documentation: ug

The Image Editor allows users to specify image extensions, as well as the minimum and maximum image sizes for uploaded or loaded images using the [`ImageEditorUploadSettings`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.ImageEditorUploadSettings.html) property. End users will receive a clear alert message if an uploaded image does not meet the defined criteria, ensuring a seamless and user-friendly upload experience.

`Note:` File restrictions apply when uploading images to the Image Editor, whether through the open method or the built-in uploader. If uploadSettings is not defined in the sample, the Image Editor, by default, allows files with .jpg, .png, .svg, and .webp extensions, without any file size restrictions.
`Note:` File restrictions apply when uploading images to the Image Editor, whether through the open method or the built-in uploader. If uploadSettings is not defined in the sample, the Image Editor, by default, allows files with .jpg, .png, .svg, .webp and .bmp extensions, without any file size restrictions.

## Allowed image extensions

The Image Editor allows users to specify acceptable file extensions for uploaded images using the [`ImageEditorUploadSettings.AllowedExtensions`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.ImageEditorUploadSettings.html#Syncfusion_Blazor_ImageEditor_ImageEditorUploadSettings_AllowedExtensions) property, ensuring that only supported formats, such as `.jpg`, `.png`, and `.webp` and `.svg` are allowed. This helps maintain compatibility and prevents errors caused by unsupported file types. By default, the Image Editor allows files with .jpg, .png, .webp, and .svg extensions.
The Image Editor allows users to specify acceptable file extensions for uploaded images using the [`ImageEditorUploadSettings.AllowedExtensions`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.ImageEditorUploadSettings.html#Syncfusion_Blazor_ImageEditor_ImageEditorUploadSettings_AllowedExtensions) property, ensuring that only supported formats, such as `.jpg`, `.png`, `.svg`, `.webp` and `.bmp` are allowed. This helps maintain compatibility and prevents errors caused by unsupported file types. By default, the Image Editor allows files with .jpg, .png, .svg, .webp, and .bmp extensions.

`Note:` To specify allowed extensions in the upload settings, use the format '.png, .svg', listing the permitted file types as a comma-separated string.

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 36 additions & 3 deletions blazor/image-editor/open-save.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ The [Blazor Image Editor](https://www.syncfusion.com/blazor-components/blazor-im

## Supported image formats

The Image Editor control supports three common image formats: PNG, JPEG, SVG, and WEBP. These formats allow you to work with a wide range of image files within the Image Editor.
The Image Editor control supports three common image formats: PNG, JPEG, SVG, WEBP and BMP. These formats allow you to work with a wide range of image files within the Image Editor.

When it comes to saving the edited image, the default file type is set as PNG. This means that when you save the edited image without specifying a different file type, it will be saved as a PNG file. However, it's important to note that the Image Editor typically provides options or methods to specify a different file type if desired. This allows you to save the edited image in formats other than the default PNG, such as JPEG, SVG, and WEBP based on your specific requirements or preferences.
When it comes to saving the edited image, the default file type is set as PNG. This means that when you save the edited image without specifying a different file type, it will be saved as a PNG file. However, it's important to note that the Image Editor typically provides options or methods to specify a different file type if desired. This allows you to save the edited image in formats other than the default PNG, such as JPEG, SVG, WEBP and BMP based on your specific requirements or preferences.

## Open an image

Expand Down Expand Up @@ -418,6 +418,39 @@ You can utilize the [`FileOpenEventArgs`](https://help.syncfusion.com/cr/blazor/
```
![Blazor Image Editor with Adding Watermark](./images/blazor-image-editor-add-watermark.jpeg)

### Opening images with custom width and height

Users can now open images with specified width and height values using the imageSettings parameter in the `Open` method. This enhancement introduces three additional properties: `width,` `height,` and `isAspectRatio.` Image dimensions can be precisely controlled while preserving the aspect ratio, if needed. This provides more control over rendering images, especially when dealing with high-resolution images or fixed canvas requirements.

```cshtml
@using Syncfusion.Blazor.ImageEditor
@using Syncfusion.Blazor.Buttons

<div style="padding-bottom: 15px">
<SfButton OnClick="OpenImageAsync">Open Image</SfButton>
</div>
<SfImageEditor @ref="ImageEditor" Toolbar="customToolbarItem" Height="400">
<ImageEditorEvents Created="OpenAsync"></ImageEditorEvents>
</SfImageEditor>

@code {
SfImageEditor ImageEditor;
private List<ImageEditorToolbarItemModel> customToolbarItem = new List<ImageEditorToolbarItemModel>() { };

private async void OpenAsync()
{
await ImageEditor.OpenAsync("https://ej2.syncfusion.com/react/demos/src/image-editor/images/bridge.png");
}

private async void OpenImageAsync()
{
await ImageEditor.OpenAsync("https://ej2.syncfusion.com/react/demos/src/image-editor/images/bridge.png", true,"", -1, 500);
}
}
```

![Blazor Image Editor with Opening an image](./images/blazor-image-editor-custom-height-width.png)

## Save as image

The [`ExportAsync`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.SfImageEditor.html#Syncfusion_Blazor_ImageEditor_SfImageEditor_ExportAsync_System_String_Syncfusion_Blazor_ImageEditor_ImageEditorFileType_System_Double_) method in the Blazor Image Editor component is used to save the modified image as an image, and it accepts a file name and file type as parameters. The file type parameter supports PNG, JPEG, SVG, and WEBP the default file type is PNG. Users are allowed to save an image with a specified file name, file type, and image quality. This enhancement provides more control over the output, ensuring that users can save their work exactly as they need it.
Expand Down Expand Up @@ -678,7 +711,7 @@ The [`FileOpened`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Image

[`FileName`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.FileOpenEventArgs.html#Syncfusion_Blazor_ImageEditor_FileOpenEventArgs_FileName): This argument is a string that contains the file name of the opened image. It represents the name of the file that was selected or provided when loading the image into the Image Editor.

[`FileType`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.FileOpenEventArgs.html#Syncfusion_Blazor_ImageEditor_FileOpenEventArgs_FileType): This argument is a string that contains the type of the opened image. It specifies the format or file type of the image that was loaded, such as PNG, JPEG, SVG, and WEBP.
[`FileType`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.ImageEditor.FileOpenEventArgs.html#Syncfusion_Blazor_ImageEditor_FileOpenEventArgs_FileType): This argument is a string that contains the type of the opened image. It specifies the format or file type of the image that was loaded, such as PNG, JPEG, SVG, WEBP and BMP.

By accessing these arguments within the `FileOpened` event handler, you can retrieve information about the loaded image, such as its file name and file type. This can be useful for performing additional actions or implementing logic based on the specific image that was opened in the Image Editor component.

Expand Down