muak / Xamarin.Plugin.ImageEdit

Image Edit Plugin for Xamarin
MIT License
55 stars 16 forks source link

Resize also rotate image #14

Open t30n3 opened 5 years ago

t30n3 commented 5 years ago

Hello, I'm using this plugin to resize images loaded via picker on a XF app. In Android, when I pick an image and execute the following code the image is correctly resized but it is also rotated.

using (IEditableImage image = await CrossImageEdit.Current.CreateImageAsync(stream))
 {
    byte[] byteArray = await Task.Run(() => image.Resize(700).ToPng());

    using (Stream outStream = File.OpenWrite(newFileName))
    {
        outStream.Write(byteArray, 0, byteArray.Length);
        outStream.Flush();
        outStream.Close();
     }
}

I also tried the following code but the result is the same:

byte[] byteArray;

if (image.Width >= image.Height)
    byteArray = await Task.Run(() => image.Resize(700, 0).ToPng());
else
    byteArray = await Task.Run(() => image.Resize(0, 700).ToPng());

using (Stream outStream = File.OpenWrite(newFileName))
{
    outStream.Write(byteArray, 0, byteArray.Length);
    outStream.Flush();
    outStream.Close();
}

Thanks in advance, Matteo

praveennachi60 commented 4 years ago

Hi @muak . May I know how to get an image path after rotated?

Code: someimage.rotate(90);

How to get this image?