Blazorise Cropper API
Explore the Blazorise Cropper API reference for parameters, events, methods, and related types.
For examples and usage guidance, see the Cropper documentation.
API
Parameters
Cropper
| Parameter | Description | Type | Default |
|---|---|---|---|
Alt |
The alt text of the image. |
string | |
CropperState |
Provides the shared state and synchronization context between the cropper and cropper viewer. |
CropperState | null |
CrossOrigin |
The cross-origin attribute of the image. |
string | |
Enabled |
Enables or disables cropper interactions. |
bool | true |
GridOptions |
Defines the grid overlay drawn inside the crop selection. |
CropperGridOptions | new CropperGridOptions() |
ImageOptions |
Controls which image transform operations are available. |
CropperImageOptions | new CropperImageOptions() |
SelectionOptions |
Defines the behavior and initial shape of the crop selection. |
CropperSelectionOptions | new CropperSelectionOptions() |
ShowBackground |
Shows the grid background behind the cropper. |
bool | true |
Source |
The source of the image. |
string |
CropperViewer
| Parameter | Description | Type | Default |
|---|---|---|---|
CropperState |
Provides the shared state and synchronization context between the cropper and cropper viewer. |
CropperState | null |
CropperCropOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
Height |
Output canvas height in pixels. |
int | 0 |
ImageQuality |
Compression quality for lossy formats, from RemarksA user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range. |
double? | 1d |
ImageType |
MIME type for the encoded cropped image. Defaults to |
string | "image/png" |
Width |
Output canvas width in pixels. |
int | 0 |
CropperImageOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
Rotatable |
Rotation commands can change the image angle. |
bool | true |
Scalable |
Scale commands can resize the image on the X or Y axis. |
bool | true |
Skewable |
Skew commands can slant the image horizontally or vertically. |
bool | false |
Translatable |
Move commands can reposition the image within the cropper. |
bool | true |
CropperSelectionOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
AspectRatio |
Fixed ratio maintained while resizing the selection. |
CropperAspectRatio | CropperAspectRatio.Is1x1 |
InitialAspectRatio |
Ratio used for the selection created during initialization. |
CropperAspectRatio | CropperAspectRatio.Is1x1 |
InitialCoverage |
Fraction of the image covered by the initial selection, from |
double? | null |
Keyboard |
Keyboard input can move or resize the active selection. |
bool | true |
Movable |
The selection can be dragged to a new position. |
bool | true |
Outlined |
The selection renders with a visible outline. |
bool | true |
Resizable |
Selection edges and handles can change its size. |
bool | true |
Zoomable |
Mouse wheel or gesture zoom can be applied from the selection. |
bool | true |
CropperGridOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
Bordered |
The grid renders border lines around its cells. |
bool | true |
Columns |
Number of vertical grid divisions. |
int | 3 |
Covered |
The grid fills the full selection area. |
bool | true |
Rows |
Number of horizontal grid divisions. |
int | 3 |
Events
Cropper
| Event | Description | Type |
|---|---|---|
CropEnded |
This event fires when the canvas (image wrapper) or the crop box stops changing. |
Func<Task> |
CropMoved |
This event fires when the canvas (image wrapper) or the crop box is changing. |
Func<Task> |
Cropped |
This event fires when the canvas (image wrapper) or the crop box changes. |
Func<CropperCroppedEventArgs, Task> |
CropStarted |
This event fires when the canvas (image wrapper) or the crop box starts to change. |
Func<Task> |
ImageLoadingFailed |
This event fires when the image cannot be loaded. Usually because of 404 or Source being null. Returns an error message as a parameter. |
Func<string, Task> |
ImageReady |
This event fires when the image is ready / loaded. |
Func<Task> |
SelectionChanged |
The event is fired when the position or size of the selection is going to change. |
Func<CropperSelectionChangedEventArgs, Task> |
Zoomed |
This event fires when a cropper instance starts to zoom in or zoom out its canvas (image wrapper). |
Func<CropperZoomedEventArgs, Task> |
Methods
Cropper
| Method | Description | Return | Parameters |
|---|---|---|---|
Center |
Center the image. | ValueTask | string size |
CropAsBase64ImageAsync |
Get the cropped image as Base64 image. | ValueTask<string> | CropperCropOptions options |
MoveTo |
Moves the image to a specific position. | ValueTask | int x, int y |
Move |
Moves the image. | ValueTask | int x, int y |
ResetSelection |
Resets the selection to its initial position and size. | ValueTask | |
Rotate |
Rotates the image. | ValueTask | double angle |
Scale |
Scale the image. | ValueTask | int x, int y |
Zoom |
Zooms the image. | ValueTask | double scale |