I am trying to extract meta information from an image I upload locally. I want to extract the DateTime and LatLng and pre-fill a form for the user after uploading an image.
Extract exif meta image data from image (FFUploadedFile)
Custom Code
I am using the EXIF package available on pub.dev, and I created a custom action to get the information (without returning anything at this stage).
Usually the EXIF package uses the build in flutter image method .readasbytes, but unfortunately FFUploadedFile doesn't support that...
So far the exifData is empty, and I have no clue how to get to the bottom of this! If I get to the EXIF data, then I can return the desired information...
import 'package:exif/exif.dart';
Future printExifDataToConsole(FFUploadedFile? image) async {
// Extract Meta Data from Image (FFUploadedFile) and print to console
if (image == null) {
print('Image is null');
return; }
final bytes = image.bytes;
if (bytes == null) {
print('Image bytes are null');
return; }
final exifData = await readExifFromBytes(bytes);
if (exifData == null || exifData.isEmpty) {
print('No Exif data found');
return;
}
exifData.forEach((key, value) {
print('$key: $value');
});
}
Yes
2 replies