Readding Files

This commit is contained in:
kiyreload27
2025-12-28 17:11:39 +00:00
parent 72dfc34893
commit 4b944c1a53
1045 changed files with 4793 additions and 0 deletions

28
utils.py Normal file
View File

@@ -0,0 +1,28 @@
import os
import sys
def resolve_image_path(db_path):
"""
Resolve the absolute path to an image file.
Handles the case where the database contains paths from a different machine/drive.
Also handles frozen (PyInstaller) state.
"""
if not db_path:
return None
filename = os.path.basename(db_path)
# Check if running as frozen executable
if getattr(sys, 'frozen', False):
# PyInstaller creates a temp folder and stores path in _MEIPASS
if hasattr(sys, '_MEIPASS'):
root_dir = sys._MEIPASS
else:
root_dir = os.path.dirname(sys.executable)
else:
# Get the project root directory (directory where this utils.py resides)
root_dir = os.path.dirname(os.path.abspath(__file__))
# Construct optimal path
return os.path.join(root_dir, 'images', filename)