Some handy xamarin cross platform (Android / iOS / UWP) commands for byte[] image manipulation. See the Sample App for example usages.
-
ResizeImageCommand: resize an image with specific width / height. Maintains aspect ratio.
-
AnalyseImageCommand: Get the height, width and size of a given image
-
ConvertImageCommand: Convert images between jpeg and png formats
-
ImageTools: Methods for all 3 above
Sample code: Resize an image
var resizeImage = DependencyService.Get<IResizeImageCommand>();
var resizeResult = await resizeImage.ExecuteAsync(new ResizeImageContext { Height = 130, Width = 280, OriginalImage = pictureResult.Image });
if (resizeResult.TaskResult == TaskResult.Success)
{
Model.Logo = resizeResult.ResizedImage;
}
Platform implementations:
Android:
DependencyService.Register<IResizeImageCommand, AndroidResizeImageCommand>();
iOS
DependencyService.Register<IResizeImageCommand, iOSImageResizeCommand>();
UWP:
DependencyService.Register<IResizeImageCommand, UWPResizeImageCommand>();
For anyone looking for a much more comprehensive image library that is .NET standard compliant, check out https://github.com/SixLabors/ImageSharp