InvokeAI/invokeai/frontend
psychedelicious 19c5435332 fix(ui): copy image via img onload to blob
There's a bug in chrome that screws with headers on fetch requests and 307 responses. This causes images to fail to copy in the commercial environment.

This change attempts to get around this by copying images in a different way (similar to how the canvas works). When the user requests a copy we:
- create an `<img />` element
- set `crossOrigin` if needed
- add an onload handler:
  - create a canvas element
  - draw image onto it
  - export canvas to blob

This is wrapped in a promise which resolves to the blob, which can then be copied to clipboard.

---

A customized version of Konva's `useImage` hook is also included, which returns the image blob in addition to the `<img />` element. Unfortunately, this hook is not suitable for use across the app, because it does all the image fetching up front, regardless of whether we actually want to copy the image.

In other words, we'd have to fetch the whole image file even if the user is just skipping through image metadata, in order to have the blob to copy. The callback approach means we only fetch the image when the user clicks copy. The hook is thus currently unused.
2023-10-17 06:43:19 +11:00
..
CLI Resolving merge conflicts for flake8 2023-08-18 15:52:04 +10:00
install closes #4768 2023-10-12 22:04:54 -04:00
merge isort wip 2023-09-12 13:01:58 -04:00
training isort wip 2023-09-12 13:01:58 -04:00
web fix(ui): copy image via img onload to blob 2023-10-17 06:43:19 +11:00
__init__.py Run python black 2023-07-28 09:46:44 -04:00
legacy_launch_invokeai.py isort wip 2023-09-12 13:01:58 -04:00