Resize image in byte[] using Syncfusion

Ganesh Gebhard 366 Reputation points
2020-12-04T11:23:31.18+00:00

Hey!

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:

45213-image.png

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:

45119-image.png

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,
Ganesh

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

Accepted answer
  1. JarvanZhang 23,961 Reputation points
    2020-12-09T08:05:22.523+00:00

    Hello,​

    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

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.