I
Immichโ€ข3y ago
satish

Duplicate images being created

Background information: the service was hosted on the pi4, then moved to a proper x86 platform. I already sat and cleaned up quite a bit of images, but i do have a few images which I didnt clean up. These images can be viewed here: https://immich.assid.com/share/1561aad560df0883e93057ca88a435e78926d2f48c4e835e9b1cae30b7ab1daaf8b230b6c6f4212cb792b1f17ff6bae26a69 Example with 1 file: find . -name 20221211_184746.heic ./mediaassets/library/06de71da-123e-4733-9448-77196690ac16/2022/2022-12-11/20221211_184746.heic Only 1 file found Exif extract provided
Public Share
Duplicate images being uploaded
118 Replies
satish
satishOPโ€ข3y ago
jrasm91
jrasm91โ€ข3y ago
Can't easily check on my phone, but I can verify tomorrow. My guess is one has gps data and one does not.
satish
satishOPโ€ข3y ago
there is only 1 physical file find . -name "20221211_184746*" ./mediaassets/library/06de71da-123e-4733-9448-77196690ac16/2022/2022-12-11/20221211_184746+1.heic ./mediaassets/library/06de71da-123e-4733-9448-77196690ac16/2022/2022-12-11/20221211_184746.heic apparently the new file is called +1 .. how / why would that be generated
jrasm91
jrasm91โ€ข3y ago
For example, You can upload a file, then edit the exif and upload it again It is not the same file anymore
satish
satishOPโ€ข3y ago
only uploading via the mobile device.. no changes are done on device level
jrasm91
jrasm91โ€ข3y ago
Phones will strip gps data if location permission isn't enabled for the app
satish
satishOPโ€ข3y ago
the gps data exists
jrasm91
jrasm91โ€ข3y ago
On both?
satish
satishOPโ€ข3y ago
no.. but there is only supposed to be 1 image
jrasm91
jrasm91โ€ข3y ago
I think you have two versions. One with gps data and one without
satish
satishOPโ€ข3y ago
not on my phone or google photos
jrasm91
jrasm91โ€ข3y ago
Yeah, I understand that, but I'm pretty sure the same file has been uploaded twice to immich
satish
satishOPโ€ข3y ago
heres what i think can happen
jrasm91
jrasm91โ€ข3y ago
And it didn't deduplicate it because one had location data stripped out because the location permission wasn't included.
satish
satishOPโ€ข3y ago
the original file which was uploaded initially.. has GPS data .. along with shutter speed then.. i must have logged out.. and logged back in .. during which .. it must have tried to re-sync.. and uploaded the data without the gps information and shutter speed the phone itself has only original image.. not 2
jrasm91
jrasm91โ€ข3y ago
Have you switched phones recently or anything like that? Iphone to Android?
satish
satishOPโ€ข3y ago
no.. i did logout / login multiple times.. and i also changed from the pi4 to x64 system
jrasm91
jrasm91โ€ข3y ago
Did you recreate immich or just migrate hardware?
satish
satishOPโ€ข3y ago
are you sure immich has no code to create a "+1" file i moved the sql database and media assets .. then i re-created my docker compose (since 1.51/1.52 changes with ML)
jrasm91
jrasm91โ€ข3y ago
The +1 comes from the storage template code
satish
satishOPโ€ข3y ago
ok.. so there you go.. its not device generated
jrasm91
jrasm91โ€ข3y ago
Correct, it was originally uploaded with the same name twice But it needs a different name to store it in the same directory
satish
satishOPโ€ข3y ago
we need to check when it was parsing the information during upload. Why didnt it check the exif data correctly because there is only 1 original file to upload.. so what changed
jrasm91
jrasm91โ€ข3y ago
I feel like i have said this a few times - if the location permission is not enabled for the app, Android will strip gps exif tags during upload automatically So that's definitely one possibility
satish
satishOPโ€ข3y ago
oh.. so even if the file exists with the exif information and uploaded as a blob/binary.. Android still strips it ?
jrasm91
jrasm91โ€ข3y ago
Have you reinstalled from another source? APK vs fdroid vs play store? Yes, truly annoying
satish
satishOPโ€ข3y ago
yeah.. i used to have the fdroid version.. then moved to play store..
jrasm91
jrasm91โ€ข3y ago
When you did that, it tried to reupload all the assets again.
satish
satishOPโ€ข3y ago
i couldnt wrap my head around this. is there an easy way to clean this up?
jrasm91
jrasm91โ€ข3y ago
Spend how many duplicates
satish
satishOPโ€ข3y ago
also can we add a permission check in the app on startup ? i cleaned up around 100 yesterday but i dont know if i deleted the original or the stipped one
jrasm91
jrasm91โ€ข3y ago
Possibly, you can ask in general chat maybe. Or open a bug about it You can SQL query for exif Are you proficient with SQL?
satish
satishOPโ€ข3y ago
i could also query for +1.heic files
jrasm91
jrasm91โ€ข3y ago
Here is what I would do Query for assets with the same device asset id Join with the exif table and check for gps data There should be two records for a single device asset id and hopefully one has gps and one does not
satish
satishOPโ€ข3y ago
but then i need to be able to delete those phgysical files as well right
jrasm91
jrasm91โ€ข3y ago
You could see how many there are at least You could always start over if that is easier, or maybe do an API call to bulk delete You could potentially select the IDs to delete and then send a http request to delete them, which would clean up the files Well, it's past my bedtime ๐Ÿ˜›. Let me know how it goes. Happy to help tomorrow if you're still stuck.
satish
satishOPโ€ข3y ago
much appreciated I think these guys are tired with the number of issues i keep running into ๐Ÿ˜›
jrasm91
jrasm91โ€ข3y ago
Lol you seem to be finding lots of bugs. Did you figure out oauth btw?
satish
satishOPโ€ข3y ago
yep
jrasm91
jrasm91โ€ข3y ago
Sweet
satish
satishOPโ€ข3y ago
apparently .. dont use regex even though it says it can handle it in authentik.. And dont enable "MOBILE REDIRECT URI OVERRIDE" in immich xargs -I{} rm -r "{}" < /ssdroot/data/immich/deleteme # -- delete the files delete from assets where "id" in ( select "assetId" from exif where "model" = 'SM-S906E' and "latitude" is null) ; # delete the records to the files Ensure proper permissions in the app, then backup (reupload.. Lets see if this solves the problem ok heres something interesting.. as i see it populate the gallery once again. Some images on the same date have gps information and some dont.. do you think it could be a difference in the background / foreground backup services ?
jrasm91
jrasm91โ€ข3y ago
Do you currently have the location permission enabled in Immich?
satish
satishOPโ€ข3y ago
yes
jrasm91
jrasm91โ€ข3y ago
Did it detect new images to reupload?
satish
satishOPโ€ข3y ago
after i deleted those images.. yes.. i could see those images being populated from another phone
jrasm91
jrasm91โ€ข3y ago
They got reuploaded again?
satish
satishOPโ€ข3y ago
yes.. cause i deleted those records and files remember
jrasm91
jrasm91โ€ข3y ago
You deleted the ones without gps, right?
satish
satishOPโ€ข3y ago
these and i did specific for this phone.. cause i have all my images since the time i got this device
jrasm91
jrasm91โ€ข3y ago
Did it upload all the same ones? That you just removed?
satish
satishOPโ€ข3y ago
yep. i saw it repopulate wait i;ll check if theres duplicates now nope.. those re gone i see some videos that are duplicate though..
jrasm91
jrasm91โ€ข3y ago
Problem solved? Or you have more dupes?
satish
satishOPโ€ข3y ago
video dupes still exist
jrasm91
jrasm91โ€ข3y ago
Is one missing gps?
satish
satishOPโ€ข3y ago
yep
satish
satishOPโ€ข3y ago
jrasm91
jrasm91โ€ข3y ago
Are the device asset IDs different?
satish
satishOPโ€ข3y ago
same
jrasm91
jrasm91โ€ข3y ago
Can you query the asset table and group by device asset id
satish
satishOPโ€ข3y ago
can you make the query you want me to run ?
jrasm91
jrasm91โ€ข3y ago
I can try, still on my phone lol Select id, count (*) from assets group by deviceAssetId
satish
satishOPโ€ข3y ago
Select "id", count ("deviceAssetId") from assets group by "deviceAssetId","id" having count("deviceAssetId") > 1; (0 rows)
jrasm91
jrasm91โ€ข3y ago
Hmm but you definitely have two videos with the same device asset id?
satish
satishOPโ€ข3y ago
yes that query is wrong
jrasm91
jrasm91โ€ข3y ago
You should not be grouping by id
satish
satishOPโ€ข3y ago
immich=> Select id,count ("deviceAssetId") from assets group by "deviceAssetId" having count("deviceAssetId") > 1; ERROR: column "assets.id" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: Select id,count ("deviceAssetId") from assets group by "dev...
jrasm91
jrasm91โ€ข3y ago
Maybe removing the having and add order by 2 Oh, i see. Remove id from the select
satish
satishOPโ€ข3y ago
that shows a lot of records
jrasm91
jrasm91โ€ข3y ago
How many are over one?
satish
satishOPโ€ข3y ago
all if i do Select count ("deviceAssetId") from assets group by "deviceAssetId" having count("deviceAssetId") > 1; then i;ll get 2 2 2 2 2 2
jrasm91
jrasm91โ€ข3y ago
Cool Can you see/count those results?
satish
satishOPโ€ข3y ago
64 rows
jrasm91
jrasm91โ€ข3y ago
Not too bad
satish
satishOPโ€ข3y ago
yeah its whatever in the middle that got screwed im guessing when i moved from f-droid to play store
jrasm91
jrasm91โ€ข3y ago
Can you do another query of select where gps is null and device asset id in that list? Should be able to use where device asset id in a sub select of that query we just did
satish
satishOPโ€ข3y ago
664 rows
jrasm91
jrasm91โ€ข3y ago
It is interesting though, same device asset id and same filename and same date. We might be able to detect that and auto recommend fixing
satish
satishOPโ€ข3y ago
however.. there is no way to check if its from my phone .. or older since the video data doesnt mention model number
jrasm91
jrasm91โ€ข3y ago
Are there 600 dupes or 60 dupes?
satish
satishOPโ€ข3y ago
600 dupes no..
jrasm91
jrasm91โ€ข3y ago
Ah.
satish
satishOPโ€ข3y ago
600 records without GPS data which are video (fps=30)
jrasm91
jrasm91โ€ข3y ago
You need to specifically look at only records from our duplicate device asset id query
satish
satishOPโ€ข3y ago
select "assetId" from exif where "fps" = 30 and "latitude" is null and "dateTimeOriginal" > '2022-09-01'::timestamptz; -- 62
jrasm91
jrasm91โ€ข3y ago
I think the best way is to find duplicate device asset IDs and target those records
satish
satishOPโ€ข3y ago
yeah.. or i;ll just sit down this sunday and just quickly see videos which look wrong and just delete it in the web interface..
jrasm91
jrasm91โ€ข3y ago
That works too ๐Ÿ˜
satish
satishOPโ€ข3y ago
its only 60+ . and i wont have to deal with re-uploading
jrasm91
jrasm91โ€ข3y ago
It's 64 results for the duplicate device asset id, right?
satish
satishOPโ€ข3y ago
yep .. i think so
jrasm91
jrasm91โ€ข3y ago
Yeah, that's pretty small
satish
satishOPโ€ข3y ago
alteast the orinal 150+ images are cleaned up.. and i had manually cleaned aroud 100 before
jrasm91
jrasm91โ€ข3y ago
Just make sure to delete the ones without gps
satish
satishOPโ€ข3y ago
yeah.. that means i need to click... see info.. then delete .. and then move on if the ui had a info available on "select" .. then i could have saved a lot more time.. i think the application should have a location permission check on startup.. and pre-hash and posthash check to make sure the right files are being uploaded
jrasm91
jrasm91โ€ข3y ago
The problem is, if permission is disabled when you read the file to complete the hash the location data is already missing
satish
satishOPโ€ข3y ago
exactly.. thats why i said location permission check on app startup
jrasm91
jrasm91โ€ข3y ago
Yeah that one is doable, but you can't detect this problem with a hash
satish
satishOPโ€ข3y ago
yeah its taking my brain alot of stress to undertand the app not being able to read the location data.. even though it has access to the file itself
jrasm91
jrasm91โ€ข3y ago
It's a privacy "feature" implemented at the operating system level on some phones
satish
satishOPโ€ข3y ago
i keep thinking it has file access.. it has file access
jrasm91
jrasm91โ€ข3y ago
The very fs.readFile returns different data depending on that permission
satish
satishOPโ€ข3y ago
yeah well i think a mandatory location permissions check on startup with a manual setting to keep ti disabled for people who dont want location data .. should definitely help in this.
jrasm91
jrasm91โ€ข3y ago
Why don't you open a feature request on GitHub about asking for location permission or an option to require it in the settings that defaults to true or something
satish
satishOPโ€ข3y ago
cause i think half the people in the group are a bit tired of dealing with my crazy problems ๐Ÿ˜›
jrasm91
jrasm91โ€ข3y ago
You are correct in that several people have run into this now and it is super annoying and also hard to understand
satish
satishOPโ€ข3y ago
and not everyone would be able to clean up the data the way i did for images..
jrasm91
jrasm91โ€ข3y ago
Correct. I think a good feature would be to extend duplication to detect stuff like this and have a page to show them with some options to auto clean.
satish
satishOPโ€ข3y ago
yep and to avoid it happening in the first place
jrasm91
jrasm91โ€ข3y ago
There obviously preferred ๐Ÿ˜›
satish
satishOPโ€ข3y ago
but tell me this.. i had 2-3 images on the same day.. 1 was uploaded with EXIF .. other 2 were not and was re-uploaded why would that happen
jrasm91
jrasm91โ€ข3y ago
I've never seen that. It is possible there were uploaded with exif, but it was missing from the database because of an error extracting it or the server was shutdown while it was in the queue.
satish
satishOPโ€ข3y ago
not 1 .. but quite a few were like that
jrasm91
jrasm91โ€ข3y ago
You can always run extract metadata for missing
satish
satishOPโ€ข3y ago
as i said , i was seeing it populate from another phone in real time
jrasm91
jrasm91โ€ข3y ago
And check the microservices logs In immich?
satish
satishOPโ€ข3y ago
yes .
satish
satishOPโ€ข3y ago
GitHub
[Feature] Location Permission check on startup ยท immich-app immich ...
The feature I suggest there should be a check and popup on application launch to confirm Location permission is available. Incase a person doesnt want it. they can explicitly set " I dont want...
jrasm91
jrasm91โ€ข3y ago
Ty

Did you find this page helpful?