I need some help related to image sizing in Xamarin Farms Cross PlatForm.

Salman Paul 21 Reputation points
2020-07-15T13:02:13.907+00:00

I need some help related to image sizing in Xamarin Farms Cross PlatForm.
I have taken the picture from my mobile using the Plugin.Media. Its generate the image in my mobile with the size of 1.42 MB and Resolution 2160x2160. I need to upload this image using Rest API. First thing is this is it possible that this size decrease to kbs?

Second thing is this i use the Xamarin.Plugin.ImageEditer to change the image size to 768x1024. It change the image size but the size is still in 1MB. The code is as following.

private async Task<byte[]> ResizeImage(string ImagePath)
{

        FileStream fs = new FileStream(ImagePath, FileMode.Open, FileAccess.Read);

        using (var image = await CrossImageEdit.Current.CreateImageAsync(fs))
        {
            var imgReSiz = await Task.Run(() =&gt;
                    image.Resize(768, 1024)
                         .ToPng()
            );
            return imgReSiz;


        }


    }

What i can do to set the image size not more then 100kb?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,116 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Laude 85,816 Reputation points
    2020-07-15T13:04:14.767+00:00

    Hi,

    Xamarin is currently not supported in the Q&A forums, the supported products are listed over here https://video2.skills-academy.com/en-us/answers/products (more to be added later on).

    You can ask the experts in the dedicated Xamarin forum over here:
    https://forums.xamarin.com/

    (Please don't forget to accept helpful replies as answer)

    Best regards,
    Leon

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.