lreading / Xamarin-Image-Resizer

(Unmaintained) Cross platform Xamarin plugin to resize images
MIT License
5 stars 0 forks source link

Unmaintained

This code base is not being maintained.

Xamarin Image Resizer

Cross platform Xamarin plugin to resize images while maintaining aspect ratio on a mobile device. This can be particularly useful when passing an image to an API.

Platforms

TODO

Installation

Install via NuGet: https://www.nuget.org/packages/Plugin.ImageResizer Install-Package Plugin.ImageResizer -Pre As with any Xamarin Plugins, be sure to install the package to your shared code and platform-specific implementations.

How to Use

This can be used with a stream (if you're using the Media Plugin https://github.com/jamesmontemagno/MediaPlugin) or standard byte arrays.

// If you already have the byte[]
byte[] resizedImage = await CrossImageResizer.Current.ResizeImageWithAspectRatioAsync(originalImageBytes, 500, 1000);

// If you have a stream, such as:
// var file = await CrossMedia.Current.PickPhotoAsync(options);
// var originalImageStream = file.GetStream();
byte[] resizedImage = await CrossImageResizer.Current.ResizeImageWithAspectRatioAsync(originalImageStream, 500, 1000);

Thanks