Cropper.Blazor icon indicating copy to clipboard operation
Cropper.Blazor copied to clipboard

About the Draw a polygon when cropping

Open AlbertLiu1974 opened this issue 1 year ago • 8 comments

Hello,

I am writing some object detection on image loading via blazor WASM. Just want to know if we can use some other drawing functions like polygons, lines or arrows.. Kindly refer to the image or YT I recorded. thanks.

image

https://youtu.be/xOmG31Nv-Ew

Best regards, Albert Liu

AlbertLiu1974 avatar Apr 10 '24 13:04 AlbertLiu1974

Hi @AlbertLiu1974.

Sorry, in this library draw functions is absent. But, you can crop a polygon image image

Sincerely, Maksym Hornytskiy

MaxymGorn avatar Apr 10 '24 13:04 MaxymGorn

@AlbertLiu1974 Try to find some additional library for draw functionality, I did a quick search and found this: https://trevormare.github.io/STDoodle/help/doodledraw, maybe there is something else...

MaxymGorn avatar Apr 10 '24 13:04 MaxymGorn

@AlbertLiu1974 Also, I know you can also use "fabric.js" for the drawing function, but you need to find a library for that or wrap the blazor interop module js library

MaxymGorn avatar Apr 10 '24 13:04 MaxymGorn

Hi @AlbertLiu1974. New version of Cropper.Blazor will be realized which allows to use canvas or image reference in blazor to draw a polygon. New code was attached into dev branch.

MaxymGorn avatar Jul 31 '24 04:07 MaxymGorn

You need to use GetCropperElementReference method to get reference into canvas or img and pass appropriate type for CropperComponentType parameter (default is img). More info in api docs (some links can be broken for new types now, it will be fixed later): https://cropperblazor.github.io/api#properties Screenshot_20240731_072503_Chrome Screenshot_20240731_073605_Chrome

Just note for CropperComponentType.Canvas type requires manual uploading of images into canvas HTMl element, including error handling. You can use GetCropperElementReference to get canvas reference and use all power of canvas functionality!

MaxymGorn avatar Jul 31 '24 04:07 MaxymGorn

Hi @AlbertLiu1974. A new version of Cropper.Blazor (1.3.4) has been released that supports the mentioned topics!

MaxymGorn avatar Aug 04 '24 15:08 MaxymGorn

thanks a lot. I am restart to test it. look forward to working with cropper blazor. stay titght.

AlbertLiu1974 avatar Mar 18 '25 12:03 AlbertLiu1974

@AlbertLiu1974 you can see examples of implemention: https://cropperblazor.github.io/examples/cropping#crop-a-polygon-image, https://cropperblazor.github.io/examples/cropping#crop-a-round-image.

Image

Additionally, a feature will be released soon that will not block the UI when retrieving cropped images, which is very useful for very large images.

MaxymGorn avatar Mar 21 '25 10:03 MaxymGorn

@AlbertLiu1974 just example of using canvas for cropper component: https://cropperblazor.github.io/examples/cropperusage#canvas-cropper

You can use canvas reference (html canvas element) for drawing and so on, e.g project to integrate and use js interop api: https://github.com/TrevorMare/STDoodle

MaxymGorn avatar May 21 '25 13:05 MaxymGorn