Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Alex-Dobrynin/Xamarin.Controls.ImageCropper
Cross platform Xamarin library to crop and rotate images
https://github.com/Alex-Dobrynin/Xamarin.Controls.ImageCropper
Last synced: 2 days ago
JSON representation
Cross platform Xamarin library to crop and rotate images
- Host: GitHub
- URL: https://github.com/Alex-Dobrynin/Xamarin.Controls.ImageCropper
- Owner: Alex-Dobrynin
- License: mit
- Created: 2021-02-25T12:34:09.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-04T12:46:28.000Z (3 months ago)
- Last Synced: 2024-12-07T20:13:22.061Z (5 days ago)
- Language: C#
- Size: 214 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dotnet-maui - Xamarin.Controls.ImageCropper - Dobrynin/Xamarin.Controls.ImageCropper?style=flat-square)](https://github.com/Alex-Dobrynin/Xamarin.Controls.ImageCropper/stargazers)|[![GitHub last-commit](https://img.shields.io/github/last-commit/Alex-Dobrynin/Xamarin.Controls.ImageCropper?style=flat-square)](https://github.com/Alex-Dobrynin/Xamarin.Controls.ImageCropper/commits) (Plugins)
README
# MAUI / Xamarin ImageCropper
Simple crossplatform MAUI / Xamarin image cropper, you can use it in Xamarin.Forms, Xamarin native and MAUI.| Supported platforms | Nuget | Android | iOS | Windows | MacCatalyst |
|---------------------|---------------|---------|-----|---------|-------------|
| MAUI | [![Nuget](https://img.shields.io/nuget/v/Plugin.Maui.ImageCropper)](https://www.nuget.org/packages/Plugin.Maui.ImageCropper) | :white_check_mark: | :white_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: |
| Xamarin | [![Nuget](https://img.shields.io/nuget/v/Xamarin.Controls.ImageCropper)](https://www.nuget.org/packages/Xamarin.Controls.ImageCropper/1.0.1) | :white_check_mark: | :white_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: |
| .NET | [![Nuget](https://img.shields.io/nuget/v/Xamarin.Controls.ImageCropper)](https://www.nuget.org/packages/Xamarin.Controls.ImageCropper) | :white_check_mark: | :white_check_mark: | :heavy_multiplication_x: | :heavy_multiplication_x: |## Powered By:
* Mono Android - uses ArturHub's [Android-Image-Cropper](https://github.com/ArthurHub/Android-Image-Cropper)
* .NET / MAUI Android - uses CanHub's [Android-Image-Cropper](https://github.com/CanHub/Android-Image-Cropper)
* iOS - uses uses Tim Oliver's [TOCropViewController](https://github.com/TimOliver/TOCropViewController)### Another platforms:
Currently Windows and MacCatalyst are not supported, but your PRs are welcome## Mono setup:
### Android:
It uses Plugin.CurrentActivity under the hood, so don't forget to initialize it in your MainActivity.cs's OnCreate method:Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle);
Also, you need to add OnActivityResult handler:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
{
base.OnActivityResult(requestCode, resultCode, intent);Plugin.Maui.ImageCropper.Platform.Droid.OnActivityResult(requestCode, resultCode, intent);
}Don't forget to add this row into your AndroidManifest.xml file application tag:
### iOS:
No extra actions required## .NET setup:
### Android:
All you need is to initialize it in your MainActivity.cs's OnCreate method:Plugin.Maui.ImageCropper.Platform.Droid.Init(this);
Don't forget to add this row into your AndroidManifest.xml file application tag:
### iOS:
No extra actions required## MAUI setup:
To use it in MAUI you should call ```UseImageCropper()``` method from ```Plugin.Maui.ImageCropper``` namespace on your ```MauiAppBuilder```.Also there is another overload which allows you to register ImageCropper instance in services and then use it with DI
```csharp
UseImageCropper(registerInterface: true)
```### Android:
Don't forget to add this row into your AndroidManifest.xml file application tag:
### iOS:
No extra actions required## Example of usage:
##### Note: in MAUI use ```Cropper``` class instead of ```ImageCropper```
```csharp
await ImageCropper.Current.Crop(new CropSettings()
{
AspectRatioX = 1,
AspectRatioY = 1,
CropShape = CropSettings.CropShapeType.Rectangle
}, imageFilePath).ContinueWith(t =>
{
if (t.IsFaulted)
{
var ex = t.Exception;
//alert user
}
else if (t.IsCanceled)
{
//do nothing
}
else if (t.IsCompletedSuccessfully)
{
var result = t.Result;
//do smth with result
}
});
```