Closed agross closed 8 months ago
Try now. I revise the stream_asset code as per:
def stream_asset(asset_id, immich_server_url):
asset_download_url = f"{immich_server_url}/api/download/asset/{asset_id}"
# Stream the asset
response = requests.post(asset_download_url, headers={'Accept': 'application/octet-stream','x-api-key': api_key}, stream=True)
if response.status_code == 200 and 'image/' in response.headers.get('Content-Type', ''):
image_bytes = BytesIO(response.content)
try:
image = Image.open(image_bytes)
return image
except UnidentifiedImageError:
# Log error or save the problematic data for inspection
print(f"Failed to identify image for asset_id {asset_id}. Content-Type: {response.headers.get('Content-Type')}")
# Optionally, save or log the problematic bytes
# with open(f"debug_{asset_id}.bin", "wb") as f_debug:
# f_debug.write(response.content)
return None
else:
print(f"Failed to fetch image for asset_id {asset_id}. Status code: {response.status_code}, Content-Type: {response.headers.get('Content-Type')}")
return None
Already commited the code
Failed to fetch image for asset_id 2889f083-d930-4206-b761-23c2262225dd. Status code: 200, Content-Type: video/mp4
Failed to fetch image for asset_id 5ee47ed6-7d49-4a0a-8a55-04527ac58cc3. Status code: 200, Content-Type: video/mp4
2024-03-21 22:49:09.038 Uncaught app exception
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 542, in _run_script
exec(code, module.__dict__)
File "/Users/agross/Downloads/immich_duplicate_finder/app.py", line 328, in <module>
main()
File "/Users/agross/Downloads/immich_duplicate_finder/app.py", line 310, in main
show_duplicate_photos(assets,limit)
File "/Users/agross/Downloads/immich_duplicate_finder/app.py", line 232, in show_duplicate_photos
image_comparison(
File "/opt/homebrew/lib/python3.11/site-packages/streamlit_image_comparison/__init__.py", line 192, in image_comparison
img1_pillow = read_image_as_pil(img1)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/streamlit_image_comparison/__init__.py", line 74, in read_image_as_pil
if image.shape[0] < 5: # image in CHW
~~~~~~~~~~~^^^
IndexError: tuple index out of range
I'm AFK now until tomorrow. Thanks and see you later ;-)
Just uploaded the revised version. Let me know
Thanks!