CropperImage.MAUI 1.1.0

dotnet add package CropperImage.MAUI --version 1.1.0
                    
NuGet\Install-Package CropperImage.MAUI -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CropperImage.MAUI" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CropperImage.MAUI" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CropperImage.MAUI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CropperImage.MAUI --version 1.1.0
                    
#r "nuget: CropperImage.MAUI, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CropperImage.MAUI@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CropperImage.MAUI&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CropperImage.MAUI&version=1.1.0
                    
Install as a Cake Tool

CropperImage.MAUI

An image cropper and portrait library (using SkiaSharp) for .NET MAUI applications.

CropperImageView

A ContetView control for cropping images with the next properties:

Android iOS/Mac Windows
Cropper Figure (circle,square)
Cropper radius
Croppep image format/quality settings
Photo transform format/quality settings
Edit/show mode
Text title over photo (show mode)
Zoom (with buttons and gestures)
Pick photo customizable

Install and configure CropperImageView

  1. Download and Install CropperImage.MAUI NuGet package on your application.

  2. Initialize the plugin in your MauiProgram.cs:

    // Add the using to the top
    using CropperImage.MAUI;
    
    public static MauiApp CreateMauiApp()
    {
    	var builder = MauiApp.CreateBuilder();
    
    	builder
    		.UseMauiApp<App>()
    		.UseImageCropper(); // Add the use of the plugging
    
    	return builder.Build();
    }
    

Using CropperImageView

In XAML, make sure to add the right XML namespace:

xmlns:ci="clr-namespace:CropperImage.MAUI;assembly=CropperImage.MAUI"

Use the control:

            <ci:CropperImageView x:Name="cropper" HorizontalOptions="Center" WidthRequest="300" HeightRequest="300" EditMode="True" 
                                 ButtonsColor="White" CropperFigure="Circle" ShowSelectButton="False" SelectSourceOnTap="True"
                                 CroppedImageFormat="PNG" CroppedImageMaxResolution="200,200"
                                 PhotoImageFormat="JPEG" PhotoImageMaxResolution="1920,1080" />


Call the crop method and use the result or bind the result properties:

        private async void Button_Clicked(object sender, EventArgs e)
        {
            var result = await cropper.CropImage(true);
            MemoryStream ms = new();
            ms.Write(result);
            ms.Position = 0;
            portrait.ImageSource = ImageSource.FromStream(() => ms);
        }
        private async void Button1_Clicked(object sender, EventArgs e)
        {
            await cropper.CropImageAsync(false);
            MemoryStream ms = new();
            ms.Write(cropper.CroppedImageBytes);
            ms.Position = 0;
            portrait.ImageSource = ImageSource.FromStream(() => ms);
        }

PortraitView

A ContentView control for portraits visualization

Initialize the plugin in your MauiProgram.cs:

```csharp
// Add the using to the top
using CropperImage.MAUI;

public static MauiApp CreateMauiApp()
{
	var builder = MauiApp.CreateBuilder();

	builder
		.UseMauiApp<App>()
		.UseImageCropper(); // Add the use of the plugging

	return builder.Build();
}
```

In XAML, make sure to add the right XML namespace:

xmlns:ci="clr-namespace:CropperImage.MAUI;assembly=CropperImage.MAUI"

Use the control and its bindable properties:

            <ci:PortraitView BindingContext="{x:Reference cropper}" ImageSource="{Binding CroppedImage}" 
                         WidthRequest="90" HeightRequest="90" Text="PR" FontSize="40" Fill="blue" TextColor="White" Stroke="orange">
                <ci:PortraitView.StrokeShape>
                    <RoundRectangle CornerRadius="30,0,0,30" />
                </ci:PortraitView.StrokeShape>
            </ci:PortraitView>
<ci:PortraitView x:Name="portrait" WidthRequest="90" HeightRequest="90" Text="HA" FontSize="40"/>

Set the ImageSource property to replace text by the image:

        private async void Button1_Clicked(object sender, EventArgs e)
        {
            await cropper.CropImageAsync(false);
            MemoryStream ms = new();
            ms.Write(cropper.CroppedImageBytes);
            ms.Position = 0;
            portrait.ImageSource = ImageSource.FromStream(() => ms);
        }

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-maccatalyst16.1 is compatible.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows10.0.19041 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 1,625 3/23/2023
1.0.1 397 3/22/2023
1.0.0 389 3/22/2023

Added Edit button