Search code examples
angularbase64jpegheic

How to convert a Heic image file to a Jpeg or Png in Angular for ngx-image-cropper to use?


Question - ngx-image-cropper doesn't accept Heic image files as it's '[imageChangedEvent]' input so how would I convert an Heic image file to a Jpeg or Png in Angular/typescript?

FYI - I'm loading images into ngx-image-cropper and it looks like it doesn't except Heic image files. Ngx-image-cropper is emitting a loadImageFailed() emitter if the file type is 'image/heic'.

Currently I open image files with a fileChangeEvent() from an input element, I guess I want to convert to a jpeg or png so that I can pass it to a the ngx-imge-cropper imageChangedEvent or it's base64 input?


Solution

  • There is one NPM package named Heic2any you can use this for image conversion.

    This answer might help you with image conversion. Please take a look into this

    Heic2any:

    Official doc

    NPM Package