diff --git a/frontend/src/canvas/clipboard.ts b/frontend/src/canvas/clipboard.ts index c7c8251..4750d3a 100644 --- a/frontend/src/canvas/clipboard.ts +++ b/frontend/src/canvas/clipboard.ts @@ -12,6 +12,8 @@ import type { Viewport } from 'pixi-viewport'; import type { Application } from 'pixi.js'; import type { SceneManager, SceneItem } from './SceneManager'; import { getItemWorldBounds } from './SceneManager'; +import { getImageVisibleLocalRect } from './imageTransforms'; +import type { ImageObject } from './scene-format'; import { uploadImage } from '../api'; /** @@ -88,8 +90,11 @@ export async function writeCanvasToClipboard( let maxRatio = 1; for (const item of items) { const tex = (item.displayObject as any)?.texture; - if (tex && tex.width > 1 && item.data.w > 1) { - maxRatio = Math.max(maxRatio, tex.width / item.data.w); + const displayW = item.type === 'image' + ? getImageVisibleLocalRect(item.data as ImageObject).w + : item.data.w; + if (tex && tex.width > 1 && displayW > 1) { + maxRatio = Math.max(maxRatio, tex.width / displayW); } } const resolution = Math.min(Math.max(maxRatio, window.devicePixelRatio || 1), 4); diff --git a/frontend/src/canvas/export.ts b/frontend/src/canvas/export.ts index 1afd438..2274de7 100644 --- a/frontend/src/canvas/export.ts +++ b/frontend/src/canvas/export.ts @@ -8,6 +8,8 @@ import type { Viewport } from 'pixi-viewport'; import type { Application } from 'pixi.js'; import type { SceneItem } from './SceneManager'; import { getItemWorldBounds } from './SceneManager'; +import { getImageVisibleLocalRect } from './imageTransforms'; +import type { ImageObject } from './scene-format'; export interface ExportOptions { format: 'png' | 'jpeg' | 'webp'; @@ -68,8 +70,11 @@ function renderToCanvas( let maxRatio = 1; for (const item of items) { const tex = (item.displayObject as any)?.texture; - if (tex && tex.width > 1 && item.data.w > 1) { - maxRatio = Math.max(maxRatio, tex.width / item.data.w); + const displayW = item.type === 'image' + ? getImageVisibleLocalRect(item.data as ImageObject).w + : item.data.w; + if (tex && tex.width > 1 && displayW > 1) { + maxRatio = Math.max(maxRatio, tex.width / displayW); } } const resolution = Math.min(maxRatio * scale, 8); // cap at 8x to avoid GPU limits @@ -176,8 +181,11 @@ export function getExportDimensions( let maxRatio = 1; for (const item of items) { const tex = (item.displayObject as any)?.texture; - if (tex && tex.width > 1 && item.data.w > 1) { - maxRatio = Math.max(maxRatio, tex.width / item.data.w); + const displayW = item.type === 'image' + ? getImageVisibleLocalRect(item.data as ImageObject).w + : item.data.w; + if (tex && tex.width > 1 && displayW > 1) { + maxRatio = Math.max(maxRatio, tex.width / displayW); } } const resolution = Math.min(maxRatio * scale, 8);