How to resize images in xamarin.forms?

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);

Leave a Comment