mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
Fix CORS for images loaded from IndexedDB
Add crossOrigin='anonymous' to image elements in CanvasState._createLayerFromSrc() method. This prevents canvas tainting when images are restored from IndexedDB after page refresh, ensuring export functions work correctly.
This commit is contained in:
@@ -200,6 +200,7 @@ export class CanvasState {
|
|||||||
_createLayerFromSrc(layerData, imageSrc, index, resolve) {
|
_createLayerFromSrc(layerData, imageSrc, index, resolve) {
|
||||||
if (typeof imageSrc === 'string') {
|
if (typeof imageSrc === 'string') {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'anonymous';
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
log.debug(`Layer ${index}: Image loaded successfully.`);
|
log.debug(`Layer ${index}: Image loaded successfully.`);
|
||||||
const newLayer = { ...layerData, image: img };
|
const newLayer = { ...layerData, image: img };
|
||||||
@@ -216,6 +217,7 @@ export class CanvasState {
|
|||||||
if (ctx) {
|
if (ctx) {
|
||||||
ctx.drawImage(imageSrc, 0, 0);
|
ctx.drawImage(imageSrc, 0, 0);
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'anonymous';
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
log.debug(`Layer ${index}: Image loaded successfully from ImageBitmap.`);
|
log.debug(`Layer ${index}: Image loaded successfully from ImageBitmap.`);
|
||||||
const newLayer = { ...layerData, image: img };
|
const newLayer = { ...layerData, image: img };
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ export class CanvasState {
|
|||||||
_createLayerFromSrc(layerData: Layer, imageSrc: string | ImageBitmap, index: number, resolve: (value: Layer | null) => void): void {
|
_createLayerFromSrc(layerData: Layer, imageSrc: string | ImageBitmap, index: number, resolve: (value: Layer | null) => void): void {
|
||||||
if (typeof imageSrc === 'string') {
|
if (typeof imageSrc === 'string') {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'anonymous';
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
log.debug(`Layer ${index}: Image loaded successfully.`);
|
log.debug(`Layer ${index}: Image loaded successfully.`);
|
||||||
const newLayer: Layer = {...layerData, image: img};
|
const newLayer: Layer = {...layerData, image: img};
|
||||||
@@ -250,6 +251,7 @@ export class CanvasState {
|
|||||||
if (ctx) {
|
if (ctx) {
|
||||||
ctx.drawImage(imageSrc, 0, 0);
|
ctx.drawImage(imageSrc, 0, 0);
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'anonymous';
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
log.debug(`Layer ${index}: Image loaded successfully from ImageBitmap.`);
|
log.debug(`Layer ${index}: Image loaded successfully from ImageBitmap.`);
|
||||||
const newLayer: Layer = {...layerData, image: img};
|
const newLayer: Layer = {...layerData, image: img};
|
||||||
|
|||||||
Reference in New Issue
Block a user