Skip to content

Commit d472779

Browse files
committed
Fixed heic to jpg
1 parent f1d45fa commit d472779

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

lib/utils/image_actions.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Future<File> compressImage(File file,
5858
return file;
5959
}
6060

61+
// Deprecated
6162
Future<List<XFile>?> onPickFiles() async {
6263
try {
6364
FilePicker.platform.clearTemporaryFiles();
@@ -110,6 +111,14 @@ Future<List<XFile>?> onPickImages() async {
110111
imageQuality: (Preferences.getUploadQuality * 100).round(),
111112
requestFullMetadata: !Preferences.getRemoveMetadata,
112113
);
114+
for (var file in files) {
115+
if (file.name.endsWith('.heic')) {
116+
String? jpgPath = await HeicToJpg.convert(file.path);
117+
if (jpgPath != null) {
118+
files[files.indexWhere((f) => f == file)] = XFile(jpgPath);
119+
}
120+
}
121+
}
113122
return files;
114123
} catch (e) {
115124
debugPrint('${e.toString()}');
@@ -132,6 +141,12 @@ Future<XFile?> onTakePhoto(BuildContext context) async {
132141
imageQuality: (Preferences.getUploadQuality * 100).round(),
133142
requestFullMetadata: !Preferences.getRemoveMetadata,
134143
);
144+
if (image != null) {
145+
String? jpgPath = await HeicToJpg.convert(image.path);
146+
if (jpgPath != null) {
147+
image = XFile(jpgPath);
148+
}
149+
}
135150
break;
136151
case 1:
137152
image = await _picker.pickVideo(source: ImageSource.camera);

0 commit comments

Comments
 (0)