WhatsApp images have an invalid creation date #9116
Replies: 22 comments 14 replies
-
Yeah, this is a bit weird but I don't think we have any reason to support photos from the year 10,000 or beyond. |
Beta Was this translation helpful? Give feedback.
-
I guess thinking further we should try to understand why the year on that photo was so wrong, and maybe handle that better? Was the image uploaded from the app? |
Beta Was this translation helpful? Give feedback.
-
Maybe #3547? |
Beta Was this translation helpful? Give feedback.
-
Most are forwarded photos and videos. No, It doesn't upload from the app. I used bulk upload docker CLI. |
Beta Was this translation helpful? Give feedback.
-
Whatsapp pictures management is shit. In this case date is indicated on filename. For instance |
Beta Was this translation helpful? Give feedback.
-
Whatsapp seems to be scrampling the EXIF on the file, so yes, metadata should be ignored if there is any. |
Beta Was this translation helpful? Give feedback.
-
Would anyone be kind enough to show the full output of exiftool on a WhatsApp image? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
The same happens with photos that are shared via Signal: all exif data is gone. |
Beta Was this translation helpful? Give feedback.
-
Just for information. Librephotos did a hacky solution for pictures with no metadata https://docs.librephotos.com/docs/user-guide/settings/date-rules It has a list of defined rules to extract dates from different places (standar exif tag, alternate tags, filename regex, etc). User may add some of that rules from a list and may assign different priority to each rule. |
Beta Was this translation helpful? Give feedback.
-
The issue still there, the parsing not works properly or at all. |
Beta Was this translation helpful? Give feedback.
-
if I edit an image manualy or using a script, to modify and fix the date for whatsapp images, how can I make immich take the new changes on considiration, I even moved the image to the correct folder structure in my immich library, but it still shows as the old date. |
Beta Was this translation helpful? Give feedback.
-
I have just discovered this issue after uploading around 50,000 images to a library. Maybe 20% of them are Whatsapp images that have the dates all wrong! Not I need to somehow bulk delete them from my immich library if anyone has any ideas. |
Beta Was this translation helpful? Give feedback.
-
Moving to feature request |
Beta Was this translation helpful? Give feedback.
-
I have made this script to perform the extraction and setting the date to |
Beta Was this translation helpful? Give feedback.
-
A batch-edit feature for file dates would solve something like 99% of the issues people describe with bad date metadata. I just looked at the file names of my local signal exports and they follow the pattern signal-YYYY-MM-DDHHmmSS.png. I could export them from signal, move them to my computer, batch fix them with exiftool and reimport them, but fixing it in the app would be a lot simpler. Immich knows how it wants the dates stored, and it already has support for editing dates and for setting a date for multiple files at once. Letting people shoot themselves in the foot using regexps (or something simplified) would be pretty simple. I expect to get some more computer time when my newborn gets a bit older, but I am not counting on it. When I do I can have a look at implementing it if there is any interest in having it mainstream. Even having a guesser would be simple enough. |
Beta Was this translation helpful? Give feedback.
-
At least as I'm seeing it, a given WhatsApp-downloaded image has a proscribed place in my iPhone's timeline. The challenge is, when I use the Immich app to synchronize the image, that place is lost. More, the behavior is undefined: On the Immich side, I can delete the picture and then re-synchronize it with the Immich app, and it will appear in a completely new arbitrary place (sometimes never to be found again). So I suppose the ask for the feature request for me would be, "in the absence of EXIF data, use the date from the device's timeline for the Immich timeline." That way when I take pictures at a birthday party, and my wife takes pictures too and sends them to me by WhatsApp, they'll all be predictably together, like they are on my phone, to be the same in the Immich timeline. In the meantime I found another app that synchronizes them to my server by SFTP with the timeline-based mtime preserved, which also solved the problem in a somewhat messy way. |
Beta Was this translation helpful? Give feedback.
-
Are Whatsapp borked dates causing disappearing timelines? |
Beta Was this translation helpful? Give feedback.
-
Given that this is a generic problem for WhatsApp images, and we don't want to fix the problem at the client (such as suggested by #18243) perhaps we add an optional feature that lets the import handle WhatApp files (identified by filename) both from client, web and import as they are added into the database |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I'm currently using a script that uses the immich API to get all information about files with WhatsApp filenames and then compares immich's date with the filename. If they differ it overwrites dateTimeOriginal. This worked fine one the first files I tested it with. My code is not very nice and it's Powershell but if anyone is interested I could post it to get the general idea. |
Beta Was this translation helpful? Give feedback.
-
Very much inspired by @Turmoil1112 and with a little help from @copilot, here's a bash script that does a very similar thing for those who prefer bash: #!/bin/env bash
# Requires: bash >= 4.0, jq >= 1.5, curl >= 7.58.0
#
# This script uses the immich API to find images that have WhatsApp-like filenames,
# then extracts dates from filenames and timestamps, compares them, and updates the API
# if mismatches are found. It assumes that the filename is correct enough for your needs,
# and that the timestamp is not.
#
# --- Usage ---
# To run this script from the command line, ensure that it is executable and that you
# have the required environment variables set.
# API_KEY: The key used for authenticating API requests.
# BASE_URL: The base URL of the API.
# > API_KEY=XXXX BASE_URL=http://localhost:2283 ./whatsapp.sh
set -euo pipefail
# Ensure API_KEY and BASE_URL are set
if [[ -z "${API_KEY:-}" ]]; then
echo "Error: API_KEY is not set." >&2
exit 1
fi
if [[ -z "${BASE_URL:-}" ]]; then
echo "Error: BASE_URL is not set." >&2
exit 1
fi
# --- Functions ---
# icurl: A wrapper around curl for making API requests with JSON headers and
# authentication.
icurl() {
local path="$1"
shift
local response
response=$(/usr/bin/curl "$@" -s -w "\n%{http_code}" --header 'Content-Type: application/json' --header 'Accept: application/json' --header "X-Api-Key: ${API_KEY}" "${BASE_URL}/api${path}")
local http_code
http_code=$(echo "$response" | tail -n1)
local body
body=$(echo "$response" | head -n-1)
if [[ $http_code -ge 200 && $http_code -le 299 ]]; then
echo "$body" | /usr/bin/jq
else
echo -e "Error: API request failed with status code $http_code\n$body" >&2
exit 1
fi
}
# fetch_metadata: Fetches metadata from the API for a given page.
fetch_metadata() {
local page="$1"
icurl /search/metadata -d '{"page":'"$page"',"withExif":true,"isVisible":true,"language":"en-GB","originalFileName":"-WA"}'
}
# Initialize counters
inspected_count=0
changed_count=0
# process_asset: Processes an asset by comparing and updating date information if
# necessary.
process_asset() {
local asset_id="$1"
local file_name="$2"
local timestamp="$3"
# Increment inspected count
inspected_count=$((inspected_count + 1))
# Extract date from timestamp
local date_from_timestamp
date_from_timestamp=$(echo "$timestamp" | cut -c 1-10 | tr -d '-')
# Extract date from filename
local date_from_filename=""
if [[ "$file_name" =~ ([0-9]{8})-WA ]]; then
date_from_filename="${BASH_REMATCH[1]}"
fi
# Compare and update if necessary
if [[ -n "$date_from_filename" && "$date_from_timestamp" != "$date_from_filename" ]]; then
local time_part
time_part=$(echo "$timestamp" | cut -d'T' -f2-)
local year=${date_from_filename:0:4}
local month=${date_from_filename:4:2}
local day=${date_from_filename:6:2}
local new_date_part="${year}-${month}-${day}"
local new_timestamp="${new_date_part}T${time_part}"
local new_date_time_original
new_date_time_original=$(icurl /assets/"${asset_id}" -X PUT -d '{"dateTimeOriginal":"'"${new_timestamp}"'"}' | jq -r '.exifInfo.dateTimeOriginal')
echo "Asset: $asset_id, $file_name $timestamp -> $new_date_time_original"
# Increment changed count
changed_count=$((changed_count + 1))
fi
}
# --- Pagination ---
# PAGE: Tracks the current page of results.
# CONTINUE: Controls whether to continue fetching pages.
PAGE=1
CONTINUE=true
while [[ "$CONTINUE" == true ]]; do
# Fetch metadata from the API.
RESULT=$(fetch_metadata "$PAGE")
if [[ $(echo "$RESULT" | jq '.assets.items | length') -eq 0 ]]; then
CONTINUE=false
else
while IFS=$'\t' read -r asset_id file_name timestamp; do
process_asset "$asset_id" "$file_name" "$timestamp"
done <<< "$(echo "$RESULT" | jq -r '.assets.items[] | [.id, .originalFileName, .localDateTime] | @tsv')"
PAGE=$((PAGE + 1))
fi
done
# Print summary
echo "Summary: $inspected_count assets inspected, $changed_count dates changed." example: $ API_KEY=MY_API_KEY BASE_URL=http://localhost:2283 ./whatsapp.sh
Asset: 4eea028f-4a70-406e-9c15-7d98dfed4081, IMG-20211203-WA0007.jpg 2018-12-03T11:05:00.000Z -> 2021-12-03T11:05:00+00:00
Asset: 8d01cd61-eee9-4a30-8400-b515c6745e1a, IMG-20170615-WA0007.jpg 2017-06-12T20:39:00.000Z -> 2017-06-15T20:39:00+00:00
Summary: 1025 assets inspected, 2 dates changed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The bug
[BUG] I got some forwarded photos and videos in Whatsapp and I see that the year of these media are more than 4 digits. So It'll not appear in the timeline. I attached photos here.


The OS that Immich Server is running on
Debian
Version of Immich Server
v1.70
Version of Immich Mobile App
v1.71
Platform with the issue
Your docker-compose.yml content
Same as v1.70 docker-compose.yml
Your .env content
Reproduction steps
1. try to upload photos with year more than 4 digits in that like 123456
Additional information
No response
Beta Was this translation helpful? Give feedback.
All reactions