Skip to content

Commit

Permalink
add change canvas painter node size, when drag and drop and paste image
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekPet committed Sep 2, 2024
1 parent 95c0c94 commit 5869b91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion PainterNode/js/painter_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,11 @@ class Painter {

pastAsBackground(image, options = {}) {
if (!image) return;

if (confirm("Resize Painter node canvas?")) {
this.setCanvasSize(image.naturalWidth, image.naturalHeight);
}

const img_ = new fabric.Image(image, {
left: 0,
top: 0,
Expand All @@ -1861,6 +1866,12 @@ class Painter {

pastAsImage(image, options = {}) {
if (!image) return;

const painterSize = confirm("Resize Painter node canvas?");
if (painterSize) {
this.setCanvasSize(image.naturalWidth, image.naturalHeight);
}

const img_ = new fabric.Image(image, {
left: 0,
top: 0,
Expand All @@ -1869,7 +1880,7 @@ class Painter {
...options,
});

if (confirm("Resize image for Painter size?")) {
if (!painterSize && confirm("Stretch image to fit canvas Painter node?")) {
img_.scaleToHeight(this.currentCanvasSize.width);
img_.scaleToWidth(this.currentCanvasSize.height);
}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui_custom_nodes_alekpet"
description = "Nodes: PoseNode, PainterNode, TranslateTextNode, TranslateCLIPTextEncodeNode, DeepTranslatorTextNode, DeepTranslatorCLIPTextEncodeNode, ArgosTranslateTextNode, ArgosTranslateCLIPTextEncodeNode, PreviewTextNode, HexToHueNode, ColorsCorrectNode, IDENode."
version = "1.0.25"
version = "1.0.26"
license = { file = "LICENSE" }

[project.urls]
Expand Down

0 comments on commit 5869b91

Please sign in to comment.