Open merry-mongoose opened 4 years ago
Is this repo dead?
Same issue!
facing the same issue. Can anyone help?
Same. :)
Test functions that work. You could also extend BMP to read the file bytes.
Platform file is the same as "File" from Dart IO.
bool isHeic(PlatformFile platformFile) {
final heicBytes = [0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63];
if (kIsWeb || platformFile.bytes != null) {
final bytes = platformFile.bytes!;
if (listEquals(heicBytes, [bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]])) {
return true;
}
}
if (platformFile.path != null) {
// Better to read path first, some platforms you can't load bytes.
if (platformFile.path!.toLowerCase().contains("heic")) {
return true;
}
}
return false;
}
bool isBmp(PlatformFile platformFile) {
final bmpBytes = [0x42, 0x4d];
if (kIsWeb || platformFile.bytes != null) {
final bytes = platformFile.bytes!;
if (listEquals(bmpBytes, [bytes[0], bytes[1]])) {
return true;
}
}
return false;
}
The original image format is HEIC on iOS. The mime of this file type has registered at https://www.iana.org/assignments/media-types/media-types.xhtml but lookupMimeType method returned null currently. Thanks