Resize image in byte[] using Syncfusion

Ganesh Gebhard 366 Reputation points


I have an app (Android & iOS) with a camera function. With this function, the user can simply click on a button to open te camera app, take a picture and this picture is then send to the server with an API:


Now I have a new camera function with an in-app camera (so that the camera app isn't needed anymore). Now the user can take a picture, which is then showed in Syncfusion image editor (rotation and cropping). This image should then be send to the API:


Now I have the following problem: the picture size is too big and the system rejects pictures which are too big.
You can see in the first image that I resize the picture to medium so that the system can handle the image. If I don't do this, the image will simply not be send to the server. Problem is that I have no idea how to do this resizing in the new camera function.

Anyone that can help?

Best regards,

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,291 questions
{count} votes

Accepted answer
  1. JarvanZhang 23,936 Reputation points


    Welcome to our Microsoft Q&A platform!

    Was the byte array not compressed? How did you pass the image byte arrary when calling DependencyService method?

    Try using the code like following:

       var stream = args.Stream;  
       byte[] bytes = stream.ReadAllBytes();  
       var compressed_bytes = DependencyService.Get<TheInterface>.ResizeImageAndroid(bytes,the_width,the_height);  

    Best Regards,

    Jarvan Zhang

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful