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.
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.
// Install CropperImage.MAUI as a Cake Addin
#addin nuget:?package=CropperImage.MAUI&version=1.1.0

// Install CropperImage.MAUI as a Cake Tool
#tool nuget:?package=CropperImage.MAUI&version=1.1.0                

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. 
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 698 3/23/2023
1.0.1 255 3/22/2023
1.0.0 251 3/22/2023

Added Edit button