mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
Add export of canvas with mask as alpha channel
Introduces a new method to export the flattened canvas with the mask applied as the alpha channel. Updates UI actions to allow previewing, copying, and saving the image with mask alpha, and ensures node previews use the new export method. This enhances workflows that require the mask to be embedded as transparency in the output image.
This commit is contained in:
11
js/Canvas.js
11
js/Canvas.js
@@ -197,6 +197,13 @@ export class Canvas {
|
||||
return this.canvasLayers.getFlattenedCanvasAsBlob();
|
||||
}
|
||||
|
||||
/**
|
||||
* Eksportuje spłaszczony canvas z maską jako kanałem alpha
|
||||
*/
|
||||
async getFlattenedCanvasWithMaskAsBlob() {
|
||||
return this.canvasLayers.getFlattenedCanvasWithMaskAsBlob();
|
||||
}
|
||||
|
||||
/**
|
||||
* Importuje najnowszy obraz
|
||||
*/
|
||||
@@ -212,6 +219,7 @@ export class Canvas {
|
||||
* Uruchamia edytor masek
|
||||
*/
|
||||
async startMaskEditor() {
|
||||
// Dla edytora masek używamy zwykłego spłaszczonego obrazu bez alpha
|
||||
const blob = await this.canvasLayers.getFlattenedCanvasAsBlob();
|
||||
if (!blob) {
|
||||
log.warn("Canvas is empty, cannot open mask editor.");
|
||||
@@ -446,7 +454,8 @@ export class Canvas {
|
||||
this.saveState();
|
||||
|
||||
const new_preview = new Image();
|
||||
const blob = await this.canvasLayers.getFlattenedCanvasAsBlob();
|
||||
// Użyj nowej metody z maską jako kanałem alpha
|
||||
const blob = await this.canvasLayers.getFlattenedCanvasWithMaskAsBlob();
|
||||
if (blob) {
|
||||
new_preview.src = URL.createObjectURL(blob);
|
||||
await new Promise(r => new_preview.onload = r);
|
||||
|
||||
Reference in New Issue
Block a user