[image_picker] Exif data are lost when the image is resized on web
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
1. Run `flutter run -d chrome` on the code sample
2. Click on "Upload image" to upload an image with exif data.
3. Notice that when the image is resized, the exif data are missing.
### Expected results
I would expect to still have access to the exif data after the image go resized.
### Actual results
The exif data are lost when the image is resized.
### Code sample
Code sample
You can also checkout https://github.com/ValentinVignal/flutter_app_stable/tree/image-picker/no-exif
```dart
import 'package:exif/exif.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: FilledButton(
onPressed: () async {
final picker = ImagePicker();
final file = await picker.pickImage(
source: ImageSource.gallery,
// imageQuality: 50, // <- Uncomment this line.
);
if (file == null) return;
final exif = await readExifFromBytes(await file.readAsBytes());
print(exif);
},
child: const Text('Upload image'),
),
)),
);
}
}
```
### Screenshots or Video
Screenshots / Video demonstration
The image I used (I'm not sure whether it keeps the exif data when uploaded on GitHub)

### Logs
Logs
The first log is when the image was not resized:
```console
{Image ImageDescription: Flutter Dash, Image ResolutionUnit: Pixels/Inch, Image DateTime: 2024:01:15 19:00:21, Image YCbCrPositioning: Centered, Image ExifOffset: 120, GPS GPSLatitudeRef: N, GPS GPSLatitude: [44, 29, 76078/1397], GPS GPSLongitudeRef: E, GPS GPSLongitude: [11, 19, 48947/1171], GPS GPSDate: 2024:01:15, Image GPSInfo: 256, EXIF ExifVersion: 0232, EXIF DateTimeOriginal: 2024:01:15 19:00:21, EXIF DateTimeDigitized: 2024:01:15 19:00:21, EXIF ComponentsConfiguration: YCbCr, EXIF UserComment: exif test, EXIF FlashPixVersion: 0100}
```
The second log is when the image was resized:
```console
{}
```
Full logs:
```console
Debug service listening on ws://127.0.0.1:56699/jd631futTYA=/ws
Connecting to VM Service at ws://127.0.0.1:56699/jd631futTYA=/ws
{Image ImageDescription: Flutter Dash, Image ResolutionUnit: Pixels/Inch, Image DateTime: 2024:01:15 19:00:21, Image YCbCrPositioning: Centered, Image ExifOffset: 120, GPS GPSLatitudeRef: N, GPS GPSLatitude: [44, 29, 76078/1397], GPS GPSLongitudeRef: E, GPS GPSLongitude: [11, 19, 48947/1171], GPS GPSDate: 2024:01:15, Image GPSInfo: 256, EXIF ExifVersion: 0232, EXIF DateTimeOriginal: 2024:01:15 19:00:21, EXIF DateTimeDigitized: 2024:01:15 19:00:21, EXIF ComponentsConfiguration: YCbCr, EXIF UserComment: exif test, EXIF FlashPixVersion: 0100}
Restarted application in 247ms.
{}
```
### Flutter Doctor output
Doctor output
```console
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.16.9, on macOS 14.0 23A344 darwin-x64, locale en-GB)
! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/3.2.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/valentin/flutter/flutter. Consider adding
/Users/valentin/flutter/flutter/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.85.1)
[✓] Connected device (2 available)
[✓] Network resources
! Doctor found issues in 1 category.
```
Contributor guide
Assessment
This issue has not been assessed yet.