diff --git a/ai-chat/src/index.js b/ai-chat/src/index.js index beb3776..f3f5889 100644 --- a/ai-chat/src/index.js +++ b/ai-chat/src/index.js @@ -369,7 +369,7 @@ var sel = selectedNode() if (!sel) { warn('请先在画布选中一个节点'); return } var img = null - try { img = await ctx.canvas.getNodeImage(sel.id) } catch (error) { img = null } + try { img = await ctx.canvas.getNodeImage(sel.id, { max: 2048 }) } catch (error) { img = null } var imgUrl = img && (img.dataUrl || img.url) if (!imgUrl) { warn('选中的节点没有可发送的图片'); return } content = [ diff --git a/album/package.json b/album/package.json index 56421bc..04ad185 100644 --- a/album/package.json +++ b/album/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/album", "private": true, - "version": "1.2.3", + "version": "1.2.4", "description": "相册:一个节点装多张本地图(只引用不复制),宫格自适应分页,一图一任务 / 批量两种模式批量生图", "ibwPlugin": { "id": "album", diff --git a/album/src/index.js b/album/src/index.js index 9cf4574..5161c87 100644 --- a/album/src/index.js +++ b/album/src/index.js @@ -669,11 +669,23 @@ } } } catch (e) { /* 没缓存就现做 */ } - let dataUrl = '' + // v1.2.4(图片策略 v2):先让**宿主原生**出 320 小图 —— 不再把整幅原图读成 dataURL + // 再在 webview 里 canvas 缩放(那是 WebKit 上每次 21MB 的整幅解码,一夹 100 张就是 GB 级)。 const src = it && it.src try { - if (fileRefOf(src)) dataUrl = await ctx.images.dataUrl(src) - else if (typeof src === 'string') dataUrl = src + if (ctx.images && typeof ctx.images.thumb === 'function') { + const u = await ctx.images.thumb(src, { max: 320 }) + if (u && typeof u === 'string' && u.length < 512 * 1024) { + st.thumbs.set(key, u) + if (st.forceThumbs) st.forceThumbs.delete(key) + // 不再往 plugin-data 另存一份:宿主已在 thumbs/ 里按 hash 落了 tier,重复存等于两份 + return u + } + } + } catch (e) { /* 回退到本地缩放 */ } + let dataUrl = '' + try { + if (typeof src === 'string' && src.indexOf('data:') === 0) dataUrl = src else dataUrl = await ctx.images.dataUrl(src) } catch (e) { dataUrl = '' } if (!dataUrl) return '' @@ -742,7 +754,11 @@ const flight = pending.get(key) if (flight) return flight if (!ctx.images || typeof ctx.images.dataUrl !== 'function') return Promise.resolve('') - const p = Promise.resolve(ctx.images.dataUrl(it && it.src)).then((u) => { + // v1.2.4:大图也只取 2048 长边的预览(原生缩放),避免整幅解码 4K 原图 + const ask = (ctx.images && typeof ctx.images.preview === 'function') + ? Promise.resolve(ctx.images.preview(it && it.src, { max: 2048 })).then((r) => (r && r.dataUrl) || '') + : Promise.resolve(ctx.images.dataUrl(it && it.src)) + const p = ask.then((u) => { pending.delete(key) if (!u) return '' cache.set(key, u) diff --git a/batch-export/package.json b/batch-export/package.json index d163eec..ce30a02 100644 --- a/batch-export/package.json +++ b/batch-export/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/batch-export", "private": true, - "version": "1.2.2", + "version": "1.2.3", "description": "批量出图:资源中心面板里勾选 ref 节点,串行跑(可选本机抠图)→ 白底/透明合成 → 双版本编码 → 打包 ZIP 下载;行内可单张下载 JPG/PNG", "ibwPlugin": { "id": "batch-export", diff --git a/batch-export/src/index.js b/batch-export/src/index.js index 7ce7d8a..6eabf0a 100644 --- a/batch-export/src/index.js +++ b/batch-export/src/index.js @@ -577,7 +577,7 @@ async function makeSrcThumb(nodeId) { if (!ctx.canvas || typeof ctx.canvas.getNodeImage !== 'function') return null - var image = await ctx.canvas.getNodeImage(nodeId) + var image = await ctx.canvas.getNodeImage(nodeId, { max: 64 }) // v: 缩略预览只要 64px,别整幅解码 var src = image && (image.dataUrl || image.url) if (!src) return null var img = await loadImageEl(src) diff --git a/image-annotate/package.json b/image-annotate/package.json index 2b8180a..687107e 100644 --- a/image-annotate/package.json +++ b/image-annotate/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/image-annotate", "private": true, - "version": "1.20.8", + "version": "1.20.9", "description": "IWB 插件:图片标注 / 修图(编辑器移植自 iwb-plaus 扩展,纯 Canvas 2D)", "ibwPlugin": { "id": "image-annotate", diff --git a/image-annotate/src/index.js b/image-annotate/src/index.js index c4fdd55..954e953 100644 --- a/image-annotate/src/index.js +++ b/image-annotate/src/index.js @@ -9214,7 +9214,8 @@ var __IWB_ANNOTATE_MANIFEST__ = { if (!editor || typeof editor.open !== "function") { return Promise.reject(new Error("标注编辑器未加载")); } - return Promise.resolve(ctx.canvas.getNodeImage(id)).then(function(image) { + // v: 编辑器入口封顶 4096 长边(原生缩),避免 8K 原图整幅进 canvas + return Promise.resolve(ctx.canvas.getNodeImage(id, { max: 4096 })).then(function(image) { if (!image || !image.dataUrl) { throw new Error(image && image.url ? "该节点是远程图片,暂不支持标注(请先转存为本地位图)" : "该节点没有可编辑的图片"); } diff --git a/image-vectorize/package.json b/image-vectorize/package.json index 5630945..ab13b66 100644 --- a/image-vectorize/package.json +++ b/image-vectorize/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/image-vectorize", "private": true, - "version": "0.6.1", + "version": "0.6.2", "description": "位图转矢量:potrace(纯 JS)单色/灰度描摹,输出 SVG 与 PNG 节点;对文字、logo、线稿保形好,不需要 wasm", "ibwPlugin": { "id": "image-vectorize", diff --git a/image-vectorize/src/index.js b/image-vectorize/src/index.js index 13a3d93..a6fc2c6 100644 --- a/image-vectorize/src/index.js +++ b/image-vectorize/src/index.js @@ -3691,7 +3691,7 @@ var __IWB_VECTORIZE_MANIFEST__ = { }); } async function resolveImage(nodeId) { - const image = await ctx.canvas.getNodeImage(nodeId); + const image = await ctx.canvas.getNodeImage(nodeId, { max: 2048 }); // v: 预览/矢量化封顶 2048 if (!image) throw new Error("该节点没有可描摹的图片"); if (image.dataUrl) return image.dataUrl; if (!image.url) throw new Error("该节点没有可描摹的图片"); diff --git a/promptlib/package.json b/promptlib/package.json index c75d511..6a41bfa 100644 --- a/promptlib/package.json +++ b/promptlib/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/promptlib", "private": true, - "version": "1.14.9", + "version": "1.14.10", "description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供", "ibwPlugin": { "id": "promptlib", diff --git a/promptlib/src/index.js b/promptlib/src/index.js index 0f4b30e..198fe7f 100644 --- a/promptlib/src/index.js +++ b/promptlib/src/index.js @@ -607,13 +607,25 @@ // dataURL → { img: 文件名 };失败原样返回(宁可留着内联 base64,也不丢封面) function ensureCoverFile (cover) { if (!FILEAPI || typeof cover !== 'string' || cover.indexOf('data:') !== 0) return Promise.resolve(cover) - var name = coverFileName(cover) - pendingCoverNames[name] = 1 - return Promise.resolve(FILEAPI.put(name, cover)).then(function (r) { - if (r && r.ok) return { img: name } - delete pendingCoverNames[name] - return cover - }).catch(function () { delete pendingCoverNames[name]; return cover }) + // v: 封面入库前先在**原生侧**缩到 512 —— 大封面会永久占 plugin-data, + // 而且每次显示都要整幅解码(WebKit 上 4K 封面 = 21MB/次)。 + var prepped = Promise.resolve(cover) + try { + if (PLP_CTX && PLP_CTX.images && typeof PLP_CTX.images.preview === 'function') { + prepped = Promise.resolve(PLP_CTX.images.preview(cover, { max: 512 })) + .then(function (r) { return (r && r.ok && r.dataUrl) ? r.dataUrl : cover }) + .catch(function () { return cover }) + } + } catch (e) { /* 退回未压缩 */ } + return prepped.then(function (small) { + var name = coverFileName(small) + pendingCoverNames[name] = 1 + return Promise.resolve(FILEAPI.put(name, small)).then(function (r) { + if (r && r.ok) return { img: name } + delete pendingCoverNames[name] + return small + }).catch(function () { delete pendingCoverNames[name]; return small }) + }) } // 回收未被任何词条引用的封面文件(判定在模块级 plpGcCoverFiles,设置页复用同一套)。 // 返回 { removed, bytes, skipped } diff --git a/white-bg-800/package.json b/white-bg-800/package.json index 39992fe..35f8201 100644 --- a/white-bg-800/package.json +++ b/white-bg-800/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/white-bg-800", "private": true, - "version": "1.2.1", + "version": "1.2.2", "description": "白底图:把节点图等比缩放居中合成到正方形画布,按格式/质量/体积上限编码,输出 _x.;可开双版本出透明 PNG + 白底 JPG", "ibwPlugin": { "id": "white-bg-800", diff --git a/white-bg-800/src/index.js b/white-bg-800/src/index.js index 1fcd8a0..b59a0bb 100644 --- a/white-bg-800/src/index.js +++ b/white-bg-800/src/index.js @@ -166,7 +166,7 @@ // 绝不对 data: URL 发网络请求 —— 宿主 CSP connect-src 不含 data:,必被拦(姊妹插件 image-annotate 踩过并修掉的坑)。 // 远程 url 才走 fetch,转成 blob: URL 再解码(blob: 同样不污染画布)。 async function resolveImage(nodeId) { - const image = await ctx.canvas.getNodeImage(nodeId) + const image = await ctx.canvas.getNodeImage(nodeId, { max: 2048 }) // v: 白底处理封顶 2048 if (!image) throw new Error(NO_IMAGE) if (image.dataUrl) return loadImage(image.dataUrl) diff --git a/xianyi-cutout/package.json b/xianyi-cutout/package.json index 7b349d9..06fb0bc 100644 --- a/xianyi-cutout/package.json +++ b/xianyi-cutout/package.json @@ -1,7 +1,7 @@ { "name": "@iwb-plugin/xianyi-cutout", "private": true, - "version": "1.0.3", + "version": "1.0.4", "description": "鲜艺抠图:调用本机 30092 的 /rmbg 把节点图抠成透明底", "ibwPlugin": { "id": "xianyi-cutout", diff --git a/xianyi-cutout/src/index.js b/xianyi-cutout/src/index.js index 724cc8c..f40658e 100644 --- a/xianyi-cutout/src/index.js +++ b/xianyi-cutout/src/index.js @@ -47,7 +47,7 @@ }, }, function (ctx) { async function cutoutOne(nodeId) { - const image = await ctx.canvas.getNodeImage(nodeId) + const image = await ctx.canvas.getNodeImage(nodeId, { max: 2048 }) // v: 抠图封顶 2048 if (!image || !image.dataUrl) throw new Error('该节点没有可编码的图片(请选中带图的参考图或输出节点)') const apiUrl = trimUrl(ctx.settings.get('apiUrl'))