ImageCropper.Maui.V2
1.4.1
dotnet add package ImageCropper.Maui.V2 --version 1.4.1
NuGet\Install-Package ImageCropper.Maui.V2 -Version 1.4.1
<PackageReference Include="ImageCropper.Maui.V2" Version="1.4.1" />
<PackageVersion Include="ImageCropper.Maui.V2" Version="1.4.1" />
<PackageReference Include="ImageCropper.Maui.V2" />
paket add ImageCropper.Maui.V2 --version 1.4.1
#r "nuget: ImageCropper.Maui.V2, 1.4.1"
#:package ImageCropper.Maui.V2@1.4.1
#addin nuget:?package=ImageCropper.Maui.V2&version=1.4.1
#tool nuget:?package=ImageCropper.Maui.V2&version=1.4.1
ImageCropper.Maui.V2
.NET MAUI plugin to crop and rotate photos.
Fork of jmbowman1107/ImageCropper.Maui (via odapmoa) with iOS fixes: Safe Area toolbar buttons, rotate and aspect ratio buttons now working. The original NuGet package (ImageCropper.Maui) is unmaintained and broken on iOS.
Supports Android and iOS.
- Android library from : https://github.com/CanHub/Android-Image-Cropper
- iOS library from : https://github.com/TimOliver/TOCropViewController
Features
- Cropping image.
- Rotating image.
- Aspect ratio.
- Circle/Rectangle shape.
Screen-Shots
Android
<img src="ScreenShots/Android_Rectangle.gif" alt="Crop/Rotate image(Rectangle/Android)"/> <img src="ScreenShots/Android_Circle.gif" alt="Crop/Rotate image(Circle/Android)"/>
iOS
<img src="ScreenShots/iOS_Rectangle.gif" alt="Crop/Rotate image(Rectangle/iOS)"/> <img src="ScreenShots/iOS_Circle.gif" alt="Crop/Rotate image(Circle/iOS)" />
Setup
Install the nuget package in portable and all platform specific projects. NOTE: TOCropView.Maui results in long file paths, and if your base repo path is little long, this package cannot be successfully installed from Visual Studio. To work around this issue install the package using 'dotnet restore' from the CLI.
This plugin uses the MediaPicker, so be sure to complete the full setup this. Please fully read through the MediaPicker description.
Android
Add the following to your AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:supportsRtl="true">
<activity android:name="com.canhub.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat" />
</application>
<uses-permission android:name="android.permission.CAMERA" />
</manifest>
In MainActivity.cs file:
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
new ImageCropper.Maui.Platform().Init(this);
base.OnCreate(savedInstanceState);
}
}
iOS
In AppDelegate.cs file:
new ImageCropper.Maui.Platform().Init(this);
Usage
Show ImageCropper page.
new ImageCropper()
{
Success = (imageFile) =>
{
Dispatcher.Dispatch(() =>
{
imageView.Source = ImageSource.FromFile(imageFile);
});
}
}.Show(this);
Show it with additional parameters.
new ImageCropper()
{
PageTitle = "Test Title",
AspectRatioX = 1,
AspectRatioY = 1,
CropShape = ImageCropper.CropShapeType.Oval,
SelectSourceTitle = "Select source",
TakePhotoTitle = "Take Photo",
PhotoLibraryTitle = "Photo Library",
CancelButtonTitle = "Cancel",
InitialCropWindowPaddingRatio = 0.15f, // Android only: adds margin around the crop rectangle
Success = (imageFile) =>
{
Dispatcher.Dispatch(() =>
{
imageView.Source = ImageSource.FromFile(imageFile);
});
}
}.Show(this);
Show it with an image
new ImageCropper()
{
Success = (imageFile) =>
{
Dispatcher.Dispatch(() =>
{
imageView.Source = ImageSource.FromFile(imageFile);
});
}
}.Show(this, imageFileName);
Properties
- PageTitle — title displayed on the crop page
- AspectRatioX / AspectRatioY — fixed aspect ratio (0 = free)
- CropShape —
RectangleorOval - InitialCropWindowPaddingRatio — (Android only) padding ratio (0.0–0.5) around the initial crop rectangle. Default
0.1. Increase this if the crop handles extend beyond the touchable screen area on some devices. - Logger —
ILoggerinstance for error logging. Auto-resolved from MAUI's DI container; can be overridden manually. Integrates with any standard .NET logging provider (Sentry, Application Insights, etc.). - Initial image can be set in Show function.
Logging
Logging works automatically — ImageCropper resolves an ILogger from MAUI's DI container. No setup needed if you're using the default MAUI logging configuration.
To override with a custom logger:
new ImageCropper()
{
Logger = myCustomLogger,
Success = (imageFile) => { ... },
Failure = () => { ... }
}.Show(this);
Contributions
Contributions are welcome!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-android36.0 is compatible. net10.0-browser was computed. net10.0-ios was computed. net10.0-ios26.0 is compatible. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Maui.Controls (>= 10.0.10)
-
net10.0-android36.0
- Com.Vanniktech.AndroidImageCropper.Maui.V2 (>= 1.4.1)
- Microsoft.Maui.Controls (>= 10.0.10)
-
net10.0-ios26.0
- Microsoft.Maui.Controls (>= 10.0.10)
- TOCropView.Maui.V2 (>= 1.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.