flutter_photo_manager
flutter_photo_manager copied to clipboard
[Help] Get File from thumbnail
Is there a way to get file from the thumbnail?
tried this but doesn't work
Uint8List? list = await assetEntity.thumbDataWithSize(400, 400);
File file = File.fromRawPath(list!);
You can create a new File
object at a desired path, and call writeAsBytes with the thumbnail data.
Yea i tried that and it works, but seems like i would store double the files. one from the package itself when it creates thumbnails and then another copy of my own in the temp directory. Can it be a feature request to have a method like getFileFromThumbnail()
?
You could perhaps delete the one you have generated after you've made use of it?
If you could explain your exact use case, it would make it easier to suggest a solution.
My use case is that i need File
as input for google_ml_kit package for ML processing.
My concern is not just the space but also the time taken for saving the file. it would definitely be faster if i can get access to the thumbnail file directly, rather than writing to file then reading it again. I am trying to optimize the process because there can be scenarios of 100s of images.
AFAIK the InputImage
accept Uint8List
.
yes i am aware of that too but i am not sure about InputImageData
https://pub.dev/documentation/google_ml_kit/latest/google_ml_kit/InputImageData-class.html.
Particularly these
inputImageFormat → InputImageFormat Format of the input image. final planeData → List<InputImagePlaneMetadata>? The plane attributes to create the image buffer on iOS. [...] final
Bytes do not have these data. And also AssetEntity
might not have all of it either
You can use the .file
getter at present for your request, though it didn't provide any thumbnail options.
You can use the
.file
getter at present for your request, though it didn't provide any thumbnail options.
Yup i tried that too but the file is unnecessarily large, causing ML Kit results to be slow. So for my case, using the full file is not an option.
tried this but doesn't work
Uint8List? list = await assetEntity.thumbDataWithSize(400, 400); File file = File.fromRawPath(list!);
Regarding the first question, how it behave when you said doesn't work
?
Uint8List? list = await assetEntity.thumbDataWithSize(400, 400);
File file = File.fromRawPath(list!);
print(file.path);
print(await file.readAsBytes());
Output:
Can you make a minimal repo that includes ML Kit and this plugin to reproduce this issue?
Hello, were you able to come up with a solution? I have the same use-case of wanting to use a file with ml kit but without the lengthy load times of .file with large files.
See comments above. InputImage
accepts Uint8List
.