This script extracts image thumbnails from a SQLite database used by the Phone Link app on Windows. It was created for users whose devices were paired with Windows via Phone Link and whose original device has been damaged, but the thumbnails are still stored in the SQLite database file.
Note: Thumbnails are a last resort as their quality is lower than the original images. Therefore, this solution may be useful for those who might want to attempt to retrieve photos from the Phone Link database if no other option is available to retrieve the originals from the phone or backups. It might be usable to at least attempt to save the low-resolution thumbnails of the photos as a better-than-nothing option.
-
SQLite database file: The database file (e.g.,
photos.db
) used by the Phone Link app.Important: Copy the database file from Phone Link's appropriate directory instead of moving it. Working on the copied file ensures that the original remains intact in case anything goes wrong during the extraction process.
- Multiple database files: If there are multiple
photos.db
files in different directories, try each one separately, as some may be empty or contain different sets of thumbnails.
- Multiple database files: If there are multiple
-
PowerShell: This script works on Windows using PowerShell.
-
SQLite: Needed to query the database.
To interact with the database, you need to have SQLite installed on your Windows machine.
- Download SQLite tools (e.g.,
sqlite-tools-win-x64-3480000.zip
) from SQLite Official Website. - Extract SQLite tools to a folder, such as
C:\sqlite
.- You may need to create the
sqlite
folder inC:\
or another directory if it does not already exist.
- You may need to create the
- Add SQLite to PATH in Windows system settings.
- Open Search in Windows and type Edit environment variables for your account.
- In the Environment Variables window, under User variables, find or create a variable named
Path
and addC:\sqlite
(or your different directory with the extracted SQLite tools).
- Save the script: Copy the script below into a new file and save it as
extract_thumbnails.ps1
, or download the one available in this repository. - Prepare the database file: Place the SQLite database (
photos.db
) in the same folder as the script or adjust the$DB
variable in the script to point to the correct path.
- Open PowerShell as Administrator.
- Navigate to the script directory:
cd "C:\path\to\your\script\directory"
- Run the script using:
powershell -ExecutionPolicy Bypass -File extract_thumbnails.ps1
Once the script is running, wait for it to complete. If any thumbnails are available in the database, they will be extracted to the extracted_thumbnails
folder in the same directory as the script.
- Automatically Handles Multiple Formats: Supports
jpeg
,png
,heic
,gif
,webp
,bmp
,tiff
,svg
,ico
, andx-adobe-dng
. - Prevents Duplicate Extensions: Ensures no duplicate extensions (e.g.,
.jpg.jpg
). - Output Directory: Saves extracted thumbnails into \
extracted_thumbnails
by default.
- SQLite Installation: If
sqlite3
is not recognized, ensure SQLite is installed and added to your system PATH. - Missing Thumbnails: If some thumbnails are not extracted, the database's thumbnail field may be empty or corrupted for those images. The script tries to extract thumbnails in a usable state; success depends on the integrity of the data in the database.
This script is released under the MIT License. For more details, see the LICENSE.md file.