0

I'm having trouble with HEIC image format in my team's project. Currently we are grabbing the bytearray of the image date and displaying it into our mobile app, but other issues occur when we want to do more with the image format.

Is it possible to convert the HEIC bytearray to some other format like PNG bytearray?

Here's what I got

private async Task ProcessPhotos(IList<Models.MediaFile> mediaFiles)
        {
            Debug.WriteLine(DateTime.Now.CurrentTimeWithMilliSeconds(), "Process Photos Start");

            foreach (var mediaFile in mediaFiles)
            {
                var editImageModel = new EditImageModel();

                editImageModel.SourceImage = System.IO.File.ReadAllBytes(mediaFile.Path);
                editImageModel.EditedImage = editImageModel.SourceImage;
                /*I want to convert the bytearray here*/

                await ProcessUpdatedImage(editImageModel);
            }

            Debug.WriteLine(DateTime.Now.CurrentTimeWithMilliSeconds(), "Process Photos End");
        }
Anthony R
  • 89
  • 1
  • 10
  • You can do this using ImageMagick. See the duplicate. –  Jan 30 '20 at 16:46
  • 1
    Maybe I put the wrong tags but that solution wont work in a mobile environment. – Anthony R Jan 30 '20 at 19:50
  • Why wouldn't it work in a mobile environment? ImageMagick (or rather Magick.NET) has a .NET Standard version, which should be supported by Xamarin. – Heretic Monkey Jan 30 '20 at 20:03
  • 1
    I thought the same but I've been reading the Readme and the issues and I found out that the libraries it uses is not compatible with ARM processors. I just would like to see if they are other solutions that doesn't require me to write more libraries in my project. @HereticMonkey.... I get this error when I use their basic example: System.TypeInitializationException: The type initializer for 'NativeMagickSettings' threw an exception. ---> System.DllNotFoundException: Magick.Native-Q16-x64.dll assembly: type: member:(null) – Anthony R Jan 30 '20 at 20:21
  • @Anthony, Do you try this way:https://stackoverflow.com/questions/54103811/converting-an-heic-image-to-jpg-and-upload-to-the-server-in-xamarin-ios – Cherry Bu - MSFT Feb 03 '20 at 07:45
  • Solution for the same is provided here : [We can save desired format from saving image stream as shown below](https://stackoverflow.com/a/64137712/13017111) – Nidhi Kayasth Sep 30 '20 at 12:46

0 Answers0