cloudacy / native_exif

A simple EXIF metadata reader/writer for Flutter.
MIT License
16 stars 15 forks source link

EXIF data not being written to image #30

Closed CYBERDEVILZ closed 9 months ago

CYBERDEVILZ commented 9 months ago

Hi there, I want to add a custom EXIF data to image selected from gallery. This is the code I have written that sets the "UserComment" attribute to "logoboa".

final Exif exif = await Exif.fromPath("${storage.path}/logo.png");
await exif.writeAttribute("UserComment", "logoboa");
print(await exif.getAttributes());
await exif.close();

When I print using exif.getAttributes(), i find that the attribute has been set as seen below: {UserComment: logoboa, ImageWidth: 0, ImageLength: 0, Orientation: 0}

Now when i load the image later, i see that the changes are not being made:

// get the image path
String path = _image!.path;
final Exif exif = await Exif.fromPath(path);
final data = await exif.getAttributes();
print(data);

The data printed does not contain "UserComment" attribute as seen below: {ImageWidth: 0, ImageLength: 0, Orientation: 0}

Device being used is an Android Emulator. What am I doing wrong here?

d-kuen commented 9 months ago

Hi,

I performed a similar test (PNG image, android emulator (API 33), same order of instructions) but could not reproduce the described behavior.

I would recommend to check if it's actually the same image. Some image modifications, like resizing, could cause cleared EXIF data. Did you try to reproduce this issue with the example app?

CYBERDEVILZ commented 9 months ago

Aaaah my bad! I was saving the image twice, one was original and the other was with modified exif. Thanks, works like charm!