-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
My android app now fails to load png chosen from the library using the image picker
It appears the path has changed in 0.8.5+8 image_picker_android and now appends ".jpg" even when its an ".png" file
The code:
XFile? file = await ImagePicker().pickImage(source: ImageSource.gallery);
...
imglib.Command cmd = imglib.Command()
..decodeImageFile(file.path)
..bakeOrientation()
..encodePngFile(newImagePath);
await cmd.executeThread();
Good config:
image_picker_android: 0.8.5+7
Debug output:
I/flutter ( 6460): Loading Image /data/user/0/app.reimage/cache/image_picker2780929013025073694.png
Bad config:
image_picker_android: 0.8.5+8
Debug output:
I/flutter ( 6927): Loading image /data/user/0/app.reimage/cache/054874a4-f2d8-4a15-b777-2fe505469ded/1000000070.jpg
...
E/flutter ( 4584): ImageException: Start Of Image marker not found.
E/flutter ( 4584): #0 JpegData._read (package:image/src/formats/jpeg/jpeg_data.dart:181:7)
E/flutter ( 4584): #1 JpegData.read (package:image/src/formats/jpeg/jpeg_data.dart:154:5)
E/flutter ( 4584): #2 JpegDecoder.decode (package:image/src/formats/jpeg_decoder.dart:44:30)
E/flutter ( 4584): #3 decodeImageFile (package:image/src/formats/formats.dart:204:20)
E/flutter ( 4584):
E/flutter ( 4584): #4 DecodeImageFileCmd.executeCommand (package:image/src/command/formats/decode_image_file_cmd.dart:12:19)
...
The exception is because its not a jpg, but a png.
According to the photos app and "My Files" the name is 1677861994058.png
Something in 0.8.5+8 has changed the location and name of the file path in the cache of the chosen image
This is the change in question:
flutter/packages@1e396f9
I believe the issue lies in the getImageName() method, as the cache filepath does not include the string "image_picker"
I don't know why/how getImageName() is returning 1000000070.jpg
I cant find any file named this, not sure where that is coming from.