InvokeAI/invokeai/frontend/web
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
..
.husky
.yarn/releases
config
dist Updated JS files 2023-10-13 17:27:41 +11:00
docs
public/locales translationBot(ui): update translation (Chinese (Simplified)) 2023-10-16 07:57:41 +11:00
scripts fix(ui): simplify typegen script 2023-08-23 23:06:42 +10:00
src fix(ui): copy image via img onload to blob 2023-10-17 06:43:19 +11:00
static
tests
__init__.py
.eslintignore feat: workflow saving and loading 2023-08-24 21:42:32 +10:00
.eslintrc.js build(ui): fix up lint scripts (way faster now) 2023-08-23 23:06:42 +10:00
.gitignore
.prettierignore fix(ui): prettier ignores translation files 2023-10-12 21:37:45 +11:00
.prettierrc.js
.yarnrc
.yarnrc.yml
favicon.ico
index.html Prevent caching to ensure updated UI is shown 2023-10-04 22:32:00 +11:00
package.json chore(ui): update deps 2023-10-15 19:30:39 +11:00
tsconfig.json
tsconfig.node.json
vite.config.ts
yarn.lock chore(ui): update deps 2023-10-15 19:30:39 +11:00