deckerst / aves

Aves is a gallery and metadata explorer app, built for Android with Flutter.
BSD 3-Clause "New" or "Revised" License
2.35k stars 91 forks source link

Changing date/time corrupts pictures #611

Closed aprunai closed 1 year ago

aprunai commented 1 year ago

Describe the bug Whenever I use the Modify -> Date and Time function on single or multiple pictures, they become black squares with "WEBP" written on them; no other app on the phone can display them. If I download them on my PC and open them with XnView, they are correctly displayed but their Exif data appears to be corrupt. I am attaching screenshots from both the app and XnView.

To Reproduce Steps to reproduce the behavior:

  1. Display a picture, or select one or more.
  2. Click on 'Modify -> Time and date"
  3. Leave the default choice, or set your preferred time and date.
  4. The picture has its time/date changed, but becomes a black thumbnail with "WEBP" written over it. If clicked upon, it displays "Ops". Its properties show that two fields have been added: "EXIF IFD0" and "EXIF SubIFD". The first one shows width and height equal to 0.

Expected behavior

The picture should remain intact and visible, and have just its date and time changed photo_2023-04-25_21-38-46 photo_2023-04-25_21-36-48 photo_2023-04-25_21-36-15 XnView_exif aves-logs-20230425_214035.txt .

Screenshots

Four screenshots are attached: three from the app and a fourth from XnView's picture properties.

System information and logs:

Package: deckers.thibault.aves.libre Installer: com.google.android.packageinstaller Aves version: 1.8.5-libre, build 9602 Flutter: stable 3.7.11 Android version: 10, API 29 Android build: MAR-L21B 10.0.0.276(C431E4R4P1) Device: HUAWEI MAR-LX1B Geocoder: ready Mobile services: not available System locales: it_IT, en_IT Storage volumes: /storage/2C4B-AF31/, /storage/emulated/0/ Storage grants: Error reporting: false

(complete log is attached)

Additional context

deckerst commented 1 year ago

Thanks for the report.

Could you attach a sample image before edit, and after edit?

Also, does it only happen with WEBP images?

deckerst commented 1 year ago

I see from your system info that Storage grants is empty. If you go to Settings > Privacy > Storage access, is it empty too? If so, could you please let me know in which directory the images you want to modify are?

aprunai commented 1 year ago

No, it happens with JPEG images as well; but the writing over the black thumbnail is still "WEBP". I am attaching the "before-after" pics. Note: I had a hard time moving them from phone to PC through Telegram, because it refused to share the modified pic with the error "Wrong photo width".

I gave the app writing permissions as soon as it asked for them, and I can copy/move/delete pictures on my SD card without problems; but when I try to do this with pictures residing in my internal memory, the app asks to give permissions to write on the root folder of my phone, which I give, and then asks again, endlessly.

Picture_original Picture_modified

aprunai commented 1 year ago

Also, I just noticed that if I select a modified JPG and choose "Modify -> Clear metadata", I get the error "This operation is not supported for elements of the type: WEBP".

deckerst commented 1 year ago

when I try to do this with pictures residing in my internal memory, the app asks to give permissions to write on the root folder of my phone, which I give, and then asks again, endlessly.

Then something is unusual with permissions on your device. That's the heart of the problem. Do you use a custom rom by any chance?

aprunai commented 1 year ago

No, just stock Huawei, never modified. Other apps exhibit this behaviour when I use them to write on internal memory, so I leave it empty and only use my SD card, which works flawlessly. The corrupted pictures all reside on my SD, and I can copy, move and delete them with Aves, no problem. Archive authorizations have been granted to the app; I am attaching a screenshot.

photo_2023-04-25_22-38-45

deckerst commented 1 year ago

Other apps exhibit this behaviour when I use them to write on internal memory

And you don't think your device OS should be fixed? ^^

Archive authorizations have been granted to the app; I am attaching a screenshot.

Thanks, but I was talking about a different kind of permissions. You can see them in the Aves app itself, under Settings > Privacy > Storage access.

aprunai commented 1 year ago

Other apps exhibit this behaviour when I use them to write on internal memory

And you don't think your device OS should be fixed? ^^

I am going to fix it by buying a Samsung device next :D I learned not to argue with Chinese phones, they're as impenetrable as the Great Wall...

Archive authorizations have been granted to the app; I am attaching a screenshot.

Thanks, but I was talking about a different kind of permissions. You can see them in the Aves app itself, under Settings > Privacy > Storage access.

Oh, I understand. As I said, the app asked for archive authorizations twice: when I opened it first, which went well, and when I tried deleting a pic on my internal memory, which ended in a loop of requests. Maybe it's something from Huawei? Cannot fix that without rooting my phone, I fear.

deckerst commented 1 year ago

The permissions I am talking about are volume specific (and directory specific for newer Android versions). So I understood you could not give permission for the root of the internal memory volume. But to modify items on the SD card volume, the app should ask to give permission to the root of the SD card (different from the internal memory root). Without giving this permission, you should not be able to move or delete items on the SD card. And if you gave it, it should appear in the privacy settings of Aves I pointed above.

aprunai commented 1 year ago

OK. For as little as I know about Android and apps, I remember permissions for archive writing are encoded in the app's manifest and the OS asks for them as soon as it sees the app needs them; so those have been given correctly at the app's first run. When writing on internal storage (/storage/emulated/0 I believe), the app asks autonomously for permission as a "special directory". I just tried allowing the app to write on a new folder I created on the internal memory through a file manager (not the root, just the new folder), and the requester loop repeated.

aprunai commented 1 year ago

Nice!! I managed to fix the pictures through XnView! I used the "delete EXIF data" in the software, reuploaded the picture on the phone and... voila! I believe the extra EXIF data is the culprit. The 'info' section in Aves now doesn't show the two extra fields ("Exif IFD0" and "Exif SubIFD") anymore, just the "WebP" that is normally present on every other picture, JPEG included.

deckerst commented 1 year ago

permissions for archive writing are encoded in the app's manifest and the OS asks for them as soon as it sees the app needs them

Kind of true in the past, but it's more complex with newer versions, and writing on SD card always requires some extra permission not in the manifest. Anyway, it doesn't matter because I believe you're right that this issue is unrelated with the weird permission system on your device.

Nice!! I managed to fix the pictures through XnView!

Great, I'm glad you didn't lose your images because of Aves.

just the "WebP" that is normally present on every other picture, JPEG included

The WebP metadata should not be in JPEG images. Only in WEBP images.

Could you try this build (play version)? It will install as "Aves [Profile]", and changing your settings in that build won't change your settings in your standard "Aves". This build is not supposed to make it work on your device, but it should prevent messing up the file. So could you please confirm that when you try to edit the date, it now shows a failure message, and leave the file as it is?

aprunai commented 1 year ago

permissions for archive writing are encoded in the app's manifest and the OS asks for them as soon as it sees the app needs them

Kind of true in the past, but it's more complex with newer versions, and writing on SD card always requires some extra permission not in the manifest. Anyway, it doesn't matter because I believe you're right that this issue is unrelated with the weird permission system on your device.

To be honest, not all apps have problems writing to internal memory; file managers, camera apps and lots of others show no problems. Others meet with some weird authorization problems.

Now that I think about it, those are all apps I installed through F-Droid... maybe there's a connection?

Nice!! I managed to fix the pictures through XnView!

Great, I'm glad you didn't lose your images because of Aves.

Same πŸ˜‰

just the "WebP" that is normally present on every other picture, JPEG included

The WebP metadata should not be in JPEG images. Only in WEBP images.

Could you try this build? It will install as "Aves [Profile]", and changing your settings in that build won't change your settings in your standard "Aves". This build is not supposed to make it work on your device, but it should prevent messing up the file. So could you please confirm that when you try to edit the date, it now shows a failure message, and leave the file as it is?

Uhm... no. In fact, it works flawlessly 😁 I changed time and date for three pictures and they regularly took the new information, even changing place in my collection according to the new time and date!

aprunai commented 1 year ago

I'm getting "the file could have been deleted" from both links...

deckerst commented 1 year ago

I'm getting "the file could have been deleted" from both links...

Sorry, I had uploaded the wrong files, so I quickly deleted my comment and the files. I've just reuploaded the right ones, see below.

In fact, it works flawlessly

I don't understand how it's possible... The build I gave you is the play version, but it should behave exactly the same as the libre version when it comes to file editing.

If you're willing to try, here are the profile builds for the libre version (i don't know whether your device accepts arm64 or not, so here are both ABIs):

aprunai commented 1 year ago

I just installed the "arm64-v8a-libre" version. This works fine as well: I modified time and date to one of my pictures and the app accepted it, putting the image in the right place in my collection based on its new time. By the way, I noticed that the "Exif IFD0" and "Exif SubIFD" fields are added again, but the resolution is correctly reported now. I am attaching a screenshot from the version you sent to me. Screenshot_20230427_131429_deckers thibault aves libre profile

deckerst commented 1 year ago

Well, I don't understand why it's fixed. But if it works fine now, I'll take it.