Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Support for HEIC images #3393

Closed
6 tasks done
kSzajo opened this issue Mar 30, 2024 · 1 comment · Fixed by #3409
Closed
6 tasks done

[BUG] - Support for HEIC images #3393

kSzajo opened this issue Mar 30, 2024 · 1 comment · Fixed by #3409
Labels
bug Something isn't working triage

Comments

@kSzajo
Copy link

kSzajo commented Mar 30, 2024

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

Unable to upload HEIC images. This is image format used by iPhones

image

Steps to Reproduce

Enter recipe
click I Made This
try to upload HEIC image on desktop

When I change Finder filtering to all files and try to upload then in console 500 internal is thrown

Request Method:
PUT
api/recipes/timeline/events/2ef4d933-3cd4-4617-957f-eb0ce3a6545c/image

Please provide relevant logs

mealie  | INFO:     192.168.176.3:53266 - "PUT /api/recipes/timeline/events/2ef4d933-3cd4-4617-957f-eb0ce3a6545c/image HTTP/1.1" 500 Internal Server Error
mealie  | ERROR:    Exception in ASGI application
mealie  | Traceback (most recent call last):
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 412, in run_asgi
mealie  |     result = await app(  # type: ignore[func-returns-value]
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
mealie  |     return await self.app(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
mealie  |     await super().__call__(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
mealie  |     await self.middleware_stack(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
mealie  |     raise exc
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
mealie  |     await self.app(scope, receive, _send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 24, in __call__
mealie  |     await responder(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 44, in __call__
mealie  |     await self.app(scope, receive, self.send_with_gzip)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
mealie  |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
mealie  |     raise exc
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
mealie  |     await app(scope, receive, sender)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 758, in __call__
mealie  |     await self.middleware_stack(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 778, in app
mealie  |     await route.handle(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle
mealie  |     await self.app(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 79, in app
mealie  |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
mealie  |     raise exc
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
mealie  |     await app(scope, receive, sender)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 74, in app
mealie  |     response = await func(request)
mealie  |   File "/app/mealie/routes/_base/routers.py", line 35, in custom_route_handler
mealie  |     response = await original_route_handler(request)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 278, in app
mealie  |     raw_response = await run_endpoint_function(
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 193, in run_endpoint_function
mealie  |     return await run_in_threadpool(dependant.call, **values)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/concurrency.py", line 42, in run_in_threadpool
mealie  |     return await anyio.to_thread.run_sync(func, *args)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
mealie  |     return await get_asynclib().run_sync_in_worker_thread(
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
mealie  |     return await future
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
mealie  |     result = context.run(func, *args)
mealie  |   File "/app/mealie/routes/recipe/timeline_events.py", line 136, in update_event_image
mealie  |     data_service.write_image(image, extension, event.image_dir)
mealie  |   File "/app/mealie/services/recipe/recipe_data_service.py", line 100, in write_image
mealie  |     self.minifier.minify(image_path)
mealie  |   File "/app/mealie/pkgs/img/minify.py", line 104, in minify
mealie  |     PillowMinifier.to_webp(image_file, org_dest, quality=70)
mealie  |   File "/app/mealie/pkgs/img/minify.py", line 67, in to_webp
mealie  |     img = Image.open(image_file)
mealie  |   File "/opt/pysetup/.venv/lib/python3.10/site-packages/PIL/Image.py", line 3309, in open
mealie  |     raise UnidentifiedImageError(msg)
mealie  | PIL.UnidentifiedImageError: cannot identify image file '/app/data/recipes/bdef5429-b909-4d50-a84a-5c28d9c374b5/images/timeline/2ef4d933-3cd4-4617-957f-eb0ce3a6545c/original.HEIC'

Mealie Version

No response

Deployment

Docker (Linux)

Additional Deployment Details

No response

@kSzajo kSzajo added bug Something isn't working triage labels Mar 30, 2024
@tba-code
Copy link
Contributor

HEIC is not supported by Pillow, the library Mealie uses to handle images. Additionally, it is not really supported by most web browsers. So not as much of a bug, as a feature request here, though we should definitely handle the exception better in cases where an image type is not supported.

@hay-kot I could make a PR that fixes this using pi-heif if that is acceptable. It should allow Pillow to open the HEIC files as well as AVIF if someone requests that down the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants