ko2ic / image_downloader

Flutter plugin that downloads images and movies on the Internet and saves to Photo Library on iOS or specified directory on Android.
https://pub.dartlang.org/packages/image_downloader#-readme-tab-
MIT License
92 stars 116 forks source link

Support for downloading and successfully saving HEIC images. #30

Closed KasemJaffer closed 5 years ago

KasemJaffer commented 5 years ago

Hello,

Thanks for the library it helped a lot. Can you support saving HEIC images on iOS? Currently it's throwing unsupported_file exception.

Here is how you identify the file is of HEIC format.

var values: UInt8 = 0
data.copyBytes(to: &values, count: 1)

switch values {

case 0x49, 0x4D:
     // image/tiff
case 0x00:
     if (data.count >= 12) {
        //....ftypheic ....ftypheix ....ftyphevc ....ftyphevx
        let testString =  String(data: data.subdata(in: 4..<12), encoding: .nonLossyASCII)
        if (testString == "ftypheic"
               || testString == "ftypheix"
               || testString == "ftyphevc"
               || testString == "ftyphevx") {
                    // image/heic
                    // TODO: Implement saving HEIC properly
          }
}

I tried to implement it myself but with no success. Would very much appreciate it if you find a way to save HEIC as is.

Thank you!

KasemJaffer commented 5 years ago

Just found a way and pushed a pull request. https://github.com/ko2ic/image_downloader/pull/31

ko2ic commented 5 years ago

The image widget of flutter does not support heic, so it was saved as jpeg. android is not compatible.