Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be2a2a1444 | ||
|
|
76eb4fc7e7 | ||
|
|
057f2bd05a | ||
|
|
172252ab02 | ||
|
|
ebc81ea57e | ||
|
|
bc235e96e5 | ||
|
|
6572b49386 | ||
|
|
d593e01fc9 | ||
|
|
009aa95d98 | ||
|
|
b61b3efc94 | ||
|
|
6cfed25a8e | ||
|
|
27e175aa08 | ||
|
|
6224bae13c | ||
|
|
bd49afae19 | ||
|
|
13e4d73dbd | ||
|
|
37584519e8 | ||
|
|
1ed921b6fb | ||
|
|
15e5803a06 | ||
|
|
a0327f6ddd | ||
|
|
e65612bb28 | ||
|
|
11d79b252d | ||
|
|
7e5cadaa06 | ||
|
|
94d302e112 | ||
|
|
fb26f3ae06 | ||
|
|
11638b0557 | ||
|
|
ad81fbcca1 | ||
|
|
9cc91ffba8 | ||
|
|
0450466422 | ||
|
|
d5442cd659 | ||
|
|
9a1096149a | ||
|
|
0401d9dd34 | ||
|
|
8961827079 | ||
|
|
dea2eac8cd | ||
|
|
3c1eeaa486 | ||
|
|
cf0eec8d31 | ||
|
|
8618d8ca56 | ||
|
|
46dde36185 | ||
|
|
a29ca76fe8 | ||
|
|
2908eac20c | ||
|
|
39a7599fd9 | ||
|
|
c4e519565b | ||
|
|
f18b8f6ca3 | ||
|
|
64ab3e9761 | ||
|
|
065f2cb14c | ||
|
|
3d99ddd35a | ||
|
|
224b4af1da | ||
|
|
0a7177b151 | ||
|
|
b31561d1a0 | ||
|
|
ba4ab486c3 | ||
|
|
4603256ebf | ||
|
|
52b23691dc | ||
|
|
df773658da | ||
|
|
d4636bb5e3 | ||
|
|
83f59cac93 | ||
|
|
cfbc42799a | ||
|
|
b4657e2b58 |
+176
@@ -2,6 +2,182 @@
|
||||
|
||||
All notable changes to ComfyUI-AusBoss are documented here.
|
||||
|
||||
## 2.26.2 - 2026-11-14
|
||||
|
||||
- **Loaders never look up a file name they refused.** Before each run,
|
||||
Load Image 🆎, Load Image + Pad 🆎, Image Crop + Rotate + Pad 🆎 and both
|
||||
Video Crop + Rotate + Pad nodes check whether their file changed. When the
|
||||
name was one they do not accept, such as a whole path or a network share,
|
||||
that check still looked it up on disk. On Windows, looking up a share
|
||||
contacts its server and hands it the computer's login. Now a refused name
|
||||
is only compared as text.
|
||||
- **The pack's scripts are found without looking up the address.** The pack
|
||||
tags its scripts with a version as the browser asks for them. It found
|
||||
each one by joining the address the browser sent to its own folder and
|
||||
looking the result up on disk, and only then checked that the file was
|
||||
its own. Now it looks the address up in a list of its scripts made when
|
||||
ComfyUI starts, so no address reaches the disk.
|
||||
- **Save Image's Save button copies only pictures it holds.** With Auto
|
||||
save off, the list of a run's held pictures was a file in ComfyUI's temp
|
||||
folder. That folder takes uploads, so a planted list could copy another
|
||||
file on the server into the output folder. The list now stays in
|
||||
ComfyUI's memory, and a held picture is found only by its run, its number
|
||||
and one of Save Image's formats. The Save button works for the last 256
|
||||
runs, up to 10,000 pictures each; held pictures still go when ComfyUI
|
||||
restarts, as before.
|
||||
|
||||
## 2.26.1 - 2026-11-14
|
||||
|
||||
- **A path that starts with `~` is no longer expanded.** Image Folder used
|
||||
to turn a pasted `~/...` path into a full one before checking that it sits
|
||||
inside ComfyUI's folders; now only a path written out in full is checked.
|
||||
LaMa Inpaint only opens a model from ComfyUI's `models/lama` list. Nothing
|
||||
outside those folders could be read before either; this removes the code
|
||||
that looked as if it could.
|
||||
|
||||
## 2.26.0 - 2026-11-14
|
||||
|
||||
- **Missing LoRAs show in ComfyUI's missing-models list.** When a workflow
|
||||
needs a LoRA you don't have, ComfyUI's Issues panel now lists it with the
|
||||
other missing models, so **Download all** fetches it too. Before, the
|
||||
list skipped every LoRA in a LoRA Loader 🆎, and Run then stopped on
|
||||
"missing LoRA file". A LoRA that moved to another folder, or a row that is
|
||||
switched off, is not listed.
|
||||
|
||||
- **Link tiles and title tiles snap by the edge you see.** A tile draws a
|
||||
card inside a wider see-through frame, and Snap into line used that frame,
|
||||
so tiles lined up with a gap around them, and a tile you dragged never
|
||||
snapped at all. Now a dragged tile lines up, and other nodes line up with
|
||||
it, by the card's own edges.
|
||||
|
||||
- **Cards work in App mode.** App mode is ComfyUI's simple form view of a
|
||||
workflow: a few labelled fields and a Run button. A field from a node
|
||||
with a card (a picture or video loader, H3 Prompt Writer) used to show
|
||||
as an empty row there. Now it shows a real control: a file list with an
|
||||
upload button, a video list, a text box. Back in the graph, the node
|
||||
looks the same as before.
|
||||
- **The video crop nodes take uploads in App mode.** Video Crop + Rotate +
|
||||
Pad and its Clip version now tell ComfyUI that their video list takes
|
||||
uploads, as the picture nodes do. In App mode the clip field gets the same
|
||||
picker as a picture field: your videos as thumbnails, an Upload button and
|
||||
a folder button. On the node itself nothing changes.
|
||||
|
||||
- **Models you already have are picked for you.** When a workflow asks for
|
||||
a model file you keep in a subfolder (`minimax-h3/model.safetensors`),
|
||||
ComfyUI used to mark its loader red until you clicked **Use it** on the
|
||||
workflow's Guide. Now the Guide switches the loader to your copy as the
|
||||
workflow opens and says so in a short message. That matters most in App
|
||||
mode, which shows no Guide to click. With two copies in different
|
||||
subfolders it still asks. Turn it off in Settings, 🆎 AusBoss, Models.
|
||||
|
||||
- **The video clip's timing is three boxes: Start, Duration, Ends at.** On
|
||||
Video Crop + Rotate + Pad (Clip), the Length on/off switch is gone. Drag
|
||||
the start to move the clip, drag the end or type a Duration to change how
|
||||
long it is, and switch between seconds and frames. Details sit in hover
|
||||
text; a short note shows only when something needs fixing, with a button
|
||||
to fix it. Saved workflows open with the same values and run the same.
|
||||
- **A linked frame rate no longer stops the clip's start too early.** With
|
||||
a rate wired in, a typed start of frame 60 used to settle on frame 7; it
|
||||
now lands where you put it, and the start handle stops only where the
|
||||
Duration no longer fits. A rate set inside a subgraph now counts as
|
||||
known, so the clip shows its length before you run.
|
||||
- **Linked clip lengths say where they come from.** A box set by another
|
||||
node shows a **linked** button that jumps to that node. A cap that the
|
||||
video cannot fill says how many frames you get, and a count only known
|
||||
when the graph runs shows the room left after the start.
|
||||
- **H3 Prompt Writer says how much of the clip H3 uses.** When the video
|
||||
comes from the clip node, it shows how many of the clip's frames H3
|
||||
makes and where in the video that stops, and which Durations use all of
|
||||
it.
|
||||
- **Crop + Rotate + Pad panels fill the node's width.** The rows under the
|
||||
picture used to stop at 460 px and sit in the middle of a wide node.
|
||||
- **Load Video uses the same timing boxes as the clip node.** Start,
|
||||
Duration and Ends at replace the IN and OUT fields and the separate
|
||||
Limit row, with the same seconds | frames switch. Saved workflows open
|
||||
with the same values and run the same.
|
||||
- **Load Video counts the frames the file really has.** The face used to
|
||||
work the count out from the length and could say one frame too many (248
|
||||
for a 247-frame clip); it now reads it from the file.
|
||||
- **Load Audio has Start, Duration and Ends at boxes.** They replace the IN
|
||||
and OUT times and the separate Max length row, so the red "cut" stripe is
|
||||
gone: the Duration is the length you get.
|
||||
- **A number wired through a Reroute or a subgraph now shows on the face.**
|
||||
The clip node, Load Video, Load Audio and Layout Boxes read a linked
|
||||
number the same way, so it no longer drops out behind a Reroute, a
|
||||
subgraph or an older Primitive node.
|
||||
|
||||
## 2.25.3 - 2026-11-13
|
||||
|
||||
- **The video clip's frame readout explains itself.** On Video Crop + Rotate
|
||||
+ Pad (Clip), the small `fr 52 · 0:02.17` beside Play now says in plain
|
||||
words, when you point at it, which frame the picture shows and how many
|
||||
seconds into the video it is. The help page explains it too.
|
||||
|
||||
## 2.25.2 - 2026-11-13
|
||||
|
||||
- **The video clip's IN handle always drags.** On Video Crop + Rotate + Pad
|
||||
(Clip), a Length as long as the clip or longer used to lock IN, and the
|
||||
only way to trim the start was to turn Length off. Now IN drags anyway:
|
||||
the Length then only caps the clip, and the clip's own end is OUT. A
|
||||
Length shorter than the clip works as before.
|
||||
|
||||
## 2.25.1 - 2026-11-13
|
||||
|
||||
- **Edit Lock Restore 🆎 takes out the pink tint.** MiniMax H3 Image gives
|
||||
every edit a faint pink, slightly lighter tint over the whole picture.
|
||||
Edit Lock already removed it wherever it locked, but when it stepped
|
||||
aside (a new hair color, a new background, rain) the tint stayed. A new
|
||||
**Remove tint** switch, on by default, reads the tint from the part of
|
||||
the picture the edit left alone and takes it out of the whole picture.
|
||||
Edits meant to recolor everything, such as golden hour or red light, are
|
||||
left as they are. Turn it off to get the old behavior.
|
||||
|
||||
## 2.25.0 - 2026-11-12
|
||||
|
||||
- **New node: Load Image.** Loads a picture and sets its size in the same
|
||||
node, so a workflow needs no resize node after its loader. Size can be a
|
||||
megapixel count, a longest side, a scale, a box the picture fits inside, or
|
||||
a box it fills by cropping, rounded to a multiple you choose. It can also
|
||||
cut a piece or a shape such as 16:9 out of the picture without resizing,
|
||||
and you pick which part is kept: the center, a side or a corner. Arrows
|
||||
step through the pictures in the input folder. Two small pictures on the
|
||||
node show what goes in and what comes out, with both sizes and what is
|
||||
cut off, before you run. It also gives the file's name and its original
|
||||
size. With Size off the picture comes out exactly as the file has it.
|
||||
|
||||
- **Clear VRAM from the right-click menu.** Right-click the empty canvas
|
||||
and pick **Clear VRAM 🆎** to unload every model and free memory on the
|
||||
ComfyUI server, the same as ComfyUI's own "Unload Models and Execution
|
||||
Cache". A short message says when it is done. Turn the entry off in
|
||||
Settings, 🆎 AusBoss, Memory.
|
||||
|
||||
- **Callout 🆎: Info card.** Right-click a Callout and pick **Info card**
|
||||
for a small card with a title, a list of labels and values, and small
|
||||
print, such as a table of run times. Write a row as `label | value`; a
|
||||
row in **bold** is drawn in teal so the one to pick stands out. The first
|
||||
line is the title, and a ⏱️ ℹ️ ⚠️ 💡 or ✅ at its start becomes a small
|
||||
icon. An older pack shows the card as a plain note with its rows written
|
||||
out.
|
||||
|
||||
- **Save Image shows big pictures at once.** The node now shows a small
|
||||
copy of each picture, a few hundred kilobytes, where it used to load the
|
||||
whole file. A 30 MB sheet on a ComfyUI opened from another computer took
|
||||
half a minute to show, or never did; it now shows as the run ends. The
|
||||
saved file is the same full-size file as before.
|
||||
|
||||
- **Save Image: the Save button is hard to miss.** With **Auto save** off,
|
||||
a row over the picture now says **Not saved yet** and holds a solid
|
||||
**Save picture** button. Before, it was a small SAVE label in the corner.
|
||||
With several pictures the button reads **Save all 4**, or **Save this
|
||||
one** when the arrows are on one picture. After a save the row says the
|
||||
name the picture was saved under.
|
||||
|
||||
- **A picture that loads slowly no longer leaves the old one up.** When a
|
||||
result took more than about 16 seconds to reach the browser, the node
|
||||
kept the picture from the run before. Now the new picture always shows,
|
||||
and the old one dims while the new one loads. This fixes Select Frame,
|
||||
Mask Refine, Mask by Name and LaMa Inpaint as well as Save Image.
|
||||
|
||||
## 2.24.0 - 2026-11-12
|
||||
|
||||
- **New node: Edit Lock.** Keeps every part of your picture that an edit
|
||||
|
||||
+9
-3
@@ -193,7 +193,7 @@ example_workflows/ # example workflows (regular workflow JSON, not API JSON)
|
||||
drag). Messages to the user go through `showToast`, never `alert()`.
|
||||
- The mouse wheel over a node zooms the graph, on every part of its face.
|
||||
`js/canvas_passthrough/` hands the wheel on from the pack's panels, and
|
||||
keeps it only for a box that can still scroll or a field being typed in,
|
||||
keeps it only for a box that can still scroll, typed in or not,
|
||||
so a panel adds no wheel listener of its own
|
||||
(`tests/canvas_passthrough.test.mjs` lists the few that exist). After a
|
||||
change to a node face, `scripts/dev/wheel_sweep.mjs` turns the wheel at
|
||||
@@ -210,8 +210,7 @@ example_workflows/ # example workflows (regular workflow JSON, not API JSON)
|
||||
never a classic canvas number widget on a finished node face. Units
|
||||
(`px`, `MP`, `×`) ride inside the box in a fixed-width slot that every
|
||||
single-field row reserves, so the numbers down a card share one centre
|
||||
line. Known, deliberate exceptions: the Seed card's seed (typed) and Load
|
||||
Video's trim timecodes (typed).
|
||||
line. Known, deliberate exception: the Seed card's seed (typed).
|
||||
- **Node faces are widget cards.** A node whose face would be classic
|
||||
LiteGraph widgets (full-width rows with an arrow at each end) gets an
|
||||
entry in `js/widget_cards/index.js` instead: `mountWidgetCard` from
|
||||
@@ -234,6 +233,13 @@ example_workflows/ # example workflows (regular workflow JSON, not API JSON)
|
||||
widget per row. A value that is meant to be wired rather than typed is a
|
||||
backend `forceInput: True` socket (Math Expression `a`/`b`/`c`), and a
|
||||
multi-type string such as `"FLOAT,INT"` accepts either kind of link.
|
||||
- **App mode** is ComfyUI's form view of a workflow (fields and a Run
|
||||
button). A file list from the input folder declares its upload flag
|
||||
(`image_upload`, `video_upload`, `audio_upload`): the form builds the
|
||||
field's Upload button from it, and without it the field is a bare list.
|
||||
`tests/test_video_upload_flag.py` holds the video lists to it. A card's
|
||||
hidden widgets reach the form through `js/app_mode/`, so a card needs
|
||||
nothing of its own for App mode.
|
||||
- Preview-carrying nodes (Select Frame, Mask Refine, Mask by Name, LaMa
|
||||
Inpaint, Save Image) share
|
||||
`js/input_preview/`: a thin bar (node tools left, a small `preview`
|
||||
|
||||
@@ -80,6 +80,12 @@ It returns the `image`, a `mask` of everything the model paints (padding, see-th
|
||||
|
||||
Krea 2 Rotate + Outpaint turns a photo, pads it and paints the new area in one pass. [Try the Krea 2 Rotate + Outpaint example →](example_workflows/Krea%202%20Rotate%20%2B%20Outpaint%20%28AusBoss%29.json)
|
||||
|
||||
### Load Image
|
||||
|
||||
Loads a picture and sets its size in one node. Pick a file, upload one, or step through the input folder with the arrows. **Size** can stay off, or bring the picture to a megapixel count, a longest side, a scale, a box it must fit inside, or a box it fills by cropping. It can also cut a piece or a shape such as 16:9 out of the picture without resizing, and **Keep** picks which part stays: the center, a side or a corner. **Round to** keeps the result on a multiple of 8, 16 or whatever the model wants. The node shows the picture going in and coming out, with both sizes, before you run, such as `912 × 1632 → 1144 × 2048`.
|
||||
|
||||
It returns the `image`, a `mask` of its see-through parts, the new `width` and `height`, the `filename` for a save prefix, and the file's `original_width` and `original_height`.
|
||||
|
||||
### Load Image + Pad
|
||||
|
||||
Makes a canvas for outpainting: drag the edges out to add room around a picture. The Source list shows the picture under the pointer. The new area can be a solid color, the average color of the nearest edge, the edge pixels smeared outward, a blurred copy of the picture, or a mirror of it. The card also has a seam feather, a canvas multiple and a megapixel budget, and **Exact padding** opens one control per side. A budget of 0 keeps the picture's size, and anything higher resizes the picture before padding. A picture wired into `source_image` is padded instead of the chosen file.
|
||||
@@ -174,13 +180,13 @@ The example keeps the clip's audio when there is any. The outpaint LoRA needs a
|
||||
|
||||
### Load Video
|
||||
|
||||
Upload a video, or pick one from the Source list, which plays the clip under the pointer. Trim it with IN and OUT handles or typed timecodes. The player plays the part you kept and can loop it. Width and height resize while decoding, and setting only one keeps the shape. `every_nth` skips frames and lowers the reported fps so the timing stays right, and `max_frames` caps how many frames load.
|
||||
Upload a video, or pick one from the Source list, which plays the clip under the pointer. Set the part you want with Start, Duration and Ends at, in seconds or frames, or drag the handles under the player. The player plays the part you kept and can loop it. Width and height resize while decoding, and setting only one keeps the shape. `every_nth` skips frames and lowers the reported fps so the timing stays right, and the Duration caps how many frames load.
|
||||
|
||||
It returns the frames, audio, frame count, fps, width, height, duration and a core `VIDEO`. Only the part you kept is decoded, and it checks memory before a large load. When you save the frames, wire its fps into the save node.
|
||||
|
||||
### Load Audio
|
||||
|
||||
Upload a sound file, or pick one from the Source list, and the node shows it as a wave. Drag the IN and OUT handles to keep only the part you want, or type the times. Press play to hear just that part. Set **Max length** to the longest sound the next step can take, such as a video's length: anything past it turns red and is cut off, so you see what comes out before you run. Click the red length next to OUT to move OUT to the cut.
|
||||
Upload a sound file, or pick one from the Source list, and the node shows it as a wave. Drag the two handles to keep only the part you want, or type a Start, a Duration or an Ends at. Press play to hear just that part. Set the Duration to the length the next step needs, such as a video's length.
|
||||
|
||||
It returns the `audio` you kept and its length in `seconds`. Only that part is decoded. [Help page](js/docs/AUSBOSS_NODES_LoadAudio.md).
|
||||
|
||||
@@ -190,7 +196,7 @@ Picks one frame from a video, then gives you the same rotate, crop and pad contr
|
||||
|
||||
### Video Crop + Rotate + Pad → Clip
|
||||
|
||||
Applies one rotate, crop and pad to every frame of a trimmed clip. It has the source picker, a timeline with a playhead and frame-accurate IN and OUT handles, frame skipping, a frame limit, the transform handles and output resizing. While you drag a trim handle, the node shows the exact first or last frame the run keeps. The bright part of the selection is what gets output.
|
||||
Applies one rotate, crop and pad to every frame of a trimmed clip. It has the source picker, a timeline with a playhead and frame-accurate start and end handles, Start, Duration and Ends at boxes, frame skipping, the transform handles and output resizing. While you drag a trim handle, the node shows the exact first or last frame the run keeps. The bright part of the selection is what gets output.
|
||||
|
||||
Fill, feather and the resize budget are in **Crop, pad & resize** below the timeline, and a new clip keeps them. That matters for video outpainting, because the black, hard-edged canvas the model needs survives a source swap. A fresh Clip node starts with that canvas, and the editor's **Reset transform** goes back to it. **Frames for** trims the end to the frame count the next video model takes: LTX (8n+1) or Wan (4n+1). Tap a ratio to pad the clip to it; a new clip is padded to the lit ratio too. The padlock keeps the shape while you drag a handle.
|
||||
|
||||
@@ -480,7 +486,7 @@ People who download your workflow get the nodes through ComfyUI-Manager's missin
|
||||
- Hold Shift while you turn the green rotation handle to snap to 15° steps.
|
||||
- In the full-screen editor, the mouse wheel zooms, and the middle mouse button or Alt-drag pans. On the node itself, the wheel and middle mouse button still move the graph.
|
||||
- **Alt+E** opens the selected node's transform editor. Change the key in Settings → Keybindings.
|
||||
- The video editors have frame stepping, playback and exact timeline seeking, on the node face as well as in the editor. The Clip node's IN and OUT handles sit on the source's own frames, so the frame shown for IN is the first one decoded and the frame shown for OUT is the last.
|
||||
- The video editors have frame stepping, playback and exact timeline seeking, on the node face as well as in the editor. The Clip node's start and end handles sit on the source's own frames, so the frame shown at the start is the first one decoded and the frame shown at the end is the last.
|
||||
- Your own aspect presets go in `ausboss_presets.json` beside the pack. Copy [`ausboss_presets_example.json`](ausboss_presets_example.json) to start. Your file survives updates.
|
||||
|
||||
LoRA Loader and Latent Size have their own gear menus for per-node preferences.
|
||||
|
||||
@@ -37,6 +37,7 @@ NODE_MODULES = [
|
||||
"node_lama_inpaint",
|
||||
"node_layout_boxes",
|
||||
"node_literals",
|
||||
"node_load_image",
|
||||
"node_load_image_pad",
|
||||
"node_load_audio",
|
||||
"node_load_video",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="105" height="20" role="img" aria-label="release: v2.24.0">
|
||||
<title>release: v2.24.0</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="105" height="20" role="img" aria-label="release: v2.26.2">
|
||||
<title>release: v2.26.2</title>
|
||||
<path fill="#555" d="M0 0h48v20H0z"/>
|
||||
<path fill="#00b4aa" d="M48 0h57v20H48z"/>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||
<text x="24" y="14">release</text>
|
||||
<text x="76.5" y="14">v2.24.0</text>
|
||||
<text x="76.5" y="14">v2.26.2</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 425 B |
@@ -0,0 +1,45 @@
|
||||
// App mode for nodes with cards: the simple form view shows a real control
|
||||
// for each field instead of an empty row. The logic is in
|
||||
// js/shared/app_mode.mjs; this file watches which mode the open workflow is
|
||||
// in and hands the fields over.
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { createAppModeSync, workflowMode } from "../shared/app_mode.mjs";
|
||||
|
||||
const sync = createAppModeSync({
|
||||
find(nodeId, name) {
|
||||
const graph = app.rootGraph ?? app.graph;
|
||||
const node = graph?.getNodeById?.(/^\d+$/.test(nodeId) ? Number(nodeId) : nodeId);
|
||||
const widget = node?.widgets?.find((entry) => entry.name === name);
|
||||
return widget ? { node, widget } : null;
|
||||
},
|
||||
changed(node) {
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
},
|
||||
});
|
||||
|
||||
let queued = false;
|
||||
// After the current task: a card hides its widgets in a microtask once the
|
||||
// node has loaded, and the form's fields are shown after that.
|
||||
function schedule() {
|
||||
if (queued) return;
|
||||
queued = true;
|
||||
setTimeout(() => {
|
||||
queued = false;
|
||||
try {
|
||||
const workflow = app.extensionManager?.workflow?.activeWorkflow;
|
||||
sync(workflowMode(workflow), (app.rootGraph ?? app.graph)?.extra?.linearData);
|
||||
} catch (error) {
|
||||
console.warn("[AusBoss] App mode fields:", error);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "ausboss.app.mode",
|
||||
setup() {
|
||||
app.extensionManager?.workflow?.$subscribe?.(schedule);
|
||||
},
|
||||
afterConfigureGraph() {
|
||||
schedule();
|
||||
},
|
||||
});
|
||||
+115
-23
@@ -13,10 +13,12 @@ import { BRAND, chainCallback, keepDomWidgetWidthAuto } from "../shared/index.mj
|
||||
import {
|
||||
ARROW_ANGLE,
|
||||
ARROW_CHOICES,
|
||||
CARD_TEMPLATE,
|
||||
DOUBLE_ARROWS,
|
||||
arrowText,
|
||||
fitFontSize,
|
||||
parseBlocks,
|
||||
parseCard,
|
||||
pastedLink,
|
||||
repointLinks,
|
||||
targetId,
|
||||
@@ -45,6 +47,10 @@ const LINK_TILES = {
|
||||
youtube: { label: "Watch Me on YouTube", url: "https://www.youtube.com/@ausbossdev" },
|
||||
discord: { label: "Join for Help or More Workflows", url: "https://discord.gg/RwVxY9Fuaj" },
|
||||
};
|
||||
// A new Info card opens at this size, which shows its starter text whole.
|
||||
const CARD_SIZE = [300, 230];
|
||||
// The card's text grows with the node like a note's, but a card stays a card.
|
||||
const CARD_FONT_MAX = 20;
|
||||
const FRAME_FILL = 0.8; // the share of the view a node brought into view takes, as in Workflow Switches
|
||||
const FONT = '"IBM Plex Sans", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif';
|
||||
|
||||
@@ -81,6 +87,20 @@ ${TILE_FACE_CSS}
|
||||
.ausboss-callout-card[data-tile] .ausboss-callout-url svg{width:36px;height:28px;flex:none}
|
||||
.ausboss-callout-card[data-tile] .ausboss-callout-out{margin-left:auto}
|
||||
.ausboss-callout-card[data-tile] .ausboss-callout-tools{right:27px;}
|
||||
.ausboss-callout-card[data-card]{background:#111818;border:1px solid #2e3c3b;}
|
||||
.ausboss-callout-card[data-card] .ausboss-callout-inner{padding:.8em 1em;color:#d9e4e3;font-weight:400;line-height:1.45;}
|
||||
.ausboss-callout-card[data-card] b{color:#f2f7f6;font-weight:650;}
|
||||
.ausboss-card-block{margin:0 0 .85em;}
|
||||
.ausboss-card-block:last-child{margin-bottom:0;}
|
||||
.ausboss-card-block>*+*{margin-top:.3em;}
|
||||
.ausboss-card-title{display:flex;align-items:center;gap:.4em;color:#f2f7f6;font-size:1.08em;font-weight:650;}
|
||||
.ausboss-card-icon{flex:none;width:1em;height:1em;color:#c9d6d4;}
|
||||
.ausboss-card-icon svg{display:block;width:100%;height:100%;}
|
||||
.ausboss-card-row{display:flex;justify-content:space-between;align-items:baseline;gap:1em;}
|
||||
.ausboss-card-row>span:last-child{flex:none;text-align:right;white-space:nowrap;}
|
||||
.ausboss-card-row.is-mark,.ausboss-card-row.is-mark b{color:#6fe0d6;font-weight:500;}
|
||||
.ausboss-card-small,.ausboss-card-small b{color:#93a6a4;}
|
||||
.ausboss-card-small{font-size:.92em;}
|
||||
.ausboss-callout-empty{color:#6f8987;font-size:14px;font-weight:400;}
|
||||
.ausboss-callout-arrow{display:inline-block;width:1.2em;height:1.2em;margin:0 .1em;vertical-align:-.26em;filter:drop-shadow(0 0 .3em rgba(0,180,170,.55));}
|
||||
.ausboss-callout-arrow svg{display:block;width:100%;height:100%;overflow:visible;}
|
||||
@@ -154,6 +174,25 @@ function arrowIcon(kind) {
|
||||
return root;
|
||||
}
|
||||
|
||||
// The small line icons an Info card's title can start with.
|
||||
const CARD_ICON_PATHS = {
|
||||
clock: ["M12 7v5l3.2 2"],
|
||||
info: ["M12 11v6", "M12 7.6v.01"],
|
||||
warning: ["M12 3.5 2.8 19.5h18.4Z", "M12 10v4", "M12 16.9v.01"],
|
||||
tip: ["M9.5 18h5", "M10.5 21h3", "M12 3a6 6 0 0 0-3.6 10.8c.7.6 1.1 1.3 1.1 2.2h5c0-.9.4-1.6 1.1-2.2A6 6 0 0 0 12 3Z"],
|
||||
check: ["M8 12.4l2.8 2.8 5.2-5.6"],
|
||||
};
|
||||
const CARD_ICON_RING = new Set(["clock", "info", "check"]);
|
||||
|
||||
function cardIcon(kind) {
|
||||
const span = el("span", "ausboss-card-icon");
|
||||
const root = svg("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" });
|
||||
if (CARD_ICON_RING.has(kind)) root.append(svg("circle", { cx: 12, cy: 12, r: 9 }));
|
||||
for (const d of CARD_ICON_PATHS[kind] ?? []) root.append(svg("path", { d }));
|
||||
span.append(root);
|
||||
return span;
|
||||
}
|
||||
|
||||
// The node a link names, looked up in the graph the note sits in.
|
||||
function linkedNode(state, id) {
|
||||
const graph = state.node.graph ?? app.graph;
|
||||
@@ -262,17 +301,79 @@ function bringIntoView(target) {
|
||||
}
|
||||
}
|
||||
|
||||
// One line's pieces into an element. The pieces of one link sit in one
|
||||
// element; a link that leaves ComfyUI ends with a small ↗.
|
||||
function appendPieces(state, into, line) {
|
||||
let run = null;
|
||||
let wrap = null;
|
||||
const close = () => {
|
||||
if (wrap?.classList.contains("ausboss-callout-url")) wrap.append(el("span", "ausboss-callout-out", "↗"));
|
||||
};
|
||||
for (const piece of line) {
|
||||
if (piece.run !== run) {
|
||||
close();
|
||||
run = piece.run;
|
||||
wrap = run === undefined ? null : linkRun(state, piece);
|
||||
if (wrap) into.append(wrap);
|
||||
}
|
||||
const target = wrap ?? into;
|
||||
if (piece.arrow) target.append(arrowSpan(state, piece.arrow, piece));
|
||||
else target.append(piece.bold ? el("b", "", piece.text) : document.createTextNode(piece.text));
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
// An Info card: a title, rows of label and value, and small print.
|
||||
function renderCard(state, blocks) {
|
||||
for (const lines of blocks) {
|
||||
const block = el("div", "ausboss-card-block");
|
||||
for (const line of lines) {
|
||||
let row;
|
||||
if (line.kind === "title") {
|
||||
row = el("div", "ausboss-card-title");
|
||||
if (line.icon) row.append(cardIcon(line.icon));
|
||||
const words = el("span");
|
||||
appendPieces(state, words, line.pieces);
|
||||
row.append(words);
|
||||
} else if (line.kind === "row") {
|
||||
row = el("div", `ausboss-card-row${line.highlight ? " is-mark" : ""}`);
|
||||
for (const cell of line.cells) {
|
||||
const side = el("span");
|
||||
appendPieces(state, side, cell);
|
||||
row.append(side);
|
||||
}
|
||||
} else {
|
||||
row = el("div", "ausboss-card-text");
|
||||
appendPieces(state, row, line.pieces);
|
||||
}
|
||||
if (line.small) row.classList.add("ausboss-card-small");
|
||||
block.append(row);
|
||||
}
|
||||
state.inner.append(block);
|
||||
}
|
||||
}
|
||||
|
||||
function renderText(state) {
|
||||
const style = state.node.properties?.ausbossCalloutTile;
|
||||
if (["youtube","discord","title"].includes(style)) state.card.dataset.tile = style;
|
||||
else delete state.card.dataset.tile;
|
||||
setTileFace(state.node, state.root, Boolean(state.card.dataset.tile), () => startEdit(state));
|
||||
const blocks = parseBlocks(state.valueWidget.value);
|
||||
// An Info card has no title bar, like a tile, but keeps the full editor
|
||||
// and saves as a plain Callout: an older pack shows its text as a note.
|
||||
if (style === "card") state.card.dataset.card = "";
|
||||
else delete state.card.dataset.card;
|
||||
const isCard = style === "card";
|
||||
setTileFace(state.node, state.root, Boolean(state.card.dataset.tile) || isCard, () => startEdit(state));
|
||||
const blocks = isCard ? parseCard(state.valueWidget.value) : parseBlocks(state.valueWidget.value);
|
||||
state.inner.replaceChildren();
|
||||
state.empty = blocks.length === 0;
|
||||
if (state.empty) {
|
||||
state.inner.append(el("div", "ausboss-callout-empty", "Double-click to write a note"));
|
||||
}
|
||||
if (isCard) {
|
||||
renderCard(state, blocks);
|
||||
fit(state);
|
||||
return;
|
||||
}
|
||||
for (const lines of blocks) {
|
||||
const point = el("div", "ausboss-callout-point");
|
||||
lines.forEach((line, index) => {
|
||||
@@ -280,21 +381,7 @@ function renderText(state) {
|
||||
// lines are told apart by a break, as before; a block needs none.
|
||||
const into = line.small ? el("div", "ausboss-callout-small") : point;
|
||||
if (index && !line.small && !lines[index - 1].small) point.append(document.createElement("br"));
|
||||
let run = null;
|
||||
let wrap = null;
|
||||
for (const piece of line) {
|
||||
// The pieces of one link sit in one element.
|
||||
if (piece.run !== run) {
|
||||
if (wrap?.classList.contains("ausboss-callout-url")) wrap.append(el("span", "ausboss-callout-out", "↗"));
|
||||
run = piece.run;
|
||||
wrap = run === undefined ? null : linkRun(state, piece);
|
||||
if (wrap) into.append(wrap);
|
||||
}
|
||||
const target = wrap ?? into;
|
||||
if (piece.arrow) target.append(arrowSpan(state, piece.arrow, piece));
|
||||
else target.append(piece.bold ? el("b", "", piece.text) : document.createTextNode(piece.text));
|
||||
}
|
||||
if (wrap?.classList.contains("ausboss-callout-url")) wrap.append(el("span", "ausboss-callout-out", "↗"));
|
||||
appendPieces(state, into, line);
|
||||
if (line.small) point.append(into);
|
||||
});
|
||||
state.inner.append(point);
|
||||
@@ -364,7 +451,7 @@ function fit(state) {
|
||||
inner.style.fontSize = `${px}px`;
|
||||
return inner.offsetHeight <= height && inner.scrollWidth <= width + 1;
|
||||
};
|
||||
const size = fitFontSize(fits);
|
||||
const size = fitFontSize(fits, undefined, card.dataset.card === undefined ? undefined : CARD_FONT_MAX);
|
||||
const social = card.dataset.tile === "youtube" || card.dataset.tile === "discord";
|
||||
inner.style.fontSize = `${social ? Math.min(size, 16) : size}px`;
|
||||
}
|
||||
@@ -453,7 +540,9 @@ function startEdit(state) {
|
||||
const wrap = el("div", "ausboss-callout-editor");
|
||||
const area = el("textarea", "ausboss-callout-edit");
|
||||
area.value = state.valueWidget.value ?? "";
|
||||
area.placeholder = "One idea per paragraph. **Bold** a word to stress it. The buttons below add an arrow, make a line small or make words a link.";
|
||||
area.placeholder = state.card.dataset.card === undefined
|
||||
? "One idea per paragraph. **Bold** a word to stress it. The buttons below add an arrow, make a line small or make words a link."
|
||||
: "The first line is the title. Write label | value for a row. **Bold** a whole row to make it teal. Small makes a line small print.";
|
||||
area.spellcheck = true;
|
||||
const bar = el("div", "ausboss-callout-arrowbar");
|
||||
bar.append(el("span", "", "Arrow"));
|
||||
@@ -560,7 +649,6 @@ function startEdit(state) {
|
||||
if (event.target !== area) event.preventDefault();
|
||||
});
|
||||
wrap.addEventListener("pointerdown", (event) => event.stopPropagation());
|
||||
wrap.addEventListener("wheel", (event) => event.stopPropagation(), { passive: true });
|
||||
// Clicking another node on the canvas takes the keyboard from the text box.
|
||||
// That is how the link is picked, so the edit stays open then; a click on
|
||||
// empty canvas, or on the note itself, ends it.
|
||||
@@ -687,7 +775,7 @@ app.registerExtension({
|
||||
const state = buildPanel(this);
|
||||
if (!state) return;
|
||||
renderText(state);
|
||||
if (state.card.dataset.tile && Number.isFinite(saved?.size?.[1])) {
|
||||
if ((state.card.dataset.tile || state.card.dataset.card !== undefined) && Number.isFinite(saved?.size?.[1])) {
|
||||
this.setSize?.([this.size[0], saved.size[1]]);
|
||||
}
|
||||
});
|
||||
@@ -699,14 +787,18 @@ app.registerExtension({
|
||||
chainCallback(nodeType.prototype, "getExtraMenuOptions", function (_canvas, options) {
|
||||
const state = this.__ausbossCallout;
|
||||
if (!state || !Array.isArray(options)) return;
|
||||
for (const [style, label] of [["plain","Plain callout"],["title","Title tile"],["youtube","Set YouTube link tile"],["discord","Set Discord link tile"]]) {
|
||||
for (const [style, label] of [["plain","Plain callout"],["card","Info card"],["title","Title tile"],["youtube","Set YouTube link tile"],["discord","Set Discord link tile"]]) {
|
||||
options.unshift({ content: label, callback: () => {
|
||||
this.properties ??= {};
|
||||
this.properties.ausbossCalloutTile = style;
|
||||
const preset = LINK_TILES[style];
|
||||
if (preset) commitWidgetValue(this, state.valueWidget, `[${preset.label}](${preset.url})`, app.canvas);
|
||||
// An empty card starts with text that shows how one is written.
|
||||
const starter = style === "card" && !String(state.valueWidget.value ?? "").trim();
|
||||
if (starter) commitWidgetValue(this, state.valueWidget, CARD_TEMPLATE, app.canvas);
|
||||
renderText(state);
|
||||
if (style !== "plain") this.setSize?.([this.size[0], style === "title" ? 86 : 78]);
|
||||
if (starter) this.setSize?.([Math.max(this.size[0], CARD_SIZE[0]), CARD_SIZE[1]]);
|
||||
else if (style !== "plain" && style !== "card") this.setSize?.([this.size[0], style === "title" ? 86 : 78]);
|
||||
markChanged();
|
||||
}});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// zooming stopped over Compare, the crop previews, the video viewers and every
|
||||
// control on a card. One listener here hands those gestures back, the same way
|
||||
// ComfyUI does for its own text boxes. A panel that wants the wheel for itself
|
||||
// (a scrolling list, a focused text field, an editor) still keeps it.
|
||||
// (a scrolling list, a long text box) keeps it while it can still scroll.
|
||||
//
|
||||
// A file dragged in from the desktop, or a picture's card from the Assets
|
||||
// panel, has the same problem in the classic renderer: dropped on a node's
|
||||
@@ -31,7 +31,7 @@ function onWheel(event) {
|
||||
const root = panelRoot(target);
|
||||
const lgCanvas = canvas();
|
||||
if (!root || !lgCanvas || event.defaultPrevented) return;
|
||||
if (panelKeepsWheel(target, event, { root, host: panelHost(target), styleOf: (el) => getComputedStyle(el), activeElement: document.activeElement })) return;
|
||||
if (panelKeepsWheel(target, event, { root, host: panelHost(target), styleOf: (el) => getComputedStyle(el) })) return;
|
||||
event.preventDefault();
|
||||
lgCanvas.processMouseWheel(event);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// Clear VRAM 🆎 — a right-click entry on the empty canvas that unloads every
|
||||
// model and frees memory on the ComfyUI server this page is connected to.
|
||||
//
|
||||
// It sends the same request as ComfyUI's own "Unload Models and Execution
|
||||
// Cache" command (top menu, Edit): POST /free with unload_models and
|
||||
// free_memory. That command is not on the right-click menu, so this entry
|
||||
// puts it one click away. A setting hides the entry; a ComfyUI that turns
|
||||
// manual unloading off (Comfy.Memory.AllowManualUnload) hides it too.
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { showToast } from "../shared/index.mjs";
|
||||
|
||||
const SETTING_ID = "AusBoss.Memory.ClearVramMenu";
|
||||
const MENU_LABEL = "Clear VRAM 🆎";
|
||||
|
||||
function setting(id) {
|
||||
return app.ui?.settings?.getSettingValue?.(id);
|
||||
}
|
||||
|
||||
async function clearVram() {
|
||||
try {
|
||||
const response = await api.fetchApi("/free", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ unload_models: true, free_memory: true }),
|
||||
});
|
||||
if (!response.ok) throw new Error(`the server answered ${response.status}`);
|
||||
showToast({ severity: "success", summary: MENU_LABEL, detail: "Models unloaded and memory freed.", life: 3000 });
|
||||
} catch (error) {
|
||||
showToast({ severity: "error", summary: MENU_LABEL, detail: `Could not clear VRAM: ${error?.message ?? error}` });
|
||||
}
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: "ausboss.clear.vram",
|
||||
settings: [
|
||||
{
|
||||
id: SETTING_ID,
|
||||
name: "Clear VRAM on the right-click menu",
|
||||
type: "boolean",
|
||||
defaultValue: true,
|
||||
category: ["🆎 AusBoss", "Memory", "Clear VRAM menu"],
|
||||
tooltip:
|
||||
"Right-click the empty canvas for Clear VRAM: it unloads every model and frees "
|
||||
+ "memory on the ComfyUI server. Off hides the entry.",
|
||||
},
|
||||
],
|
||||
getCanvasMenuItems() {
|
||||
if (setting(SETTING_ID) === false) return [];
|
||||
if (setting("Comfy.Memory.AllowManualUnload") === false) return [];
|
||||
return [{ content: MENU_LABEL, callback: clearVram }];
|
||||
},
|
||||
});
|
||||
@@ -15,7 +15,38 @@ Right-click the Callout and choose **Title tile** to give your existing text a b
|
||||
- Double-click a title to edit it. **Save** or `Ctrl+Enter` keeps the change; **Cancel** or `Esc` leaves the original text.
|
||||
- Drag the visible bottom-right grip to resize. You can also focus the grip and use arrow keys; hold **Shift** for smaller changes. Resizing keeps the tile in place and supports Undo.
|
||||
|
||||
## Writing
|
||||
## Info card
|
||||
|
||||
A small card for facts people look up: run times, settings, what each choice
|
||||
does. Right-click the Callout and choose **Info card**. An empty note starts
|
||||
with sample text that shows each part.
|
||||
|
||||
Write it like this:
|
||||
|
||||
```text
|
||||
⏱️ Too slow?
|
||||
###### Redraw time on an RTX 5090. Smaller cards take longer.
|
||||
|
||||
2x, 18 steps | ~4 min
|
||||
2x, 10 steps | ~3 min
|
||||
1.5x, 18 steps | ~2.5 min
|
||||
**1.5x, 10 steps (default) | ~2 min**
|
||||
|
||||
###### 1.5x is a 4608-wide sheet, 2x is 6144.
|
||||
```
|
||||
|
||||
- The first line is the card's title. Start it with ⏱️ ℹ️ ⚠️ 💡 or ✅ and
|
||||
that emoji is drawn as a small icon.
|
||||
- A line with a `|` in it is a row: the words before the `|` on the left,
|
||||
the rest on the right.
|
||||
- Put the whole row in two stars, `**like this | value**`, and it is drawn
|
||||
in teal. Use it for the default or the one to pick.
|
||||
- Small print (the **Small** button) is a grey line, for a subtitle or a note
|
||||
at the bottom.
|
||||
- A blank line leaves a gap. Arrows and links work as in any callout.
|
||||
- Double-click the card to edit it. Choose **Plain callout** to turn it back
|
||||
into a note; the text stays.
|
||||
|
||||
|
||||
- On a plain callout, double-click the note, or press **Edit**, to type. Click outside the box to
|
||||
keep the text. **Esc** drops what you typed.
|
||||
@@ -90,5 +121,13 @@ In the text a link is written `[the words](https://example.com)`, or
|
||||
it to read the address before you click.
|
||||
- An older version of the pack shows a link as typed, brackets and address
|
||||
included, so the address can still be read and copied there.
|
||||
- An Info card is saved as an ordinary Callout with the text you typed.
|
||||
The card look is a setting on the node, so an older version of the pack
|
||||
shows the same text as a plain note, rows written out as `label | value`.
|
||||
A plain callout never reads `|` as a row, so notes written before look
|
||||
the same.
|
||||
- A row splits at its first `|` that is not inside a link. A row pasted
|
||||
from a Markdown table loses its outer pipes, and the table's `---` line
|
||||
is skipped. An Info card's text grows with the card, up to 20 px.
|
||||
- The font is IBM Plex Sans when the computer has it, otherwise the system
|
||||
font. The node loads no fonts and makes no network requests.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Edit Lock Restore
|
||||
|
||||
Puts your picture's own pixels back in every part the edit did not change.
|
||||
Puts your picture's own pixels back in every part the edit did not change,
|
||||
and takes out the faint pink tint some edit models add to the whole picture.
|
||||
|
||||
**Edit Lock 🆎** keeps the untouched parts in place while the picture is
|
||||
made. They still pass through the VAE, which softens fine detail a little.
|
||||
@@ -22,6 +23,14 @@ your picture pixel for pixel. Only the edit is new.
|
||||
- **Feather** (`feather`): how softly your original fades into the edit,
|
||||
in pixels. 16 is the default. The fade lies outside the edit, so the
|
||||
edit itself is never mixed with the old picture.
|
||||
- **Remove tint** (`remove_tint`): on by default. MiniMax H3 Image makes
|
||||
every edit a little pinker and lighter all over. This reads that tint
|
||||
from the part of the picture the edit left alone and takes it out of the
|
||||
whole picture, the edit included. It matters most when Edit Lock stepped
|
||||
aside, such as for a new hair color, a new background or rain, because
|
||||
then nothing else removes it. Edits meant to recolor everything (golden
|
||||
hour, red light, a new art style) are left alone. Turn it off if a color
|
||||
change you asked for comes out weaker.
|
||||
|
||||
## Outputs
|
||||
|
||||
@@ -30,13 +39,15 @@ your picture pixel for pixel. Only the edit is new.
|
||||
what the lock decided, or for a later step that should only touch the
|
||||
edit.
|
||||
- **report**: one line, such as "Edit Lock kept 82% of your picture as it
|
||||
was and left 18% to the edit".
|
||||
was and left 18% to the edit". When the tint was taken out it adds a
|
||||
sentence that says so.
|
||||
|
||||
## When nothing was locked
|
||||
|
||||
The picture passes through unchanged, the mask is all white, and the
|
||||
Your original pixels are not pasted back, the mask is all white, and the
|
||||
report says why: the edit changed the whole picture, the lock was off, or
|
||||
the picture and the result were different sizes.
|
||||
the picture and the result were different sizes. Remove tint still works
|
||||
here, so the picture can come out with the tint taken out.
|
||||
|
||||
## Technical details
|
||||
|
||||
@@ -46,3 +57,17 @@ by the same amount, and used to blend the decoded picture with your
|
||||
original. If the decoded picture is not the size of your original (after
|
||||
an upscale), the original is resized to fit first, which costs it some
|
||||
sharpness. That is why this node goes before an upscaler.
|
||||
|
||||
**Remove tint.** The edit is lined up with your original (edits often come
|
||||
back about one percent larger or a little shifted), both are averaged
|
||||
into coarse cells of about 8 px at 1 megapixel, and their difference is
|
||||
taken in Lab color. The tint is the even shift most cells share: it starts
|
||||
at the median and keeps only cells within 4 Lab units of it, five times
|
||||
over, so a new background or new hair drops out of the count. It is taken
|
||||
out only when it looks like the model's own tint: a between +0.5 and +10,
|
||||
b between -8 and 0, L between -1 and +6, read on at least 15% of the
|
||||
picture. On 21 test edits at 16 megapixels it took out the tint on the 5
|
||||
it should (a +2.6 to +6.5 down to +0.4 or less) and left the other 16
|
||||
alone, golden hour, red light and an anime restyle included. It cannot
|
||||
tell this tint from an edit that asks for a slightly pinker, lighter look
|
||||
over the whole picture; turn it off for one of those.
|
||||
|
||||
@@ -5,37 +5,31 @@ clip, a song or any sound a video model or a save node takes, when you want
|
||||
one part of the file and not the whole thing.
|
||||
|
||||
The node shows the whole file as a wave, so you can see where the loud parts
|
||||
are. The part that comes out is bright. Drag the white **IN** and **OUT**
|
||||
handles to set where it starts and stops, drag the bright part to slide it,
|
||||
or click somewhere else on the wave to move it there. You can also type a time
|
||||
under the wave, in seconds (`12.5`) or minutes and seconds (`1:02.5`).
|
||||
are. The part that comes out is bright. Under the wave are three boxes:
|
||||
**Start**, **Duration** and **Ends at**, in seconds. Drag the left handle to
|
||||
move the start, drag the right handle or type a Duration to change how long
|
||||
the sound is, or drag the bright part to slide it. Click somewhere else on
|
||||
the wave to move it there. Typing **Ends at** sets the Duration for you.
|
||||
|
||||
Press **▶** to hear only the part that comes out. **LOOP** plays it again and
|
||||
again.
|
||||
|
||||
## Max length
|
||||
Set the Duration to the length the next step needs, such as the length of
|
||||
the video you are making. An empty Duration runs to the end of the file.
|
||||
|
||||
Set **Max length** to the longest sound the next step can take, such as the
|
||||
length of the video you are making. The start stays where it is, and anything
|
||||
past the limit turns red with a dashed line where it is cut. Next to OUT,
|
||||
the node shows how long the sound that comes out is, such as `15.0 s`. It
|
||||
turns red when part of your pick is cut; hold the mouse over it to see how
|
||||
much, and click it to move OUT to the cut. Play stops at the cut, so what you
|
||||
hear is what comes out. `0` means no limit.
|
||||
|
||||
Max length can be wired. When the wire comes from a number node such as
|
||||
Float 🆎, the wave shows the cut for that number; otherwise the length's tooltip says
|
||||
`max wired` and the run still cuts the sound to the wired length.
|
||||
A box set by another node, such as Float 🆎, shows a **linked** button that
|
||||
jumps to that node, and the wave shows the part that number picks.
|
||||
|
||||
## Controls
|
||||
|
||||
- **Source** (`audio`): a sound file in ComfyUI's input folder. **Upload**
|
||||
adds one. Videos are listed as well, for their sound.
|
||||
- **Max length** (`max_seconds`): the longest the sound may be, in seconds.
|
||||
`0` means no limit.
|
||||
- **IN** (`start_seconds`): where the sound starts.
|
||||
- **OUT** (`end_seconds`): where the sound stops. `0` means the end of the
|
||||
file.
|
||||
- **Start** (`start_seconds`): where the sound starts.
|
||||
- **Duration** (`max_seconds`): how long the sound is, in seconds. Empty, or
|
||||
`0`, runs to the end of the file.
|
||||
- **Ends at**: where the sound stops. Typing it sets the Duration.
|
||||
A workflow saved with an end time (`end_seconds`) keeps it and runs the
|
||||
same.
|
||||
|
||||
## Outputs
|
||||
|
||||
@@ -49,4 +43,4 @@ Float 🆎, the wave shows the cut for that number; otherwise the length's toolt
|
||||
- The sound keeps its own sample rate and channels.
|
||||
- A start past the end of the file stops the run with a message that says so.
|
||||
- The wave is drawn in the browser from the file itself; nothing extra is
|
||||
stored with the workflow besides the four values above.
|
||||
stored with the workflow besides the node's own values.
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
# Load Image
|
||||
|
||||
Loads a picture and sets its size in the same node, so a workflow does not
|
||||
need a resize node and a size node after its loader.
|
||||
|
||||
Pick a file in **Source**, press **Load** to upload one, or use the arrows
|
||||
under it to step through the pictures in ComfyUI's input folder. The line
|
||||
beside the arrows shows the size of the file and, when the size changes, the
|
||||
size that comes out:
|
||||
|
||||
`912 × 1632 → 1144 × 2048`
|
||||
|
||||
That is the real output size, worked out before you run.
|
||||
|
||||
Under that line are two small pictures: the file as it goes in, and the
|
||||
picture as it comes out. On the first one the part that is kept is lit and
|
||||
the part that is cut off is dark. Between them the node says the shape
|
||||
(`3:4 → 1:1`) and what happens (`77% size`, `cuts 449 px of height`).
|
||||
|
||||
## Size
|
||||
|
||||
**Size** (`size`) picks how the picture is resized. Each choice shows only
|
||||
the numbers it uses.
|
||||
|
||||
| Choice | What it does | Its number |
|
||||
|---|---|---|
|
||||
| **off** | The picture comes out exactly as the file has it. | none |
|
||||
| **megapixels** | Brings the whole picture to a total size and keeps its shape. | **Megapixels** (`megapixels`): 1.0 is about 1024 × 1024 |
|
||||
| **longest side** | Sets the longer edge; the other edge follows. | **Longest side** (`longest_side`), in pixels |
|
||||
| **scale** | Multiplies both edges. | **Scale** (`scale`): 0.5 is half, 2 is double |
|
||||
| **fit inside** | Makes the picture as big as it can be inside a box, with nothing cut off. | **Width** and **Height** (`width`, `height`) |
|
||||
| **crop to fill** | Covers the box completely and cuts off what sticks out. | **Width** and **Height** |
|
||||
| **crop** | Cuts a piece of that size out of the picture. Nothing is resized. | **Width** and **Height** |
|
||||
| **crop to ratio** | Cuts the largest piece of a shape, such as 16:9, out of the picture. Nothing is resized. | **Ratio** (`ratio`) |
|
||||
|
||||
**Round to** (`multiple`) rounds the new width and height to a multiple of
|
||||
that number. Most models want 8 or 16. Set it to 1 to keep the numbers as
|
||||
they are. It does nothing while Size is off.
|
||||
|
||||
## Which part is kept
|
||||
|
||||
The three crop choices show **Keep** (`crop_from`). It picks the part of the
|
||||
picture that stays: `center` cuts evenly from both sides, `top` keeps the top
|
||||
and cuts from the bottom, `bottom left` keeps that corner, and so on.
|
||||
|
||||
You can also click the first small picture: click its top to keep the top,
|
||||
a corner to keep that corner. The lit part moves so you see what you get.
|
||||
|
||||
In **Ratio**, `width : height` takes the shape from the Width and Height
|
||||
boxes, for a shape that is not in the list (1600 and 900 give 16:9).
|
||||
|
||||
## More
|
||||
|
||||
- **Method** (`method`): how pixels are resampled. `lanczos` is the sharpest
|
||||
for photos. `nearest` keeps pixel art crisp.
|
||||
- **Enlarge** (`enlarge`): on, a small picture is made bigger to reach the
|
||||
size you asked for. Off, a picture is only ever made smaller: one that is
|
||||
already below the target comes out at its own size, and crop to fill cuts
|
||||
the box's shape out of it without growing it.
|
||||
|
||||
## The picture on the node
|
||||
|
||||
The picture under the settings is ComfyUI's own preview, the same one the
|
||||
stock Load Image shows. Drop a file on the node or paste one to upload it,
|
||||
and right-click the node for the mask editor and for copy and paste.
|
||||
|
||||
## Outputs
|
||||
|
||||
- `image`: the picture at its new size.
|
||||
- `mask`: white where the picture is see-through and black where it is
|
||||
solid, as the stock loader gives it. A picture with no transparency gives
|
||||
an all black mask. It is always the same size as `image`.
|
||||
- `width`, `height`: the size that comes out.
|
||||
- `filename`: the file's name without its folder or its ending
|
||||
(`shots/hero.png` gives `hero`), ready for a save node's prefix.
|
||||
- `original_width`, `original_height`: the size of the file before any
|
||||
resize. Use them to bring a result back to the size you started from.
|
||||
|
||||
## Which loader to use
|
||||
|
||||
- **Load Image** (this node): load a picture and set its size.
|
||||
- **Load Image + Pad**: add empty space around a picture for outpainting.
|
||||
- **Image Crop + Rotate + Pad**: turn, crop and pad a picture by hand.
|
||||
|
||||
## Technical details
|
||||
|
||||
- Every frame of an animated file comes through as a batch, all at the same
|
||||
new size. A phone photo is turned the way its EXIF data says.
|
||||
- With Size off the pixels are the file's own, bit for bit, and Round to is
|
||||
not applied.
|
||||
- Rounding moves each edge to the nearest multiple, so the shape can change
|
||||
by up to half a step. Fit inside rounds down instead, so the result never
|
||||
leaves its box.
|
||||
- Crop to fill resizes the picture until it covers the box, then cuts the
|
||||
box out at the side Keep names. The mask goes through the same resize and
|
||||
the same cut.
|
||||
- Crop and crop to ratio only cut. A box larger than the picture is cut down
|
||||
to the picture, and Round to rounds down so the piece stays inside it.
|
||||
Enlarge does not apply to them.
|
||||
- The small pictures are drawn on one scale, so a picture made half as large
|
||||
is drawn half as large.
|
||||
- With Enlarge off, a rounded size is rounded down so it never passes the
|
||||
file's own size.
|
||||
- The size line on the node uses the same arithmetic as the run. The pack's
|
||||
tests hold the two to the same answers over a table of cases.
|
||||
- Files are read only from ComfyUI's input, output and temp folders. A name
|
||||
such as `photo.png [output]` loads a picture ComfyUI made.
|
||||
- The node runs again when the file changes on disk or a setting changes.
|
||||
@@ -1,37 +1,33 @@
|
||||
# Load Video
|
||||
|
||||
Loads a video from ComfyUI's input folder as an `IMAGE` frame batch plus its
|
||||
audio. One responsive player shows the source and previews the selected trim.
|
||||
Drag the high-contrast **IN** and **OUT** handles below it, drag the selected
|
||||
range to move the whole window, or type a time into the two fields, in seconds
|
||||
(`95.5`) or as a timecode (`1:35.5`). Click the strip outside the selection to
|
||||
move the window to that spot.
|
||||
The playhead follows each edit, so the frame at either boundary is visible
|
||||
while trimming. In **Source**, the list plays the clip under the pointer, muted, and filters as you type.
|
||||
audio. The player shows the video; the timing card under it picks the part
|
||||
that comes out.
|
||||
|
||||
Playback is constrained to the selected window. **LOOP** repeats it; turn loop
|
||||
off and playback pauses at OUT. The reload button refreshes the source without
|
||||
creating a second preview. The player takes the height you give the node:
|
||||
drag the node taller for a bigger picture. A tall video is shown whole, never
|
||||
cropped.
|
||||
The timing card has three boxes: **Start**, **Duration** and **Ends at**.
|
||||
Drag the left handle on the bar to move the start, drag the right handle or
|
||||
type a Duration to change how long the clip is, or drag the middle of the
|
||||
clip to slide it. **s | fr** switches every box between seconds and frames;
|
||||
it only changes what you see, never a saved value. **Use as start** starts
|
||||
the clip at the frame in the picture, and **Whole video** puts the clip back
|
||||
to the full file. In **Source**, the list plays the clip under the pointer,
|
||||
muted, and filters as you type.
|
||||
|
||||
**FRAME** switches the loader into a frame picker: the trim strip becomes a
|
||||
single scrub rail, and only the frame at the marker loads — a one-image batch,
|
||||
ready for image workflows without a separate frame-select node. Click or drag
|
||||
anywhere on the rail to choose the frame, or type an exact time into the AT
|
||||
field. Playback runs the whole source freely in this mode so you can hunt for
|
||||
the right moment. Picking a frame moves IN to that time. When you toggle back,
|
||||
OUT stays where it was, unless the frame is at or after OUT: then OUT moves to
|
||||
the end of the video.
|
||||
The player takes the height you give the node: drag the node taller for a
|
||||
bigger picture. A tall video is shown whole, never cropped. **LOOP** plays
|
||||
the clip again and again; with it off, playback pauses at the clip's end.
|
||||
The reload button refreshes the source.
|
||||
|
||||
The label between IN and OUT reports what one Run will actually load — e.g.
|
||||
`0:04.0 of 0:10.0 · 48 frames @ 12 fps`, or `1 frame at 0:05.2` while FRAME
|
||||
is on. The preview cannot re-render `every_nth` frame drops or a `max_frames`
|
||||
cap, so it counts them instead: the frame total and playback rate come from
|
||||
the source's real frame rate (probed from the file, since the browser's
|
||||
player never exposes it) with `every_nth` and `max_frames` applied. When a
|
||||
deciding value arrives over a link, or the rate cannot be probed, the count
|
||||
drops out rather than guessing.
|
||||
**FRAME** turns the loader into a frame picker: only the frame at the marker
|
||||
loads, as a one-image batch, ready for image workflows without a separate
|
||||
frame-select node. Drag the bar to choose the frame, or type it into the
|
||||
**FRAME** box. Playback runs the whole video in this mode so you can hunt for
|
||||
the right moment. Picking a frame moves the clip's start there.
|
||||
|
||||
The boxes count real frames: the frame rate and frame count come from the
|
||||
file itself, so a 4.1 s clip at 60 fps reads 247 frames, the same number
|
||||
the run loads. When a box is set by another node it shows a **linked**
|
||||
button that jumps to that node.
|
||||
|
||||
## Drop a video onto the node
|
||||
|
||||
@@ -48,21 +44,21 @@ embedded workflow replaces the whole graph.
|
||||
|
||||
- **Source** (`video`): A file in the input folder; **Upload** adds new ones.
|
||||
A video ComfyUI made, named like `clip.mp4 [output]`, loads too.
|
||||
- **IN** (`start_seconds`): Skip everything before this time.
|
||||
- **OUT** (`end_seconds`): Stop at this time; `0` means the source end until a
|
||||
handle is moved.
|
||||
- **Every nth** (`every_nth`): Keep one frame in this many — `2` halves the frame count.
|
||||
The `fps` output divides to match, so the clip still plays at real speed
|
||||
downstream.
|
||||
- **Limit** (`max_frames`): Stop after this many kept frames; `0` loads the
|
||||
whole trim window. Caps memory on long clips — the decode ends early
|
||||
instead of loading and discarding.
|
||||
- **LOOP**: Repeat the selected window during preview. It starts on and is
|
||||
saved with the workflow.
|
||||
- **FRAME** (`single_frame`): Load only the frame at the IN time (the field
|
||||
reads **AT** while FRAME is on) as a one-image batch; `end_seconds`,
|
||||
`every_nth`, and `max_frames` are ignored while it is on.
|
||||
- **↻**: Reload the selected source preview.
|
||||
- **Start** (`start_seconds`): Skip everything before this time.
|
||||
- **Duration** (`max_frames`): How many frames the clip keeps. **Whole
|
||||
video** removes the limit, so the clip runs to the end (the widget holds
|
||||
`0`). The decode stops early, so a short clip from a long video stays
|
||||
quick.
|
||||
- **Ends at**: Where the clip stops. Typing it sets the Duration. A
|
||||
workflow saved with an end time (`end_seconds`) keeps it and runs the same.
|
||||
- **Every nth** (`every_nth`): Keep one frame in this many; `2` halves the
|
||||
frame count. The `fps` output divides to match, so the clip still plays at
|
||||
real speed downstream.
|
||||
- **LOOP**: Repeat the clip during preview. It starts on and is saved with
|
||||
the workflow.
|
||||
- **FRAME** (`single_frame`): Load only the frame at the marker as a
|
||||
one-image batch; the Duration and Every nth are ignored while it is on.
|
||||
- **↻**: Reload the source preview.
|
||||
- **Width** / **Height** (`custom_width` / `custom_height`): `0` keeps the
|
||||
source size. Set one side only and the other follows the aspect ratio,
|
||||
rounded to an even number.
|
||||
|
||||
@@ -266,6 +266,14 @@ red with advice to re-pick. Thumbnails, the info card, and range lookups
|
||||
all use the resolved name, so a moved file keeps its previews and Civitai
|
||||
data.
|
||||
|
||||
A missing LoRA is also listed in ComfyUI's own missing-models list (the
|
||||
Issues panel, and the "Download all" button) next to the other models the
|
||||
workflow needs, with a Download button when the workflow saved where the
|
||||
file comes from. Rows that are switched off, at zero strength, or whose
|
||||
file moved folders are left off that list, because the run does not need
|
||||
them or finds them anyway. Rows that come into the node over a link are
|
||||
listed by the node that sets them, not here.
|
||||
|
||||
The run side matches: a stale saved path resolves by name at load time
|
||||
(exact → unique case-insensitive path → unique basename, with a one-line
|
||||
console note when it remaps). A LoRA that is genuinely missing **stops the
|
||||
|
||||
@@ -53,15 +53,19 @@ file's name. A caption on the `caption_text` input writes the paired `.txt`.
|
||||
such as a folder of images), they all show side by side. The arrows
|
||||
beside the switch (‹ all 5 ›) go on to each one by itself (‹ 2 / 5 ›) and
|
||||
back round to all of them. A run of more than 48 shows one at a time.
|
||||
The node shows a small copy of each picture (up to 2048 pixels on the
|
||||
long side), so a big file shows at once on a slow connection too. The
|
||||
saved file is always full size. The copies are in ComfyUI's temp folder.
|
||||
- **Auto save** (`autosave`, on by default): on, every run saves its
|
||||
pictures. Off, a run only shows them here and saves nothing. A **SAVE**
|
||||
button then sits over the picture: **SAVE ALL** keeps every picture of
|
||||
the run, and with the arrows on one picture, **SAVE** keeps that one.
|
||||
pictures. Off, a run only shows them here and saves nothing. A row over
|
||||
the picture then says **Not saved yet**, with a **Save picture** button.
|
||||
With several pictures it reads **Save all 4**, and with the arrows on one
|
||||
picture, **Save this one**. After a save the row says what is saved.
|
||||
Use it to make a batch, look, and keep only the good ones. The pictures
|
||||
are saved under the name and folder set above, in the format picked,
|
||||
with the workflow inside if **Embed workflow** is on. They wait in
|
||||
ComfyUI's temp folder, which is emptied when ComfyUI restarts, so save
|
||||
what you want before that.
|
||||
what you want before that. The Save button works for the last 256 runs.
|
||||
- **Preview steps** (`step_preview`, off by default): the switch left of
|
||||
**preview** shows the picture while it is being made, one step at a time,
|
||||
where the saved image goes, with a **STOP** button on the bar. Stop a run
|
||||
|
||||
@@ -14,28 +14,43 @@ model that paints black regions.
|
||||
- **Inputs**: Pick an existing input video (the list plays the clip under the pointer, muted, and filters as you type), click **Load**, or drop a video file
|
||||
onto the node. The old source widgets remain compatible with saved workflows, but
|
||||
are now driven by this compact card. Choosing another video keeps the canvas
|
||||
settings - Fill, Feather, **Align**, Resize, Every nth, Frames for, Length - and
|
||||
settings - Fill, Feather, **Align**, Resize, Every nth, Frames for, Duration - and
|
||||
fits the new clip to the lit ratio button, the way **Fit** is set. Rotation, crop,
|
||||
padding, IN/OUT and the playhead start over.
|
||||
padding, the clip's timing and the playhead start over.
|
||||
- **Outputs** (`source_mode` / `local_path`): Pick a video from ComfyUI's output folder,
|
||||
such as one you just rendered. The list shows the newest first and previews the video
|
||||
under the pointer. The video is read in place, without an upload copy. In an API prompt
|
||||
it is named the way ComfyUI names a file there: `clip.mp4 [output]`. A whole path such
|
||||
as `/home/me/ComfyUI/output/clip.mp4` is not read, for queued runs and the editor's live
|
||||
preview alike.
|
||||
- **Play / Pause** beside the scrubber previews the selected frames and stops at OUT. Press Play at OUT to start from IN again.
|
||||
- **Timeline** (right under the preview and size line): The rail on the node and in the editor is one timeline. Press or
|
||||
drag anywhere on it to scrub the **playhead**, with Length on or off; the stage shows
|
||||
that frame. Drag the **IN** or **OUT** handle to trim: the playhead rides on the handle, so what you see
|
||||
is the first (IN) or last (OUT) frame the run keeps, and it stays there when you let
|
||||
go. IN and OUT are frames, snapped to the source's frame grid; the boxes under the
|
||||
rail take a frame number, and `start_seconds` / `end_seconds` are derived from them
|
||||
(OUT is exclusive, 0 means the end of the source). Arrow keys on a handle move one
|
||||
second, Shift one frame. **OUT always sits on the last frame the run outputs**, so
|
||||
the handle and the bright bar end together; with Every nth or Frames for it steps to the
|
||||
frames the run keeps, and a dim tail marks frames the window holds but the run
|
||||
drops. In the editor, **Set IN** / **Set OUT** (or the **I** / **O** keys) put a
|
||||
trim point at the playhead, and **Full clip** resets the window. The editor also
|
||||
- **Play / Pause** beside the timeline plays the clip from its start and stops at its end. Pause and Play again to carry on from where you stopped.
|
||||
- **Timeline** (right under the picture): Press or drag anywhere on it to look at
|
||||
another frame; the picture shows it. Point at the bar to see where you are, the
|
||||
clip in words and the source's frame rate. Drag the **start** handle to move the
|
||||
clip (its Duration stays), and the **end** handle to change the Duration. The
|
||||
start stops where the whole Duration still fits, and a short note says so.
|
||||
**Use as start** starts the clip at the frame on the picture.
|
||||
- **Start / Duration / Ends at**: the clip in three boxes. Start and Ends at are
|
||||
places in the source video; Duration is how long the clip is. Type any of them,
|
||||
or drag over a box to scrub it. The small **s | fr** switch shows them in seconds
|
||||
or frames: Start and Ends at count source frames, Duration counts the frames the
|
||||
clip sends on, at the output rate. Point at a box for the other unit and what it
|
||||
covers. Typing a Start that leaves too little video is allowed: an amber note says
|
||||
how many frames still fit and offers to shorten the clip or move the start.
|
||||
- **Linked timing**: when another node feeds `start_frame`, `end_frame`,
|
||||
`frame_load_cap` or `fixed_frames`, that box is locked and its label shows a small
|
||||
**linked** button that jumps to the node. `fixed_frames` is an exact count;
|
||||
`frame_load_cap` is only a limit, so when the video ends first the note says how
|
||||
many frames you get. A count only worked out when the graph runs (a Math
|
||||
Expression, say) shows as **at run time**, and the timeline shows striped room
|
||||
after the start instead of a clip. A rate typed inside a subgraph counts as known.
|
||||
- **Technical details**: `start_seconds` / `end_seconds` are derived from the frames
|
||||
(the end is exclusive, 0 means the end of the source), and the Duration is stored
|
||||
as `max_frames`. Arrow keys on a handle move one second, Shift one frame. With
|
||||
Every nth or Frames for the end steps to the frames the run keeps, and a dim tail
|
||||
marks frames the window holds but the run drops.
|
||||
In the editor, **Set IN** / **Set OUT** (or the **I** / **O** keys) put a
|
||||
trim point at the playhead, and **Whole video** resets the clip. The editor also
|
||||
has buttons for the first and last frame, steps of 1, 25, 50 and 100 frames, and
|
||||
**Play**. Arrow keys step one frame (10 with Shift), Home and End jump to the
|
||||
ends, and Space plays or pauses. **Save & close** keeps your edits; **Cancel** or
|
||||
@@ -55,22 +70,16 @@ model that paints black regions.
|
||||
fill colour with a faint hatch, so black bands show on the black stage. A fresh clip node starts
|
||||
with black and feather 0 and the editor's **Reset transform** returns to them;
|
||||
the image nodes keep their grey fill and feathered mask.
|
||||
- **Length** (`max_frames`): the one other way to set how long the clip is. **Off**
|
||||
(the default): OUT ends the clip. **On**: a number of output frames from IN; OUT
|
||||
sits that many frames after IN and follows it when you drag IN, and dragging OUT or
|
||||
typing the number changes the Length. To move the whole clip, drag IN or the small
|
||||
grip in the middle of the kept part (the grip also slides a trimmed window with
|
||||
Length off). When the Length is the whole clip there is nowhere to move it, and the
|
||||
row says so: "= the whole clip. Shorten it to move IN." The Length stays when you
|
||||
swap the video, so a workflow built for 97 frames keeps taking 97. Turning it on or
|
||||
off never moves anything: the count becomes the OUT, or the OUT the count. If the
|
||||
source ends first, the footer says how many frames are left. **To start** moves IN
|
||||
to the start of the source.
|
||||
- **Whole video / To start** (bottom right of the timing card): **Whole video**
|
||||
uses the whole source, with no Duration limit. When the length is linked, the
|
||||
button reads **To start** and moves the start to the beginning instead. The
|
||||
Duration stays when you swap the video, so a workflow built for 97 frames keeps
|
||||
taking 97.
|
||||
- **Every nth** (`every_nth`): Thin the batch. The `fps` output divides to match
|
||||
every_nth, so the clip keeps real-time downstream; a Length counts the frames kept.
|
||||
every_nth, so the clip keeps real-time downstream; a Duration counts the frames kept.
|
||||
- **Frames for** (`frame_snap`): Keep a frame count a video model takes:
|
||||
**LTX (8n+1)** (49, 97, 121) or **Wan (4n+1)**. **any** keeps every frame in the window.
|
||||
OUT drags and the Length step through those counts.
|
||||
Dragging the end and typing a Duration step through those counts.
|
||||
With it on, `frame_count`, `duration`, the audio window and the stitcher all match the
|
||||
clip the sampler hands back, so wiring `frame_count` into the empty latent's length
|
||||
never leaves the stitch with more source frames than generated ones.
|
||||
@@ -102,7 +111,7 @@ with the padlock on it also takes away the bands the lock added.
|
||||
**Reset** on the node clears rotation, crop and padding and turns the padlock off;
|
||||
fill, feather, **Align** and the timeline stay.
|
||||
**Reset transform** in the editor resets rotation, crop, padding, fill, feather and
|
||||
**Align**; it keeps the source, current frame, trim, Length, resize and stitch
|
||||
**Align**; it keeps the source, current frame, trim, Duration, resize and stitch
|
||||
settings. **Align** makes the width and height divide evenly by the number
|
||||
you pick: padding grows by a few pixels, and a side with no padding is trimmed by
|
||||
a few instead. Some models need sizes divisible by 8, 16 or 32; 1 turns it off.
|
||||
@@ -162,8 +171,8 @@ Five optional sockets sit on the left, above the editor:
|
||||
| `force_rate` | Sample at this fps before Every nth. 0 keeps the source rate. Drops or repeats frames to keep playback speed. Accepts FLOAT or INT. |
|
||||
| `start_frame` | Zero-based source start frame. Overrides timeline IN. |
|
||||
| `end_frame` | Exclusive source end frame. 0 means the end of the source. Overrides timeline OUT. |
|
||||
| `fixed_frames` | Exact output frames from IN; the source must be long enough. Connected, it sets the length: OUT, Length and Frames for step aside. |
|
||||
| `frame_load_cap` | Maximum frames after rate conversion and Every nth, before Frames for. 0 means unlimited. Connected, it sets the length in place of Length. When the count is known, dragging IN stops at the last start that fits the kept frames. |
|
||||
| `fixed_frames` | Exact output frames from IN; the source must be long enough. Connected, it sets the length: Duration, Ends at and Frames for step aside. |
|
||||
| `frame_load_cap` | Maximum frames after rate conversion and Every nth, before Frames for. 0 means unlimited. Connected, it sets the length in place of Duration. When the count is known, dragging the start stops at the last start that fits the kept frames. |
|
||||
| `last_seconds` | Load only this many seconds from the end of the clip, or of the part before OUT. 0 loads all of it. Use it to carry on from a clip: a long clip then costs no more memory than a short one. |
|
||||
|
||||
Frame bounds use the source's frame-rate grid, independent of `force_rate`.
|
||||
@@ -177,17 +186,17 @@ For example, start 24 and end 72 select two seconds from a 24 fps source.
|
||||
A 12 fps forced rate returns 24 frames; a cap of 10 then keeps only the first
|
||||
10 of those. Audio and duration follow the returned batch.
|
||||
|
||||
A connected start or end locks that handle and its IN/OUT field on both
|
||||
A connected start or end locks that handle and its box on both
|
||||
the node and fullscreen editor. Hover to see why. Disconnect to restore
|
||||
local control. While timing inputs are connected, the preview shows the local
|
||||
trim as a reference and avoids claiming an output count before the linked
|
||||
values are evaluated at run time.
|
||||
|
||||
**A connected length input takes over the length.** Connect a count to
|
||||
`fixed_frames` (exact) or `frame_load_cap` (at most) and the OUT handle goes
|
||||
away, OUT and Length grey out, and only IN is left to set: the clip starts at
|
||||
IN and the input decides where it ends. Literal Integer/Float nodes (including
|
||||
`fixed_frames` (exact) or `frame_load_cap` (at most) and the end handle goes
|
||||
away, Duration and Ends at lock, and only Start is left to set: the clip starts
|
||||
there and the input decides where it ends. Literal Integer/Float nodes (including
|
||||
AusBoss cards and reroutes) show the resulting frames on the rail before
|
||||
running; calculated counts show "at run time". An older workflow that saved a
|
||||
Fixed frames number without a connection reads as a Length; the first change
|
||||
Fixed frames number without a connection reads as a Duration; the first change
|
||||
here turns it into one.
|
||||
|
||||
@@ -60,10 +60,12 @@ answered on the same line as the button.
|
||||
- A found file swaps its Download button for an **✓ installed** pill; hovering
|
||||
the pill shows where it was found. A file that lives in a subfolder still
|
||||
counts. When a loader in the workflow still asks for the bare file name,
|
||||
which ComfyUI cannot find there (it marks that loader red), the row says
|
||||
where the file is instead (**in LTXV 2.3/**) and **Use it** points those
|
||||
loaders at the copy it found. The check only asks the ComfyUI server for its
|
||||
own model lists.
|
||||
which ComfyUI cannot find there (it marks that loader red), the note points
|
||||
that loader at your copy by itself and says so in a short message. If you
|
||||
have two copies in different subfolders, the row says where one is
|
||||
(**in LTXV 2.3/**) and **Use it** picks it. To always choose yourself, turn
|
||||
off Settings, 🆎 AusBoss, Models, **Pick found files**. The check only asks
|
||||
the ComfyUI server for its own model lists.
|
||||
- **↻ check files** re-runs the check after you move files in. ComfyUI's own
|
||||
**R** refresh triggers it as well.
|
||||
- Folder `input` is for a sample image or clip shipped with the workflow: it
|
||||
|
||||
@@ -17,6 +17,7 @@ help panel.
|
||||
| Pick a picture size by shape and megapixels, in place of Empty Latent | Latent Size (`AUSBOSS_NODES_Resolution`) |
|
||||
| Resize a picture, or snap its size to a multiple | Image Resize (`AUSBOSS_NODES_ImageResize`), Align Image (`AUSBOSS_NODES_AlignImage`) |
|
||||
| Read a picture's width and height | Image Size (`AUSBOSS_NODES_ImageSize`) |
|
||||
| Load a picture and set its size or crop it (megapixels, longest side, a box, a ratio) in one node | Load Image (`AUSBOSS_NODES_LoadImage`) |
|
||||
| Outpaint: load a picture and add empty space around it | Load Image + Pad (`AUSBOSS_NODES_LoadImagePad`) |
|
||||
| Turn, crop and pad a picture in one node | Image Crop + Rotate + Pad (`AUSBOSS_NODES_ImageCropRotatePad`) |
|
||||
| Inpaint only the masked part, then put it back | Crop For Inpaint (`AUSBOSS_NODES_CropForInpaint`) then Stitch Inpaint (`AUSBOSS_NODES_StitchInpaint`) |
|
||||
|
||||
+122
-25
@@ -14,7 +14,7 @@
|
||||
// switch lays each sampling step over the stage, with a Stop button on the
|
||||
// bar (shared/step_preview.mjs).
|
||||
|
||||
import { panelSwitch } from "../shared/panel_controls.mjs";
|
||||
import { panelSwitch, primaryAction } from "../shared/panel_controls.mjs";
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { isForeignRun } from "../shared/prompt_scope.mjs";
|
||||
@@ -26,14 +26,16 @@ import { suppressCoreImagePreview } from "../shared/core_preview.mjs";
|
||||
import { autoMaskValues } from "../shared/mask_auto.mjs";
|
||||
import { hideInputsInDef, hideWidget, setWidgetVisible } from "../shared/widget_visibility.mjs";
|
||||
import { makePictureStepper } from "../shared/picture_stepper.mjs";
|
||||
import { ALL, allLabel, gridShape, heldPlaces, keepIndex, stepIndex, stepWithAll } from "../shared/picture_steps.mjs";
|
||||
import { ALL, allLabel, gridShape, heldPlaces, keepIndex, keepWords, stepIndex, stepWithAll } from "../shared/picture_steps.mjs";
|
||||
import { addStepConsumer, mountStepOverlay, showsStepsOn, stepRun, stopStepRun, watchSteps } from "../shared/step_preview.mjs";
|
||||
import {
|
||||
describeNodePreview,
|
||||
describeSourcePreview,
|
||||
lightPreviewQuery,
|
||||
outputLocatorId,
|
||||
outputRecordCount,
|
||||
outputRecordQuery,
|
||||
ownResultIsCurrent,
|
||||
placeholderText,
|
||||
staleText,
|
||||
sourceFileWidget,
|
||||
@@ -54,6 +56,9 @@ const BAR_GAP = 6;
|
||||
const BAR_PADDING = 2;
|
||||
const PANEL_HEIGHT = STAGE_HEIGHT + BAR_HEIGHT + 4 + 16;
|
||||
const OFF_HEIGHT = BAR_HEIGHT + 16;
|
||||
// The row over pictures that wait for a Save, and the gap under it.
|
||||
const KEEP_HEIGHT = 30;
|
||||
const KEEP_SPACE = KEEP_HEIGHT + 4;
|
||||
const INPUT_SIDE = 1; // LiteGraph.INPUT
|
||||
// A run that left this many pictures or fewer opens with all of them side
|
||||
// by side. More than that and each would be a speck, so the arrows go
|
||||
@@ -126,9 +131,9 @@ const NODE_CONFIG = {
|
||||
noun: "an image",
|
||||
switchTitle: "Show the saved image here. The file is saved either way.",
|
||||
steps: true,
|
||||
tools: [
|
||||
{ label: "SAVE", title: "Save what is showing: every picture, or the one the arrows picked.", action: keepHeld, held: true },
|
||||
],
|
||||
// Auto save off: a row over the picture says it is not saved yet and
|
||||
// holds the button that saves it.
|
||||
keep: "Save what is showing: every picture, or the one the arrows picked.",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -152,16 +157,21 @@ function ensureCss() {
|
||||
.ausboss-input-preview.preview-off .ausboss-stepper{display:none;}
|
||||
.ausboss-input-preview-stage img,.ausboss-input-preview-stage video{display:none;position:absolute;inset:0;margin:auto;max-width:100%;max-height:100%;object-fit:contain;}
|
||||
.ausboss-input-preview-stage.show-image img{display:block;}
|
||||
.ausboss-input-preview-stage.loading-image img{opacity:.4;transition:opacity .3s ease 1.2s;}
|
||||
.ausboss-input-preview-stage.show-video video{display:block;}
|
||||
.ausboss-input-preview-grid{display:none;position:absolute;inset:0;box-sizing:border-box;gap:${GRID_GAP}px;padding:${GRID_GAP}px;justify-content:center;align-content:center;}
|
||||
.ausboss-input-preview-stage.show-grid .ausboss-input-preview-grid{display:grid;}
|
||||
.ausboss-input-preview-stage .ausboss-input-preview-grid img{display:block;position:static;margin:0;width:100%;height:100%;min-width:0;min-height:0;max-width:none;max-height:none;object-fit:contain;}
|
||||
.ausboss-input-preview-hint{display:none;max-width:86%;color:${T.faint};font:11px/1.35 ${FONT_UI};text-align:center;}
|
||||
.ausboss-input-preview-stage:not(.show-image):not(.show-video):not(.show-grid) .ausboss-input-preview-hint{display:block;}
|
||||
.ausboss-input-preview-keep{box-sizing:border-box;flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;height:${KEEP_HEIGHT}px;padding:0 4px 0 10px;border-radius:${RADIUS_CONTROL}px;background:${T.brandSoft};pointer-events:none;}
|
||||
.ausboss-input-preview-keep[hidden]{display:none;}
|
||||
.ausboss-input-preview-keep span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:${T.brandInk};font:600 11px/1.2 ${FONT_UI};}
|
||||
.ausboss-input-preview-keep.done{background:${T.fill};}
|
||||
.ausboss-input-preview-keep.done span{color:${T.label};}
|
||||
.ausboss-input-preview-tools{display:flex;gap:4px;pointer-events:auto;}
|
||||
.ausboss-input-preview-tool{box-sizing:border-box;height:${BAR_HEIGHT}px;min-width:24px;padding:0 6px;border:1px solid transparent;border-radius:${RADIUS_XS}px;background:${T.fill};color:${T.label};font:600 9.5px/18px ${FONT_UI};letter-spacing:.02em;cursor:pointer;}
|
||||
.ausboss-input-preview-tool[hidden]{display:none;}
|
||||
.ausboss-input-preview-tool.keep{color:${T.brandInk};background:${T.brandSoft};}
|
||||
.ausboss-input-preview-stage .ausboss-input-preview-grid img.kept{outline:2px solid ${T.brand};outline-offset:-2px;}
|
||||
.ausboss-input-preview-tool:hover{color:${T.ink};background:${T.fillHover};}
|
||||
.ausboss-input-preview-tool.active{color:${T.brandInk};background:${T.brandSoft};}
|
||||
@@ -472,7 +482,7 @@ function syncPreviewMode(state, resize) {
|
||||
if (resize) {
|
||||
const node = state.node;
|
||||
node.properties ??= {};
|
||||
const floor = node.computeSize?.()[1] ?? (enabled ? PANEL_HEIGHT : OFF_HEIGHT);
|
||||
const floor = node.computeSize?.()[1] ?? panelFloor(state);
|
||||
if (!enabled) {
|
||||
// Off: remember the height, then shrink to what is left.
|
||||
const height = Number(node.size?.[1]);
|
||||
@@ -509,7 +519,6 @@ function buildTools(state, tools, signal) {
|
||||
tool.action(state);
|
||||
}, { signal });
|
||||
state.toolButtons[tool.label] = button;
|
||||
if (tool.held) { button.hidden = true; state.keepButton = button; }
|
||||
bar.append(button);
|
||||
}
|
||||
return bar;
|
||||
@@ -538,6 +547,7 @@ function showMedia(state, kind) {
|
||||
|
||||
function clearMedia(state) {
|
||||
state.img.removeAttribute("src");
|
||||
state.stage.classList.remove("loading-image");
|
||||
state.video.pause?.();
|
||||
state.video.removeAttribute("src");
|
||||
clearGrid(state);
|
||||
@@ -578,6 +588,7 @@ function showGrid(state, count) {
|
||||
cell.decoding = "async";
|
||||
// The first picture to load tells the grid the shape to lay out for.
|
||||
cell.addEventListener("load", () => layoutGrid(state), { once: true });
|
||||
cell.addEventListener("error", () => dropLightPreview(state), { once: true });
|
||||
cell.src = url;
|
||||
return cell;
|
||||
}));
|
||||
@@ -630,12 +641,30 @@ function rewatchSource(state, source) {
|
||||
// record: an overwritten file reloads after the next run, and a plain refresh
|
||||
// never reloads the picture.
|
||||
const storedRand = new WeakMap();
|
||||
const outputRecord = (node) => app.nodeOutputs?.[outputLocatorId(node)];
|
||||
// Save Image also writes a small copy of each picture for its face, and the
|
||||
// panel shows that one: a few hundred kilobytes where the file can be tens
|
||||
// of megabytes. The copies are in the temp folder, which ComfyUI empties
|
||||
// when it starts; a record whose copy is gone goes back to the file itself.
|
||||
const lightGone = new WeakSet();
|
||||
function lightQuery(record, index = null) {
|
||||
return record && !lightGone.has(record) ? lightPreviewQuery(record, index) : null;
|
||||
}
|
||||
function storedResultUrl(node, index = null) {
|
||||
const record = app.nodeOutputs?.[outputLocatorId(node)];
|
||||
const query = outputRecordQuery(record, index);
|
||||
const record = outputRecord(node);
|
||||
const light = lightQuery(record, index);
|
||||
const query = light ?? outputRecordQuery(record, index);
|
||||
if (!query) return null;
|
||||
if (!storedRand.has(record)) storedRand.set(record, app.getRandParam?.() ?? "");
|
||||
return api.apiURL(`/view?${query}${app.getPreviewFormatParam?.() ?? ""}${storedRand.get(record)}`);
|
||||
return api.apiURL(`/view?${query}${light ? "" : app.getPreviewFormatParam?.() ?? ""}${storedRand.get(record)}`);
|
||||
}
|
||||
// A small copy that would not load: show the file itself from now on.
|
||||
function dropLightPreview(state) {
|
||||
const record = outputRecord(state.node);
|
||||
if (!lightQuery(record)) return false;
|
||||
lightGone.add(record);
|
||||
scheduleRefresh(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Several pictures from one run (a list, or a batch Save Image saved one by
|
||||
@@ -679,23 +708,66 @@ function keepsAll(state, count) {
|
||||
return count < 2 || showsAll(state, count) || !previewEnabled(state);
|
||||
}
|
||||
|
||||
// The button says what a click will do: SAVE ALL over the grid, SAVE over
|
||||
// one picture, SAVED once there is nothing left to keep there.
|
||||
// The row shows while the node holds pictures. It says what is saved, and
|
||||
// its button what a click will do (keepWords).
|
||||
function syncHeld(state, count = resultCount(state)) {
|
||||
const button = state.keepButton;
|
||||
if (!button) return;
|
||||
const row = state.keepRow;
|
||||
if (!row) return;
|
||||
const held = heldPictures(state);
|
||||
button.hidden = !held.length || count < 1;
|
||||
if (button.hidden) return;
|
||||
const hidden = !held.length || count < 1;
|
||||
if (row.hidden !== hidden) {
|
||||
row.hidden = hidden;
|
||||
fitKeepRow(state);
|
||||
}
|
||||
if (hidden) return;
|
||||
const kept = keptOf(state, held);
|
||||
const all = keepsAll(state, count);
|
||||
const done = all ? kept.size >= held.length : kept.has(state.index);
|
||||
button.textContent = state.keeping ? "SAVING" : done ? "SAVED" : all && count > 1 ? "SAVE ALL" : "SAVE";
|
||||
button.classList.toggle("keep", !done);
|
||||
button.disabled = Boolean(state.keeping);
|
||||
const words = keepWords({
|
||||
held: held.length, kept: kept.size, all, done, saving: Boolean(state.keeping), name: state.kept?.name ?? "",
|
||||
});
|
||||
state.keepNote.textContent = words.note;
|
||||
state.keepNote.title = state.kept?.path ? `ComfyUI/output/${state.kept.path}` : "";
|
||||
state.keepButton.textContent = words.button;
|
||||
state.keepButton.classList.toggle("quiet", words.quiet);
|
||||
state.keepButton.disabled = Boolean(state.keeping);
|
||||
row.classList.toggle("done", words.quiet && kept.size >= held.length);
|
||||
[...(state.grid?.children ?? [])].forEach((cell, index) => cell.classList.toggle("kept", kept.has(index)));
|
||||
}
|
||||
|
||||
// The row takes room of its own, so the picture keeps its floor: the node
|
||||
// grows to hold it, and a node with the preview off gives the room back.
|
||||
function fitKeepRow(state) {
|
||||
const node = state.node;
|
||||
if (previewEnabled(state)) {
|
||||
ensureNodeMinHeight(node);
|
||||
} else {
|
||||
const floor = Number(node.computeSize?.()?.[1]);
|
||||
if (Number.isFinite(floor)) node.setSize?.([node.size?.[0] ?? PANEL_MIN_WIDTH, floor]);
|
||||
}
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
function buildKeepRow(state, title, signal) {
|
||||
const row = document.createElement("div");
|
||||
row.className = "ausboss-input-preview-keep";
|
||||
row.hidden = true;
|
||||
const note = document.createElement("span");
|
||||
const button = primaryAction("Save picture", title);
|
||||
// Stop the graph from seeing the click as a canvas drag on the node.
|
||||
button.addEventListener("pointerdown", (event) => event.stopPropagation(), { signal });
|
||||
button.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
keepHeld(state);
|
||||
}, { signal });
|
||||
row.append(note, button);
|
||||
state.keepRow = row;
|
||||
state.keepNote = note;
|
||||
state.keepButton = button;
|
||||
return row;
|
||||
}
|
||||
|
||||
async function keepHeld(state) {
|
||||
const held = heldPictures(state);
|
||||
if (!held.length || state.keeping) return;
|
||||
@@ -729,6 +801,12 @@ async function keepHeld(state) {
|
||||
if (picture.token === token && done.has(picture.index)) kept.add(place);
|
||||
});
|
||||
saved.push(...(answer.saved ?? []));
|
||||
// One picture: the row says the name it was saved under.
|
||||
const path = held.length === 1 ? answer.saved?.[0]?.path : null;
|
||||
if (typeof path === "string" && path && state.kept) {
|
||||
state.kept.path = path;
|
||||
state.kept.name = path.slice(path.lastIndexOf("/") + 1);
|
||||
}
|
||||
skipped += answer.skipped?.length ?? 0;
|
||||
}
|
||||
toast(state, saved.length === 1
|
||||
@@ -798,7 +876,9 @@ function refresh(state) {
|
||||
? describeSourcePreview(source)
|
||||
: count > 1
|
||||
? { kind: "url", url: storedResultUrl(state.node, state.index) }
|
||||
: describeNodePreview(state.node, state.inputName, storedResultUrl(state.node));
|
||||
: describeNodePreview(state.node, state.inputName, storedResultUrl(state.node),
|
||||
// The small copy goes first: node.imgs is the full file.
|
||||
!lightQuery(outputRecord(state.node)) && ownResultIsCurrent(state.node, outputRecord(state.node), state.imgsFor));
|
||||
if (!described) {
|
||||
clearMedia(state);
|
||||
showPlaceholder(state, !!source);
|
||||
@@ -820,6 +900,9 @@ function refresh(state) {
|
||||
state.video.removeAttribute("src");
|
||||
if (state.img.getAttribute("src") !== url) {
|
||||
state.img.src = url;
|
||||
// The picture before stays up while this one loads. A slow load
|
||||
// dims it, so an old picture is never taken for the new one.
|
||||
state.stage.classList.toggle("loading-image", true);
|
||||
} else if (state.img.complete && state.img.naturalWidth > 0) {
|
||||
showMedia(state, "image");
|
||||
}
|
||||
@@ -842,8 +925,19 @@ function scheduleRefresh(state) {
|
||||
// Watching the property rather than an api event catches both routes that set
|
||||
// it - the progress frames streamed during a run and the ui payload delivered
|
||||
// when the node finishes - without this file having to know either event name.
|
||||
// The panel's floor: the bar and the picture, the bar alone with the
|
||||
// preview off, and the Save row on top while it shows.
|
||||
function panelFloor(state, enabled = state ? previewEnabled(state) : true) {
|
||||
const keep = state?.keepRow && !state.keepRow.hidden ? KEEP_SPACE : 0;
|
||||
return (enabled ? PANEL_HEIGHT : OFF_HEIGHT) + keep;
|
||||
}
|
||||
|
||||
function watchOwnResult(node, state) {
|
||||
let images = node.imgs;
|
||||
// Which output the pictures in node.imgs were loaded for. The frontend
|
||||
// gives up on a picture that loads slowly and keeps the run before, so
|
||||
// the panel checks this before it trusts node.imgs (ownResultIsCurrent).
|
||||
state.imgsFor = outputRecord(node);
|
||||
try {
|
||||
Object.defineProperty(node, "imgs", {
|
||||
configurable: true,
|
||||
@@ -851,6 +945,7 @@ function watchOwnResult(node, state) {
|
||||
get: () => images,
|
||||
set: (value) => {
|
||||
images = value;
|
||||
state.imgsFor = outputRecord(node);
|
||||
if (state.alive) scheduleRefresh(state);
|
||||
},
|
||||
});
|
||||
@@ -891,7 +986,7 @@ function buildPanel(node, config) {
|
||||
const widget = node.addDOMWidget(WIDGET_NAME, "ausboss_input_preview", root, {
|
||||
serialize: false,
|
||||
hideOnZoom: false,
|
||||
getMinHeight: () => (enabled() ? PANEL_HEIGHT : OFF_HEIGHT),
|
||||
getMinHeight: () => panelFloor(node.__ausbossInputPreview, enabled()),
|
||||
});
|
||||
keepDomWidgetWidthAuto(widget);
|
||||
// Not saved with the workflow either: options.serialize only keeps it out
|
||||
@@ -903,7 +998,7 @@ function buildPanel(node, config) {
|
||||
// dragged taller. With the preview off the floor is the bar alone.
|
||||
fillNodeHeight(widget, {
|
||||
minWidth: () => previewMinWidth(node.__ausbossInputPreview),
|
||||
minHeight: () => (enabled() ? PANEL_HEIGHT : OFF_HEIGHT),
|
||||
minHeight: () => panelFloor(node.__ausbossInputPreview, enabled()),
|
||||
minNodeSize: [PANEL_MIN_WIDTH, 90],
|
||||
exactMinWidth: true,
|
||||
});
|
||||
@@ -934,6 +1029,7 @@ function buildPanel(node, config) {
|
||||
};
|
||||
livePanels.add(state);
|
||||
if (config.tools?.length) bar.append(buildTools(state, config.tools, abort.signal));
|
||||
if (config.keep) bar.after(buildKeepRow(state, config.keep, abort.signal));
|
||||
if (config.readout) {
|
||||
state.readout = document.createElement("span");
|
||||
state.readout.className = "ausboss-input-preview-readout";
|
||||
@@ -958,9 +1054,10 @@ function buildPanel(node, config) {
|
||||
watcher.observe(stage);
|
||||
abort.signal.addEventListener("abort", () => watcher.disconnect(), { once: true });
|
||||
}
|
||||
img.addEventListener("load", () => showMedia(state, "image"));
|
||||
img.addEventListener("load", () => { stage.classList.remove("loading-image"); showMedia(state, "image"); });
|
||||
img.addEventListener("error", () => {
|
||||
if (img.getAttribute("src")) showPlaceholder(state, true);
|
||||
stage.classList.remove("loading-image");
|
||||
if (img.getAttribute("src") && !dropLightPreview(state)) showPlaceholder(state, true);
|
||||
});
|
||||
video.addEventListener("loadeddata", () => showMedia(state, "video"));
|
||||
video.addEventListener("error", () => {
|
||||
|
||||
@@ -20,21 +20,36 @@ export function outputWindow(durationValue, startValue, endValue, maxValue = 0)
|
||||
return { start, end, keepEnd, length: keepEnd - start, cut: Math.max(0, end - keepEnd) };
|
||||
}
|
||||
|
||||
// "0:12.0" style, the way the IN and OUT fields write a time.
|
||||
export function secondsLabel(value) {
|
||||
const seconds = Math.max(0, finite(value));
|
||||
if (seconds < 60) return `${seconds.toFixed(1)} s`;
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
return `${minutes}:${(seconds - minutes * 60).toFixed(1).padStart(4, "0")}`;
|
||||
const hundredth = (value) => Math.round(value * 100) / 100;
|
||||
|
||||
// What the face stores for a pick from `start` to `end`: a Start and a
|
||||
// Duration (max_seconds, with end_seconds at 0, "to the end"). A pick that
|
||||
// reaches the end of the file needs no Duration. When another node sets the
|
||||
// Duration or the end, the pick is stored as a start and an end instead.
|
||||
// A key left out is not written.
|
||||
export function pickWrites(durationValue, startValue, endValue, { maxLinked = false, endLinked = false } = {}) {
|
||||
const duration = Math.max(0, finite(durationValue));
|
||||
const start = hundredth(Math.min(Math.max(0, finite(startValue)), duration));
|
||||
const end = hundredth(Math.max(start, Math.min(finite(endValue), duration)));
|
||||
const toEnd = end >= duration - 0.005;
|
||||
if (endLinked) return { start };
|
||||
if (maxLinked) return { start, end: toEnd ? 0 : end };
|
||||
return { start, end: 0, max: toEnd ? 0 : Math.max(0.01, hundredth(end - start)) };
|
||||
}
|
||||
|
||||
// The line between IN and OUT: what comes out, and what the max cuts off.
|
||||
export function outputSummary(window, { maxFromLink = false } = {}) {
|
||||
if (!window || window.length <= 0) return "";
|
||||
const parts = [secondsLabel(window.length)];
|
||||
if (window.cut > 0.005) parts.push(`cut ${secondsLabel(window.cut)}`);
|
||||
if (maxFromLink) parts.push("max wired");
|
||||
return parts.join(" · ");
|
||||
// A value typed into Start, Duration or Ends at, as the pick it makes.
|
||||
// Start keeps the Duration; Duration and Ends at keep the start. An empty
|
||||
// or 0 Duration, and an empty Ends at, run to the end of the file.
|
||||
export function typedPick(key, value, window, durationValue, minimum = 0.1) {
|
||||
const duration = Math.max(0, finite(durationValue));
|
||||
const clampTime = (time) => Math.min(duration, Math.max(0, finite(time)));
|
||||
if (key === "start") {
|
||||
const start = clampTime(value);
|
||||
return { start, end: Math.min(duration, start + window.length) };
|
||||
}
|
||||
if (value == null || (key === "duration" && !(finite(value) > 0))) return { start: window.start, end: duration };
|
||||
const end = key === "duration" ? window.start + Math.max(minimum, finite(value)) : Math.max(window.start + minimum, finite(value));
|
||||
return { start: window.start, end: clampTime(end) };
|
||||
}
|
||||
|
||||
// Loud and quiet across the file: for each of `buckets` slices, the lowest
|
||||
|
||||
+118
-110
@@ -1,30 +1,35 @@
|
||||
// Load Audio 🆎 - the wave, the trim and the player.
|
||||
// Load Audio 🆎 - the wave, the timing and the player.
|
||||
//
|
||||
// The card above (js/widget_cards) holds Source and Max length. This panel
|
||||
// draws the whole file as a wave: the part that comes out is bright, the
|
||||
// part a Max length cuts off is red, and the rest is dim. Drag a handle to
|
||||
// move IN or OUT, drag the middle to slide the pick, or click elsewhere to
|
||||
// move it there. Play plays only what comes out. The widgets underneath
|
||||
// (start_seconds, end_seconds, max_seconds) stay the source of truth.
|
||||
// The card above (js/widget_cards) holds Source. This panel draws the whole
|
||||
// file as a wave: the part that comes out is bright and the rest is dim.
|
||||
// Under it, Start, Duration and Ends at, as on the video nodes. Drag a
|
||||
// handle on the wave to move the start or the end, drag the middle to slide
|
||||
// the sound, or click elsewhere to move it there. Play plays only what comes
|
||||
// out. The widgets underneath stay the source of truth: the Duration is
|
||||
// max_seconds with end_seconds at 0. A saved end (or a linked Max length)
|
||||
// still works: the part a Max length cuts off shows red.
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { BRAND, chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange, showToast } from "../shared/index.mjs";
|
||||
import { keepKeyInField } from "../shared/canvas_passthrough.mjs";
|
||||
import { WIDGET_FRAME, fillNodeHeight } from "../shared/panel_layout.mjs";
|
||||
import { formatTimecode, parseTimecode } from "../shared/timecode.mjs";
|
||||
import { formatTimecode } from "../shared/timecode.mjs";
|
||||
import { inputNumber } from "../shared/clip_rate.mjs";
|
||||
import { makeScrubInput } from "../shared/scrub_input.mjs";
|
||||
import { linkedNodeInfo } from "../shared/timing_links.mjs";
|
||||
import { parseImageReference } from "../shared/pad_canvas.mjs";
|
||||
import { mediaViewQuery, splitMediaName } from "../shared/video_preview.mjs";
|
||||
import { ensureVideoCss, hideCanvasWidget, makeToolButton } from "../shared/video_ui.mjs";
|
||||
import { MIN_TRIM_SECONDS, dragTrimHandle, slideTrimWindow } from "../load_video/trim_preview.mjs";
|
||||
import { grabZone, outputSummary, outputWindow, secondsLabel, wavePeaks } from "./audio_window.mjs";
|
||||
import { grabZone, outputWindow, pickWrites, typedPick, wavePeaks } from "./audio_window.mjs";
|
||||
|
||||
const NODE_NAME = "AUSBOSS_NODES_LoadAudio";
|
||||
const PANEL_WIDGET = "ausboss_load_audio_wave";
|
||||
// The frontend's own player for an audio_upload input. The wave replaces it.
|
||||
const CORE_AUDIO_WIDGET = "audioUI";
|
||||
const MIN_WIDTH = 280;
|
||||
// 8px root padding + the wave's 28px floor + 6px gap + the 22px play, IN/OUT and loop row.
|
||||
const PANEL_MIN_HEIGHT = 64;
|
||||
// 8px root padding + the wave's 28px floor + 6px gap + the 38px Start,
|
||||
// Duration and Ends at row (a label over a box).
|
||||
const PANEL_MIN_HEIGHT = 80;
|
||||
// Opens small and neat: 300 px wide, with a wave about as tall as a field
|
||||
// (32 px). Drag the corner down for a taller wave.
|
||||
const DEFAULT_WIDTH = 300;
|
||||
@@ -50,26 +55,32 @@ function hideCoreAudio(node) {
|
||||
}
|
||||
}
|
||||
|
||||
// A wired Max length: the number the wire carries, when the far end is a
|
||||
// node that shows it (Float, Integer, a Primitive). null when it can't be known.
|
||||
function wiredMax(node) {
|
||||
const input = node.inputs?.find((slot) => slot?.widget?.name === "max_seconds");
|
||||
if (!input || input.link == null) return { wired: false, value: null };
|
||||
const graph = node.graph;
|
||||
const link = graph?.getLink?.(input.link) ?? graph?.links?.get?.(input.link) ?? graph?.links?.[input.link];
|
||||
const origin = link ? graph?.getNodeById?.(link.origin_id) : null;
|
||||
const shown = origin?.widgets?.find((widget) => typeof widget?.value === "number");
|
||||
return { wired: true, value: shown ? Number(shown.value) : null };
|
||||
function linked(node, name) {
|
||||
return !!node.inputs?.some((slot) => slot?.widget?.name === name && slot.link != null);
|
||||
}
|
||||
|
||||
// A value as the run will see it: the widget, or the number a linked input
|
||||
// carries when the far end is a typed number (through Reroutes and
|
||||
// subgraphs). null when only the run knows it.
|
||||
function valueOf(state, name, widget) {
|
||||
if (!linked(state.node, name)) return Number(widget?.value) || 0;
|
||||
return inputNumber(state.node, name, null);
|
||||
}
|
||||
|
||||
function maxSeconds(state) {
|
||||
const wired = wiredMax(state.node);
|
||||
if (wired.wired) return { value: wired.value ?? 0, fromLink: true, known: wired.value != null };
|
||||
return { value: Number(state.maxWidget?.value) || 0, fromLink: false, known: true };
|
||||
const fromLink = linked(state.node, "max_seconds");
|
||||
const value = valueOf(state, "max_seconds", state.maxWidget);
|
||||
return { value: value ?? 0, fromLink, known: value != null };
|
||||
}
|
||||
|
||||
function currentWindow(state) {
|
||||
return outputWindow(state.duration, state.startWidget.value, state.endWidget.value, maxSeconds(state).value);
|
||||
const start = valueOf(state, "start_seconds", state.startWidget) ?? 0;
|
||||
const max = maxSeconds(state).value;
|
||||
let end = valueOf(state, "end_seconds", state.endWidget) ?? 0;
|
||||
// No end and a Duration: the Duration is where the sound stops, so
|
||||
// nothing past it shows as cut off. Only an end past the Duration does.
|
||||
if (!(end > 0) && max > 0 && state.duration > 0) end = Math.min(state.duration, Math.max(0, start) + max);
|
||||
return outputWindow(state.duration, start, end, max);
|
||||
}
|
||||
|
||||
async function loadPeaks(name, route) {
|
||||
@@ -105,16 +116,15 @@ function ensureAudioCss() {
|
||||
.ausboss-audio-error{pointer-events:auto;border:0;background:transparent;color:#e6bf87;font:11px system-ui;cursor:pointer;white-space:nowrap}
|
||||
.ausboss-audio-root canvas.ausboss-audio-wave{position:absolute;inset:0;width:100%;height:100%;display:block;}
|
||||
.ausboss-audio-root .ausboss-video-stage:not(.is-empty) .ausboss-video-status{display:none;}
|
||||
.ausboss-audio-root .ausboss-audio-row{display:flex;align-items:center;gap:6px;flex:none;padding:0 2px;}
|
||||
.ausboss-audio-root .ausboss-audio-row .ausboss-video-values{flex:1 1 auto;min-width:0;}
|
||||
.ausboss-audio-root .ausboss-audio-play{min-width:30px;font-size:10px;}
|
||||
.ausboss-audio-root .ausboss-audio-length{flex:none;padding:0 2px;color:#7fd9d2;font-size:10px;font-variant-numeric:tabular-nums;white-space:nowrap;cursor:default;}
|
||||
.ausboss-audio-root .ausboss-audio-length:empty{display:none;}
|
||||
.ausboss-audio-root .ausboss-audio-length.has-cut{color:#ff9aa0;cursor:pointer;text-decoration:underline dotted rgba(224,82,90,.8);text-underline-offset:2px;}
|
||||
.ausboss-audio-root .ausboss-audio-row .ausboss-video-tool{flex:none;}
|
||||
.ausboss-audio-root .ausboss-video-values{display:flex;gap:8px;}
|
||||
.ausboss-audio-root .ausboss-video-value input{width:48px;}
|
||||
.ausboss-audio-root .ausboss-audio-length{margin-left:auto;}
|
||||
.ausboss-audio-root .ausboss-audio-wave-row{display:flex;align-items:stretch;gap:6px;flex:1 1 auto;min-height:28px;}
|
||||
.ausboss-audio-root .ausboss-audio-wave-row .ausboss-video-stage{flex:1 1 auto;min-width:0;}
|
||||
.ausboss-audio-root .ausboss-audio-play{flex:none;align-self:center;min-width:30px;font-size:10px;}
|
||||
.ausboss-audio-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;flex:none;padding:0 2px;color:#ddd;font:11px system-ui;}
|
||||
.ausboss-audio-field{display:flex;flex-direction:column;gap:2px;min-width:0;}
|
||||
.ausboss-audio-field .ausboss-scrub{width:100%;box-sizing:border-box;}
|
||||
.ausboss-audio-field-label{display:flex;align-items:center;gap:6px;min-width:0;color:#cadddb;}
|
||||
.ausboss-audio-go{border:0;background:transparent;padding:0;color:#45d6cb;font:600 10px system-ui;text-decoration:underline;cursor:pointer;}
|
||||
.ausboss-audio-go[hidden]{display:none;}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
@@ -192,21 +202,31 @@ function draw(state) {
|
||||
}
|
||||
}
|
||||
|
||||
// One box's look: its value, whether it can be typed, and the "linked"
|
||||
// button when another node sets it.
|
||||
function showField(state, key, value, lockedBy, tip) {
|
||||
const field = state.fields[key];
|
||||
field.control.set(value);
|
||||
field.control.root.style.opacity = lockedBy ? ".45" : "";
|
||||
field.control.root.inert = Boolean(lockedBy);
|
||||
field.go.hidden = !lockedBy;
|
||||
field.cell.title = lockedBy ? `Set by ${lockedBy.title}. Click "linked" to go to that node.` : tip;
|
||||
if (lockedBy) field.go.onclick = () => lockedBy.go?.();
|
||||
}
|
||||
|
||||
function updateFace(state) {
|
||||
const win = currentWindow(state);
|
||||
const max = maxSeconds(state);
|
||||
if (document.activeElement !== state.startInput) state.startInput.value = formatTimecode(win.start);
|
||||
if (document.activeElement !== state.endInput) state.endInput.value = formatTimecode(win.end);
|
||||
if (state.duration > 0) {
|
||||
const summary = outputSummary(win, { maxFromLink: max.fromLink && !max.known });
|
||||
state.summary.textContent = win.length > 0 ? secondsLabel(win.length) : "";
|
||||
state.summary.classList.toggle("has-cut", win.cut > 0.005);
|
||||
state.summary.title = win.cut > 0.005
|
||||
? `${summary}. Max length is ${max.value} s, so ${formatTimecode(win.keepEnd)} to ${formatTimecode(win.end)} is cut off (red). Click to move OUT to ${formatTimecode(win.keepEnd)}.`
|
||||
: `${summary}: ${formatTimecode(win.start)} to ${formatTimecode(win.keepEnd)} comes out.`;
|
||||
} else {
|
||||
state.summary.textContent = "";
|
||||
}
|
||||
const link = (name) => (linked(state.node, name) ? linkedNodeInfo(state.node, name) : null);
|
||||
// A linked value the page cannot read is only known when the graph runs:
|
||||
// its box, and the boxes that depend on it, stay empty.
|
||||
const known = (name) => !linked(state.node, name) || inputNumber(state.node, name, null) != null;
|
||||
const has = state.duration > 0;
|
||||
const startKnown = has && known("start_seconds");
|
||||
const lengthKnown = startKnown && known("max_seconds") && known("end_seconds");
|
||||
showField(state, "start", startKnown ? win.start : null, link("start_seconds"), `Where the sound starts in the file, of ${formatTimecode(state.duration)}.`);
|
||||
showField(state, "duration", lengthKnown ? win.length : null, link("max_seconds"),
|
||||
win.cut > 0.005 ? `How long the sound is. It stops ${formatTimecode(win.cut)} before the saved end (red).` : "How long the sound is. Clear it, or type 0, to run to the end of the file.");
|
||||
showField(state, "end", lengthKnown ? win.keepEnd : null, link("end_seconds"), "Where the sound stops in the file. Typing it changes the Duration.");
|
||||
draw(state);
|
||||
}
|
||||
|
||||
@@ -217,12 +237,19 @@ function writeWidget(widget, value) {
|
||||
widget.callback?.(next);
|
||||
}
|
||||
|
||||
// The pick, stored the way the face shows it (pickWrites): a Start and a
|
||||
// Duration, or a start and an end when another node sets the Duration.
|
||||
function writeTrim(state, bounds) {
|
||||
state.writing = true;
|
||||
try {
|
||||
writeWidget(state.startWidget, bounds.start);
|
||||
// OUT at the very end stays 0, the widget's own "to the end".
|
||||
writeWidget(state.endWidget, bounds.end >= state.duration - 0.005 ? 0 : bounds.end);
|
||||
const startLinked = linked(state.node, "start_seconds");
|
||||
const writes = pickWrites(state.duration, startLinked ? currentWindow(state).start : bounds.start, bounds.end, {
|
||||
maxLinked: linked(state.node, "max_seconds") || !state.maxWidget,
|
||||
endLinked: linked(state.node, "end_seconds"),
|
||||
});
|
||||
if (!startLinked) writeWidget(state.startWidget, writes.start);
|
||||
if (writes.end !== undefined) writeWidget(state.endWidget, writes.end);
|
||||
if (writes.max !== undefined) writeWidget(state.maxWidget, writes.max);
|
||||
} finally {
|
||||
state.writing = false;
|
||||
}
|
||||
@@ -248,7 +275,7 @@ function installDrag(state) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const initial = infoAt(event.clientX);
|
||||
const bounds = { start: initial.win.start, end: initial.win.end };
|
||||
const bounds = { start: initial.win.start, end: initial.win.keepEnd };
|
||||
const anchor = initial.fraction * state.duration;
|
||||
const downX = event.clientX;
|
||||
let moved = false;
|
||||
@@ -262,7 +289,7 @@ function installDrag(state) {
|
||||
const next = infoAt(clientX);
|
||||
if (initial.zone === "start" || initial.zone === "end") {
|
||||
const now = currentWindow(state);
|
||||
writeTrim(state, dragTrimHandle(state.duration, { start: now.start, end: now.end }, initial.zone, next.fraction, MIN_TRIM_SECONDS));
|
||||
writeTrim(state, dragTrimHandle(state.duration, { start: now.start, end: now.keepEnd }, initial.zone, next.fraction, MIN_TRIM_SECONDS));
|
||||
} else if (initial.zone === "move") {
|
||||
writeTrim(state, slideTrimWindow(state.duration, bounds, next.fraction * state.duration - anchor));
|
||||
} else {
|
||||
@@ -336,19 +363,6 @@ function installPlayer(state) {
|
||||
state.stopPlayer = () => { audio.pause(); stop(); };
|
||||
}
|
||||
|
||||
function commitTimeInput(state, edge, input) {
|
||||
if (state.duration <= 0) return;
|
||||
const seconds = parseTimecode(input.value);
|
||||
const win = currentWindow(state);
|
||||
if (seconds === null) {
|
||||
input.value = formatTimecode(edge === "start" ? win.start : win.end);
|
||||
return;
|
||||
}
|
||||
writeTrim(state, dragTrimHandle(state.duration, { start: win.start, end: win.end }, edge, seconds / state.duration, MIN_TRIM_SECONDS));
|
||||
notifyAusbossChange();
|
||||
input.blur();
|
||||
}
|
||||
|
||||
function watchWidget(state, widget) {
|
||||
if (!widget || widget.__ausbossAudioWatch) return;
|
||||
widget.__ausbossAudioWatch = true;
|
||||
@@ -385,37 +399,44 @@ function buildPanel(node) {
|
||||
playButton.classList.add("ausboss-audio-play");
|
||||
const loopButton = makeToolButton("LOOP", "Play it again and again");
|
||||
stage.append(canvas, status);
|
||||
// Play and Loop sit either side of the wave, so neither covers a handle.
|
||||
loopButton.classList.add("ausboss-audio-play");
|
||||
const waveRow = document.createElement("div");
|
||||
waveRow.className = "ausboss-audio-wave-row";
|
||||
waveRow.append(playButton, stage, loopButton);
|
||||
|
||||
const values = document.createElement("div");
|
||||
values.className = "ausboss-video-values";
|
||||
const makeValue = (labelText, title) => {
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "ausboss-video-value";
|
||||
const label = document.createElement("label");
|
||||
label.textContent = labelText;
|
||||
const input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.inputMode = "decimal";
|
||||
input.placeholder = "m:ss.s";
|
||||
input.title = title;
|
||||
input.addEventListener("keydown", (event) => {
|
||||
keepKeyInField(event);
|
||||
if (event.key === "Enter") input.dispatchEvent(new Event("change"));
|
||||
});
|
||||
wrap.append(label, input);
|
||||
return { wrap, input };
|
||||
// Start, Duration and Ends at, as on the video nodes, in seconds.
|
||||
const fieldsRow = document.createElement("div");
|
||||
fieldsRow.className = "ausboss-audio-fields";
|
||||
const fields = {};
|
||||
const commit = (key, value) => {
|
||||
const state = node.__ausbossLoadAudio;
|
||||
if (!state || state.duration <= 0) return;
|
||||
writeTrim(state, typedPick(key, value, currentWindow(state), state.duration, MIN_TRIM_SECONDS));
|
||||
};
|
||||
const startValue = makeValue("IN", "Where the sound starts. Type seconds (12.5) or a time (0:12.5).");
|
||||
const endValue = makeValue("OUT", "Where the sound stops. Type seconds (24) or a time (0:24.0).");
|
||||
// How long the output is, beside OUT and off the wave. Red when Max
|
||||
// length cuts the pick short; the tooltip says how much.
|
||||
const summary = document.createElement("div");
|
||||
summary.className = "ausboss-audio-length";
|
||||
values.append(startValue.wrap, endValue.wrap);
|
||||
const row = document.createElement("div");
|
||||
row.className = "ausboss-audio-row";
|
||||
row.append(playButton, values, summary, loopButton);
|
||||
root.append(stage, row);
|
||||
for (const [key, caption] of [["start", "Start"], ["duration", "Duration"], ["end", "Ends at"]]) {
|
||||
const cell = document.createElement("div");
|
||||
cell.className = "ausboss-audio-field";
|
||||
const label = document.createElement("span");
|
||||
label.className = "ausboss-audio-field-label";
|
||||
label.textContent = caption;
|
||||
const go = document.createElement("button");
|
||||
go.type = "button";
|
||||
go.className = "ausboss-audio-go";
|
||||
go.textContent = "linked";
|
||||
go.hidden = true;
|
||||
label.append(go);
|
||||
const control = makeScrubInput({
|
||||
value: 0, min: 0, max: 86400, step: 0.1, fineStep: 0.01, decimals: 2, minDecimals: 0, unit: "s", unitWidth: 14,
|
||||
allowEmpty: true,
|
||||
onChange: (value) => commit(key, value),
|
||||
onSettle: () => notifyAusbossChange(),
|
||||
});
|
||||
cell.append(label, control.root);
|
||||
fieldsRow.append(cell);
|
||||
fields[key] = { cell, control, go };
|
||||
}
|
||||
root.append(waveRow, fieldsRow);
|
||||
|
||||
const widget = node.addDOMWidget(PANEL_WIDGET, "ausboss_audio", root, {
|
||||
serialize: false,
|
||||
@@ -435,22 +456,11 @@ function buildPanel(node) {
|
||||
audio.preload = "auto";
|
||||
const abort = new AbortController();
|
||||
const state = node.__ausbossLoadAudio = {
|
||||
node, root, stage, canvas, status, playButton, loopButton, summary, audio,
|
||||
startInput: startValue.input, endInput: endValue.input,
|
||||
node, root, stage, canvas, status, playButton, loopButton, audio, fields,
|
||||
audioWidget, startWidget, endWidget, maxWidget: findWidget(node, "max_seconds"),
|
||||
duration: 0, peaks: null, abort, writing: false, dragging: false, raf: 0, loading: 0,
|
||||
};
|
||||
|
||||
// Clicking the red length moves OUT to where the sound really ends.
|
||||
summary.addEventListener("click", (event) => {
|
||||
const win = currentWindow(state);
|
||||
if (win.cut <= 0.005) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
writeTrim(state, { start: win.start, end: win.keepEnd });
|
||||
notifyAusbossChange();
|
||||
});
|
||||
|
||||
const updateLoop = () => loopButton.classList.toggle("active", loopEnabled(node));
|
||||
updateLoop();
|
||||
loopButton.addEventListener("click", (event) => {
|
||||
@@ -509,8 +519,6 @@ function buildPanel(node) {
|
||||
watchWidget(state, startWidget);
|
||||
watchWidget(state, endWidget);
|
||||
watchWidget(state, state.maxWidget);
|
||||
startValue.input.addEventListener("change", () => commitTimeInput(state, "start", startValue.input));
|
||||
endValue.input.addEventListener("change", () => commitTimeInput(state, "end", endValue.input));
|
||||
const observer = new ResizeObserver(() => draw(state));
|
||||
observer.observe(stage);
|
||||
state.observer = observer;
|
||||
|
||||
+145
-355
@@ -1,9 +1,11 @@
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange } from "../shared/index.mjs";
|
||||
import { keepKeyInField } from "../shared/canvas_passthrough.mjs";
|
||||
import { WIDGET_FRAME, fillNodeHeight } from "../shared/panel_layout.mjs";
|
||||
import { formatTimecode, parseTimecode } from "../shared/timecode.mjs";
|
||||
import { inputNumber } from "../shared/clip_rate.mjs";
|
||||
import { clipInfo, windowSeconds } from "../shared/timeline_math.mjs";
|
||||
import { mountTransformTrim } from "../shared/transform_trim.mjs";
|
||||
import { linkedNodeInfo, timingUnits } from "../shared/timing_links.mjs";
|
||||
import { parseImageReference } from "../shared/pad_canvas.mjs";
|
||||
import {
|
||||
mediaInfo,
|
||||
@@ -19,42 +21,31 @@ import {
|
||||
suppressCoreVideoPreview,
|
||||
} from "../shared/video_ui.mjs";
|
||||
import {
|
||||
MIN_TRIM_SECONDS,
|
||||
clampTrimSeek,
|
||||
closestTrimHandle,
|
||||
dragTrimHandle,
|
||||
loadSummary,
|
||||
playbackBoundaryAction,
|
||||
singleFrameFraction,
|
||||
singleFrameTime,
|
||||
slideTrimWindow,
|
||||
trimAfterFramePick,
|
||||
trimBounds,
|
||||
trimFractions,
|
||||
} from "./trim_preview.mjs";
|
||||
|
||||
const NODE_NAME = "AUSBOSS_NODES_LoadVideo";
|
||||
const PREVIEW_WIDGET = "ausboss_load_video_viewer";
|
||||
const PREVIEW_CHROME = 88;
|
||||
// The shared video root's CSS minimum: 8px root padding + the stage's 112px
|
||||
// floor + 6px gap + the 76px trim strip. The declared floor adds
|
||||
// WIDGET_FRAME on top, or the element comes up short and clips the trim
|
||||
// strip's bottom border at the node's minimum height.
|
||||
const PANEL_MIN_HEIGHT = 202;
|
||||
// 8px root padding + the stage's 112px floor + 6px gap + the 152px timing
|
||||
// card (js/shared/transform_trim.mjs). The declared floor adds WIDGET_FRAME
|
||||
// on top, or the element comes up short and clips the card's bottom border
|
||||
// at the node's minimum height.
|
||||
const PANEL_MIN_HEIGHT = 278;
|
||||
// Height the node opens at. It used to fall out of the panel's computeSize;
|
||||
// with the panel free to follow the node, the default has to be stated. The
|
||||
// chrome covers the transport row and the trim strip under the player.
|
||||
const DEFAULT_NODE_SIZE = [380, responsivePreviewHeight(380) + PREVIEW_CHROME + 190];
|
||||
// extra covers the tools over the picture and the timing card under it.
|
||||
const DEFAULT_NODE_SIZE = [380, responsivePreviewHeight(380) + PREVIEW_CHROME + 210];
|
||||
const TRIM_EPSILON = 0.04;
|
||||
|
||||
function findWidget(node, name) {
|
||||
return node.widgets?.find((widget) => widget.name === name);
|
||||
}
|
||||
|
||||
function roundHundredth(value) {
|
||||
return Math.round(Number(value || 0) * 100) / 100;
|
||||
}
|
||||
|
||||
function getLoopEnabled(node) {
|
||||
node.properties ??= {};
|
||||
if (node.properties.ausboss_load_video_loop === undefined) {
|
||||
@@ -66,14 +57,25 @@ function getLoopEnabled(node) {
|
||||
function setEmpty(state, text) {
|
||||
state.stage.classList.add("is-empty");
|
||||
state.status.textContent = text;
|
||||
state.status.hidden = false;
|
||||
}
|
||||
|
||||
function setReady(state, text) {
|
||||
state.stage.classList.remove("is-empty");
|
||||
state.status.textContent = text;
|
||||
state.status.hidden = !text;
|
||||
}
|
||||
|
||||
// The run's window in seconds, as the timing card works it out (Start, and
|
||||
// the Duration or the end), or the plain start/end before the video's frame
|
||||
// rate is known.
|
||||
function currentBounds(state) {
|
||||
const info = clipInfo(state.metadata);
|
||||
const window = state.card?.window?.();
|
||||
if (info.fps > 0 && window && Number.isFinite(window.first)) {
|
||||
const last = Number.isFinite(window.last) ? window.last : info.count - 1;
|
||||
return { start: window.first / info.fps, end: Math.min(info.duration || Infinity, (last + 1) / info.fps) };
|
||||
}
|
||||
return trimBounds(state.video.duration, state.startWidget.value, state.endWidget.value);
|
||||
}
|
||||
|
||||
@@ -82,271 +84,116 @@ function isSingleFrame(state) {
|
||||
}
|
||||
|
||||
// Where the preview belongs for the current mode: the chosen frame, or the
|
||||
// trim window's IN point.
|
||||
// clip's start.
|
||||
function homeTime(state) {
|
||||
return isSingleFrame(state)
|
||||
? singleFrameTime(state.video.duration, state.startWidget.value)
|
||||
: currentBounds(state).start;
|
||||
}
|
||||
|
||||
function applyMode(state) {
|
||||
const single = isSingleFrame(state);
|
||||
state.root.classList.toggle("is-single-frame", single);
|
||||
state.frameButton?.classList.toggle("active", single);
|
||||
state.startLabel.textContent = single ? "AT" : "IN";
|
||||
state.range.title = single
|
||||
? "Drag or click to choose the frame that loads"
|
||||
: "Drag either handle to set the trim; drag the selected range to move it";
|
||||
updateTrimFace(state);
|
||||
}
|
||||
|
||||
function widgetLinkDriven(node, name) {
|
||||
return !!node.inputs?.some((input) => input?.widget?.name === name && input.link != null);
|
||||
}
|
||||
|
||||
// The honest "what will actually load" text for the label under the trim
|
||||
// strip, or "" when there is nothing honest to say. Any of the deciding
|
||||
// widgets driven by a link means its face value is stale, so the count
|
||||
// drops out rather than guessing.
|
||||
function trimLoadSummary(state, duration, bounds) {
|
||||
const deciders = ["start_seconds", "end_seconds", "every_nth", "max_frames", "single_frame"];
|
||||
if (deciders.some((name) => widgetLinkDriven(state.node, name))) return "";
|
||||
return loadSummary(
|
||||
duration,
|
||||
bounds,
|
||||
state.sourceFps,
|
||||
state.everyNthWidget?.value,
|
||||
state.maxFramesWidget?.value,
|
||||
isSingleFrame(state),
|
||||
);
|
||||
}
|
||||
|
||||
// The <video> element never exposes the source frame rate, so the frame
|
||||
// count in the label needs a probe of the pack's metadata route. Fail-soft:
|
||||
// on any error the label simply omits the count and the timecodes stand.
|
||||
async function probeSourceFps(state, name) {
|
||||
state.sourceFps = 0;
|
||||
// Frame rate and the real frame count come from the pack's metadata route:
|
||||
// the <video> element knows neither, and its length rounds up a frame.
|
||||
// Fail-soft: without it the card waits for a source.
|
||||
async function probeMetadata(state, name) {
|
||||
state.metadata = null;
|
||||
try {
|
||||
const query = new URLSearchParams({ source_mode: "input folder", video: name });
|
||||
const type = parseImageReference(name)?.type;
|
||||
if (type && type !== "input") {
|
||||
query.set("source_mode", "local path");
|
||||
query.set("local_path", name);
|
||||
}
|
||||
const response = await api.fetchApi(`/ausboss/transform/video/metadata?${query}`);
|
||||
if (!response.ok) return;
|
||||
const metadata = await response.json();
|
||||
if (state.videoWidget.value !== name) return; // a newer selection won
|
||||
state.sourceFps = Math.max(0, Number(metadata?.fps) || 0);
|
||||
updateTrimFace(state);
|
||||
state.metadata = metadata;
|
||||
state.card?.sync();
|
||||
} catch (_error) {
|
||||
/* no fps, no frame count */
|
||||
/* no metadata, no timing card numbers */
|
||||
}
|
||||
}
|
||||
|
||||
function writeWidget(widget, value) {
|
||||
const next = roundHundredth(value);
|
||||
if (Math.abs(Number(widget.value || 0) - next) < 0.0001) return;
|
||||
widget.value = next;
|
||||
widget.callback?.(next);
|
||||
function setWidget(widget, value) {
|
||||
if (!widget) return;
|
||||
if (widget.value === value) return;
|
||||
widget.value = value;
|
||||
widget.callback?.(value);
|
||||
}
|
||||
|
||||
function writeTrim(state, bounds, seekEdge = null) {
|
||||
state.writing = true;
|
||||
try {
|
||||
writeWidget(state.startWidget, bounds.start);
|
||||
writeWidget(state.endWidget, bounds.end);
|
||||
} finally {
|
||||
state.writing = false;
|
||||
}
|
||||
updateTrimFace(state);
|
||||
if (state.video.readyState >= 1 && seekEdge) {
|
||||
state.video.currentTime = seekEdge === "start"
|
||||
? bounds.start
|
||||
: Math.max(bounds.start, bounds.end - TRIM_EPSILON);
|
||||
}
|
||||
state.node.setDirtyCanvas?.(true, true);
|
||||
state.node.graph?.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
function writeFrameTime(state, timeValue) {
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
const time = singleFrameTime(duration, timeValue);
|
||||
state.writing = true;
|
||||
try {
|
||||
writeWidget(state.startWidget, time);
|
||||
} finally {
|
||||
state.writing = false;
|
||||
}
|
||||
updateTrimFace(state);
|
||||
if (state.video.readyState >= 1) state.video.currentTime = time;
|
||||
state.node.setDirtyCanvas?.(true, true);
|
||||
state.node.graph?.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
|
||||
function updateTrimFace(state) {
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
if (isSingleFrame(state)) {
|
||||
const time = singleFrameTime(duration, state.startWidget.value);
|
||||
const percent = singleFrameFraction(duration, time) * 100;
|
||||
state.selection.style.width = "0%";
|
||||
state.startHandle.style.left = `${percent}%`;
|
||||
if (document.activeElement !== state.startInput) state.startInput.value = formatTimecode(time);
|
||||
// "1 frame at 0:05.2" - the count comes from the same pure summary the
|
||||
// trim label uses, so both modes report what one Run will load.
|
||||
const summary = trimLoadSummary(state, duration, null);
|
||||
state.durationLabel.textContent = duration > 0
|
||||
? `${summary || "frame"} at ${formatTimecode(time)}`
|
||||
: "load a video to pick a frame";
|
||||
if (duration > 0) state.status.textContent = `frame at ${formatTimecode(time)}`;
|
||||
return;
|
||||
}
|
||||
const bounds = trimBounds(duration, state.startWidget.value, state.endWidget.value);
|
||||
const fractions = trimFractions(duration, bounds);
|
||||
const startPercent = fractions.start * 100;
|
||||
const endPercent = fractions.end * 100;
|
||||
state.selection.style.left = `${startPercent}%`;
|
||||
state.selection.style.width = `${Math.max(0, endPercent - startPercent)}%`;
|
||||
state.startHandle.style.left = `${startPercent}%`;
|
||||
state.endHandle.style.left = `${endPercent}%`;
|
||||
if (document.activeElement !== state.startInput) state.startInput.value = formatTimecode(bounds.start);
|
||||
if (document.activeElement !== state.endInput) state.endInput.value = formatTimecode(bounds.end);
|
||||
const selected = Math.max(0, bounds.end - bounds.start);
|
||||
// The preview cannot re-render every_nth or max_frames, so the label
|
||||
// reports them instead: "0:04.0 of 0:10.0 · 48 frames @ 12 fps".
|
||||
const summary = trimLoadSummary(state, duration, bounds);
|
||||
state.durationLabel.textContent = duration > 0
|
||||
? `${formatTimecode(selected)} of ${formatTimecode(duration)}${summary ? ` · ${summary}` : ""}`
|
||||
: "load a video to trim";
|
||||
state.status.textContent = duration > 0
|
||||
? `${formatTimecode(bounds.start)} → ${formatTimecode(bounds.end)}`
|
||||
: state.status.textContent;
|
||||
}
|
||||
|
||||
function installTrimDrag(state) {
|
||||
const { range } = state;
|
||||
const infoAt = (clientX) => {
|
||||
const rect = range.getBoundingClientRect();
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
const bounds = currentBounds(state);
|
||||
const fractions = trimFractions(duration, bounds);
|
||||
const x = clientX - rect.left;
|
||||
const hit = 10;
|
||||
let zone = "jump";
|
||||
const closest = closestTrimHandle(
|
||||
fractions.start,
|
||||
fractions.end,
|
||||
rect.width ? x / rect.width : 0,
|
||||
rect.width,
|
||||
hit,
|
||||
);
|
||||
if (closest) zone = closest;
|
||||
else if (x > fractions.start * rect.width && x < fractions.end * rect.width) zone = "move";
|
||||
return { rect, duration, bounds, fraction: rect.width ? x / rect.width : 0, zone };
|
||||
};
|
||||
|
||||
range.addEventListener("pointermove", (event) => {
|
||||
if (state.dragging) return;
|
||||
if (isSingleFrame(state)) {
|
||||
range.style.cursor = "ew-resize";
|
||||
return;
|
||||
}
|
||||
const { zone } = infoAt(event.clientX);
|
||||
range.style.cursor = zone === "start" || zone === "end"
|
||||
? "ew-resize"
|
||||
: zone === "move" ? "grab" : "pointer";
|
||||
});
|
||||
|
||||
range.addEventListener("pointerdown", (event) => {
|
||||
if (event.button !== 0 || state.dragging) return;
|
||||
const initial = infoAt(event.clientX);
|
||||
if (initial.duration <= 0) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (isSingleFrame(state)) {
|
||||
// Frame-picker gesture: the strip is one scrub rail. A click already
|
||||
// sets the frame; a drag keeps refining it until release.
|
||||
state.dragging = true;
|
||||
try { range.setPointerCapture(event.pointerId); } catch (_error) { /* mouse fallback */ }
|
||||
const scrub = (clientX) => {
|
||||
const next = infoAt(clientX);
|
||||
writeFrameTime(state, next.fraction * next.duration);
|
||||
};
|
||||
scrub(event.clientX);
|
||||
const move = (moveEvent) => {
|
||||
if (!(moveEvent.buttons & 1)) { finish(); return; }
|
||||
scrub(moveEvent.clientX);
|
||||
};
|
||||
const finish = () => {
|
||||
if (!state.dragging) return;
|
||||
state.dragging = false;
|
||||
range.removeEventListener("pointermove", move);
|
||||
try { range.releasePointerCapture(event.pointerId); } catch (_error) { /* already released */ }
|
||||
// One notification per gesture: the frame changed on pointerdown.
|
||||
notifyAusbossChange();
|
||||
};
|
||||
range.addEventListener("pointermove", move);
|
||||
range.addEventListener("pointerup", finish, { once: true });
|
||||
range.addEventListener("pointercancel", finish, { once: true });
|
||||
range.addEventListener("lostpointercapture", finish, { once: true });
|
||||
return;
|
||||
}
|
||||
state.dragging = true;
|
||||
try { range.setPointerCapture(event.pointerId); } catch (_error) { /* mouse fallback */ }
|
||||
const downX = event.clientX;
|
||||
const anchorTime = initial.fraction * initial.duration;
|
||||
let moved = false;
|
||||
|
||||
const apply = (clientX) => {
|
||||
const next = infoAt(clientX);
|
||||
if (initial.zone === "start" || initial.zone === "end") {
|
||||
writeTrim(
|
||||
state,
|
||||
dragTrimHandle(next.duration, currentBounds(state), initial.zone, next.fraction),
|
||||
initial.zone,
|
||||
);
|
||||
} else if (initial.zone === "move") {
|
||||
const pointerTime = next.fraction * next.duration;
|
||||
writeTrim(
|
||||
state,
|
||||
slideTrimWindow(next.duration, initial.bounds, pointerTime - anchorTime),
|
||||
"start",
|
||||
);
|
||||
} else {
|
||||
const span = initial.bounds.end - initial.bounds.start;
|
||||
const centeredStart = next.fraction * next.duration - span / 2;
|
||||
writeTrim(
|
||||
state,
|
||||
slideTrimWindow(next.duration, initial.bounds, centeredStart - initial.bounds.start),
|
||||
"start",
|
||||
);
|
||||
// The timing card: the clip node's own, with Start, Duration and Ends at,
|
||||
// or, while FRAME is on, its frame picker. The player above it is the
|
||||
// picture, so the card leaves out its own Play button.
|
||||
function mountCard(state) {
|
||||
const { node } = state;
|
||||
const widgetFor = (name) => node.widgets?.find((widget) => widget.name === name);
|
||||
const fps = () => clipInfo(state.metadata).fps;
|
||||
const single = isSingleFrame(state);
|
||||
const card = mountTransformTrim({
|
||||
get: (name, fallback) => {
|
||||
if (name === "frame_index") return state.head ?? 0;
|
||||
const widget = widgetFor(name);
|
||||
return widget ? widget.value : fallback;
|
||||
},
|
||||
set: (name, value) => {
|
||||
state.writing = true;
|
||||
try { setWidget(widgetFor(name), value); } finally { state.writing = false; }
|
||||
if (state.video.readyState >= 1 && !state.video.paused) return;
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
},
|
||||
has: (name) => Boolean(widgetFor(name)),
|
||||
driven: (name) => widgetLinkDriven(node, name),
|
||||
number: (name, fallback) => inputNumber(node, name, fallback),
|
||||
metadata: () => state.metadata,
|
||||
trim: !single,
|
||||
play: false,
|
||||
isPlaying: () => !state.video.paused,
|
||||
onTogglePlayback: () => {},
|
||||
onSeek: (frame, settled) => {
|
||||
state.head = frame;
|
||||
const rate = fps();
|
||||
if (single && rate > 0) {
|
||||
state.writing = true;
|
||||
try { setWidget(state.startWidget, windowSeconds(clipInfo(state.metadata), frame, frame).start_seconds); } finally { state.writing = false; }
|
||||
}
|
||||
};
|
||||
|
||||
const move = (moveEvent) => {
|
||||
if (!(moveEvent.buttons & 1)) { finish(moveEvent); return; }
|
||||
if (!moved && Math.abs(moveEvent.clientX - downX) < 3) return;
|
||||
moved = true;
|
||||
apply(moveEvent.clientX);
|
||||
};
|
||||
const finish = (finishEvent) => {
|
||||
if (!state.dragging) return;
|
||||
state.dragging = false;
|
||||
range.removeEventListener("pointermove", move);
|
||||
try { range.releasePointerCapture(event.pointerId); } catch (_error) { /* already released */ }
|
||||
if (!moved && initial.zone === "jump") {
|
||||
const next = infoAt(finishEvent?.clientX ?? downX);
|
||||
const span = initial.bounds.end - initial.bounds.start;
|
||||
const centeredStart = next.fraction * next.duration - span / 2;
|
||||
writeTrim(
|
||||
state,
|
||||
slideTrimWindow(next.duration, initial.bounds, centeredStart - initial.bounds.start),
|
||||
"start",
|
||||
);
|
||||
}
|
||||
// One notification per gesture, on release — never per pointermove.
|
||||
if (moved || initial.zone === "jump") notifyAusbossChange();
|
||||
};
|
||||
range.addEventListener("pointermove", move);
|
||||
range.addEventListener("pointerup", finish, { once: true });
|
||||
range.addEventListener("pointercancel", finish, { once: true });
|
||||
range.addEventListener("lostpointercapture", finish, { once: true });
|
||||
if (state.video.readyState >= 1 && rate > 0) state.video.currentTime = Math.min(state.video.duration || Infinity, (frame + 0.5) / rate);
|
||||
if (settled) notifyAusbossChange();
|
||||
},
|
||||
onCommit: notifyAusbossChange,
|
||||
linkInfo: (name) => linkedNodeInfo(node, name),
|
||||
units: () => timingUnits(),
|
||||
setUnits: (next) => timingUnits(next),
|
||||
});
|
||||
state.card?.root.remove();
|
||||
state.card = card;
|
||||
state.cardSlot.append(card.root);
|
||||
return card;
|
||||
}
|
||||
|
||||
function applyMode(state) {
|
||||
const single = isSingleFrame(state);
|
||||
state.root.classList.toggle("is-single-frame", single);
|
||||
state.frameButton?.classList.toggle("active", single);
|
||||
if (state.cardMode !== single) {
|
||||
state.cardMode = single;
|
||||
mountCard(state);
|
||||
}
|
||||
state.card?.sync();
|
||||
}
|
||||
|
||||
// The playhead follows the player, so the card's marker and readout move
|
||||
// with the picture.
|
||||
function followPlayer(state) {
|
||||
const rate = clipInfo(state.metadata).fps;
|
||||
if (!(rate > 0)) return;
|
||||
const frame = Math.max(0, Math.floor(state.video.currentTime * rate + 1e-6));
|
||||
if (frame === state.head) return;
|
||||
state.head = frame;
|
||||
state.card?.sync();
|
||||
}
|
||||
|
||||
function installPlayback(state) {
|
||||
@@ -356,9 +203,9 @@ function installPlayback(state) {
|
||||
state.playRaf = 0;
|
||||
};
|
||||
const tick = () => {
|
||||
if (video.paused || video.ended) { stopTick(); return; }
|
||||
// Frame picking plays the whole source freely — the trim window is not
|
||||
// in force, so there is no boundary to loop or stop at.
|
||||
if (video.paused || video.ended) { stopTick(); followPlayer(state); return; }
|
||||
// Frame picking plays the whole source freely - the clip is not in
|
||||
// force, so there is no boundary to loop or stop at.
|
||||
if (!isSingleFrame(state)) {
|
||||
const bounds = currentBounds(state);
|
||||
const action = playbackBoundaryAction(video.currentTime, bounds, getLoopEnabled(state.node), TRIM_EPSILON);
|
||||
@@ -367,9 +214,11 @@ function installPlayback(state) {
|
||||
} else if (action === "stop") {
|
||||
video.pause();
|
||||
video.currentTime = Math.max(bounds.start, bounds.end - TRIM_EPSILON);
|
||||
followPlayer(state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
followPlayer(state);
|
||||
state.playRaf = requestAnimationFrame(tick);
|
||||
};
|
||||
video.addEventListener("play", () => {
|
||||
@@ -390,7 +239,7 @@ function installPlayback(state) {
|
||||
state.correctingSeek = true;
|
||||
video.currentTime = target;
|
||||
}, { signal: state.abort.signal });
|
||||
video.addEventListener("seeked", () => { state.correctingSeek = false; }, { signal: state.abort.signal });
|
||||
video.addEventListener("seeked", () => { state.correctingSeek = false; followPlayer(state); }, { signal: state.abort.signal });
|
||||
state.stopTick = stopTick;
|
||||
}
|
||||
|
||||
@@ -401,8 +250,8 @@ function watchTrimWidget(state, widget) {
|
||||
widget.callback = function (...args) {
|
||||
const result = prior?.apply(this, args);
|
||||
if (!state.writing) {
|
||||
updateTrimFace(state);
|
||||
if (state.video.readyState >= 1) state.video.currentTime = homeTime(state);
|
||||
state.card?.sync();
|
||||
if (state.video.readyState >= 1 && state.video.paused) state.video.currentTime = homeTime(state);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -416,7 +265,10 @@ function watchFrameWidget(state, widget) {
|
||||
const result = prior?.apply(this, args);
|
||||
if (!isSingleFrame(state)) {
|
||||
const reopened = trimAfterFramePick(state.startWidget.value, state.endWidget.value);
|
||||
if (reopened) writeTrim(state, reopened);
|
||||
if (reopened) {
|
||||
state.writing = true;
|
||||
try { setWidget(state.endWidget, reopened.end); } finally { state.writing = false; }
|
||||
}
|
||||
}
|
||||
applyMode(state);
|
||||
if (state.video.readyState >= 1) state.video.currentTime = homeTime(state);
|
||||
@@ -424,28 +276,6 @@ function watchFrameWidget(state, widget) {
|
||||
};
|
||||
}
|
||||
|
||||
function commitTimeInput(state, edge, input) {
|
||||
const duration = Number.isFinite(state.video.duration) ? state.video.duration : 0;
|
||||
if (duration <= 0) return;
|
||||
const seconds = parseTimecode(input.value);
|
||||
if (seconds === null) {
|
||||
// Malformed entry: restore the previous value and keep focus for a retry.
|
||||
const bounds = currentBounds(state);
|
||||
input.value = formatTimecode(edge === "start" ? bounds.start : bounds.end);
|
||||
return;
|
||||
}
|
||||
if (isSingleFrame(state)) {
|
||||
writeFrameTime(state, seconds);
|
||||
notifyAusbossChange();
|
||||
input.blur();
|
||||
return;
|
||||
}
|
||||
const fraction = seconds / duration;
|
||||
writeTrim(state, dragTrimHandle(duration, currentBounds(state), edge, fraction), edge);
|
||||
notifyAusbossChange();
|
||||
input.blur();
|
||||
}
|
||||
|
||||
function buildPreview(node) {
|
||||
if (node.__ausbossLoadVideo) return node.__ausbossLoadVideo;
|
||||
const videoWidget = findWidget(node, "video");
|
||||
@@ -461,6 +291,8 @@ function buildPreview(node) {
|
||||
hideCanvasWidget(startWidget);
|
||||
hideCanvasWidget(endWidget);
|
||||
if (frameWidget) hideCanvasWidget(frameWidget);
|
||||
// Every nth and the frame limit (the Duration) live in the timing card;
|
||||
// the widget card hides their widgets (js/widget_cards).
|
||||
|
||||
const root = document.createElement("div");
|
||||
root.className = "ausboss-video-root";
|
||||
@@ -475,7 +307,7 @@ function buildPreview(node) {
|
||||
status.textContent = "Choose or upload a video";
|
||||
const tools = document.createElement("div");
|
||||
tools.className = "ausboss-video-tools";
|
||||
const loopButton = makeToolButton("LOOP", "Loop playback inside the selected trim");
|
||||
const loopButton = makeToolButton("LOOP", "Play the clip again and again");
|
||||
loopButton.classList.add("ausboss-video-loop");
|
||||
const reloadButton = makeToolButton("↻", "Reload the selected source video");
|
||||
const frameButton = frameWidget
|
||||
@@ -485,45 +317,12 @@ function buildPreview(node) {
|
||||
tools.append(loopButton, reloadButton);
|
||||
stage.append(video, status, tools);
|
||||
|
||||
const trim = document.createElement("div");
|
||||
trim.className = "ausboss-video-trim";
|
||||
const range = document.createElement("div");
|
||||
range.className = "ausboss-video-range";
|
||||
range.title = "Drag either handle to set the trim; drag the selected range to move it";
|
||||
const selection = document.createElement("div");
|
||||
selection.className = "ausboss-video-selection";
|
||||
const startHandle = document.createElement("div");
|
||||
startHandle.className = "ausboss-video-handle";
|
||||
const endHandle = document.createElement("div");
|
||||
endHandle.className = "ausboss-video-handle is-end";
|
||||
range.append(selection, startHandle, endHandle);
|
||||
const values = document.createElement("div");
|
||||
values.className = "ausboss-video-values";
|
||||
const makeValue = (labelText) => {
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "ausboss-video-value";
|
||||
const label = document.createElement("label");
|
||||
label.textContent = labelText;
|
||||
const input = document.createElement("input");
|
||||
input.type = "text";
|
||||
input.inputMode = "decimal";
|
||||
input.placeholder = "m:ss.s";
|
||||
input.title = `${labelText} point - type seconds (95.5) or a timecode (1:35.5, 1:02:03.5)`;
|
||||
input.addEventListener("keydown", (event) => {
|
||||
keepKeyInField(event);
|
||||
if (event.key === "Enter") input.dispatchEvent(new Event("change"));
|
||||
});
|
||||
wrap.append(label, input);
|
||||
return { wrap, input, label };
|
||||
};
|
||||
const startValue = makeValue("IN");
|
||||
const endValue = makeValue("OUT");
|
||||
endValue.wrap.classList.add("is-end");
|
||||
const durationLabel = document.createElement("div");
|
||||
durationLabel.className = "ausboss-video-duration";
|
||||
values.append(startValue.wrap, durationLabel, endValue.wrap);
|
||||
trim.append(range, values);
|
||||
root.append(stage, trim);
|
||||
// The timing card goes here (mountCard): the clip node's Start,
|
||||
// Duration and Ends at, or the frame picker while FRAME is on.
|
||||
const cardSlot = document.createElement("div");
|
||||
cardSlot.className = "ausboss-video-timing";
|
||||
cardSlot.style.flex = "none";
|
||||
root.append(stage, cardSlot);
|
||||
|
||||
const widget = node.addDOMWidget(PREVIEW_WIDGET, "ausboss_video", root, {
|
||||
serialize: false,
|
||||
@@ -544,15 +343,9 @@ function buildPreview(node) {
|
||||
const abort = new AbortController();
|
||||
const state = node.__ausbossLoadVideo = {
|
||||
node, root, stage, video, status, loopButton, reloadButton, frameButton,
|
||||
trim, range, selection, startHandle, endHandle, startInput: startValue.input,
|
||||
endInput: endValue.input, startLabel: startValue.label, durationLabel,
|
||||
cardSlot, card: null, cardMode: null, metadata: null, head: 0,
|
||||
videoWidget, startWidget, endWidget, frameWidget,
|
||||
// Absent on a backend without these widgets; the summary then reads
|
||||
// its defaults (keep every frame, no cap).
|
||||
everyNthWidget: findWidget(node, "every_nth"),
|
||||
maxFramesWidget: findWidget(node, "max_frames"),
|
||||
sourceFps: 0,
|
||||
widget, abort, writing: false, dragging: false, correctingSeek: false, playRaf: 0,
|
||||
widget, abort, writing: false, correctingSeek: false, playRaf: 0,
|
||||
};
|
||||
|
||||
const updateLoopButton = () => loopButton.classList.toggle("active", getLoopEnabled(node));
|
||||
@@ -583,9 +376,9 @@ function buildPreview(node) {
|
||||
if (!name || typeof name !== "string") {
|
||||
video.pause();
|
||||
video.removeAttribute("src");
|
||||
state.sourceFps = 0;
|
||||
state.metadata = null;
|
||||
setEmpty(state, "Choose or upload a video");
|
||||
updateTrimFace(state);
|
||||
state.card?.sync();
|
||||
return;
|
||||
}
|
||||
const parts = splitMediaName(name);
|
||||
@@ -595,7 +388,7 @@ function buildPreview(node) {
|
||||
const type = parseImageReference(name)?.type ?? "input";
|
||||
video.src = api.apiURL(`/view?${mediaViewQuery({ ...parts, type }, "input")}`);
|
||||
video.load();
|
||||
probeSourceFps(state, name);
|
||||
probeMetadata(state, name);
|
||||
};
|
||||
state.refresh = refresh;
|
||||
reloadButton.addEventListener("click", (event) => {
|
||||
@@ -605,31 +398,23 @@ function buildPreview(node) {
|
||||
});
|
||||
|
||||
video.addEventListener("loadedmetadata", () => {
|
||||
const single = isSingleFrame(state);
|
||||
const bounds = currentBounds(state);
|
||||
if (!single && bounds.end - bounds.start < MIN_TRIM_SECONDS && video.duration >= MIN_TRIM_SECONDS) {
|
||||
writeTrim(state, { start: Math.max(0, bounds.end - MIN_TRIM_SECONDS), end: bounds.end });
|
||||
}
|
||||
video.currentTime = homeTime(state);
|
||||
setReady(state, single
|
||||
? `frame at ${formatTimecode(homeTime(state))}`
|
||||
: `${formatTimecode(currentBounds(state).start)} → ${formatTimecode(currentBounds(state).end)}`);
|
||||
// Quiet source hint: resolution and duration from the loaded metadata.
|
||||
// The card says where the clip is; the stage only names the source on hover.
|
||||
setReady(state, "");
|
||||
const sourceInfo = mediaInfo(null, video);
|
||||
durationLabel.title = sourceInfo ? `Source: ${sourceInfo}` : "";
|
||||
updateTrimFace(state);
|
||||
stage.title = sourceInfo ? `Source: ${sourceInfo}` : "";
|
||||
state.card?.sync();
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
}, { signal: abort.signal });
|
||||
video.addEventListener("error", () => setEmpty(state, "Preview could not load this video"), { signal: abort.signal });
|
||||
|
||||
installTrimDrag(state);
|
||||
installPlayback(state);
|
||||
watchTrimWidget(state, startWidget);
|
||||
watchTrimWidget(state, endWidget);
|
||||
watchFrameWidget(state, frameWidget);
|
||||
watchTrimWidget(state, findWidget(node, "every_nth"));
|
||||
watchTrimWidget(state, findWidget(node, "max_frames"));
|
||||
applyMode(state);
|
||||
startValue.input.addEventListener("change", () => commitTimeInput(state, "start", startValue.input));
|
||||
endValue.input.addEventListener("change", () => commitTimeInput(state, "end", endValue.input));
|
||||
|
||||
const priorVideoCallback = videoWidget.callback;
|
||||
videoWidget.callback = function (...args) {
|
||||
@@ -664,6 +449,11 @@ app.registerExtension({
|
||||
}
|
||||
});
|
||||
});
|
||||
// A wire into a timing input changes what the card can show.
|
||||
chainCallback(nodeType.prototype, "onConnectionsChange", function () {
|
||||
const state = this.__ausbossLoadVideo;
|
||||
if (state) queueMicrotask(() => state.card?.sync());
|
||||
});
|
||||
chainCallback(nodeType.prototype, "onRemoved", function () {
|
||||
const state = this.__ausbossLoadVideo;
|
||||
state?.stopTick?.();
|
||||
|
||||
@@ -13,6 +13,7 @@ import { makeScrubInput } from "../shared/scrub_input.mjs";
|
||||
import { isAppShortcut, keepKeyInField } from "../shared/canvas_passthrough.mjs";
|
||||
import { resetUnknownValues } from "../shared/widget_card_math.mjs";
|
||||
import { boxRowInputs, boxRowsWidget, boxesOf, hostBox, rowsInputName, workflowNodes } from "../shared/lora_box.mjs";
|
||||
import { coreLoraList, syncFileWidgets } from "../shared/lora_file_widgets.mjs";
|
||||
import {
|
||||
SETTINGS_PROPERTY as SWITCHES_PROPERTY, releaseStackGroup, releaseStackRow, renameStackGroup, stackGroupOwners, stackRowOwners,
|
||||
} from "../shared/workflow_switches.mjs";
|
||||
@@ -724,9 +725,47 @@ function commitRows(state, rows, { structural = false, record = true } = {}) {
|
||||
state.node.graph?.setDirtyCanvas(true, true);
|
||||
if (structural) renderRows(state);
|
||||
else updateRowValues(state);
|
||||
syncLoraFiles(state.node);
|
||||
if (record) notifyAusbossChange();
|
||||
}
|
||||
|
||||
// ComfyUI's missing-models list sees a row's file only through a list
|
||||
// widget, so each row that needs a file gets a hidden one
|
||||
// (js/shared/lora_file_widgets.mjs). Rows that come in over a link (from a
|
||||
// box or another node) are not this node's to list.
|
||||
function syncLoraFiles(node) {
|
||||
if (node?.type !== NODE_CLASS) return;
|
||||
const widget = node.widgets?.find((item) => item.name === "loras");
|
||||
if (!widget) return;
|
||||
const fed = node.inputs?.find((item) => item?.name === "loras")?.link != null;
|
||||
syncFileWidgets(node, fed ? [] : parseRows(widget.value), {
|
||||
installed: () => coreLoraList(globalThis.LiteGraph?.registered_node_types?.LoraLoader?.nodeData)
|
||||
?? node.__ausbossLoraState?.available ?? null,
|
||||
hide: hideWidget,
|
||||
onPick: (rowId, name) => pickRowFile(node, rowId, name),
|
||||
});
|
||||
}
|
||||
|
||||
// ComfyUI put another file in a row's hidden list (a replacement picked in
|
||||
// its Issues panel): the row takes that file.
|
||||
function pickRowFile(node, rowId, name) {
|
||||
const widget = node.widgets?.find((item) => item.name === "loras");
|
||||
if (!widget) return;
|
||||
const rows = parseRows(widget.value);
|
||||
const row = rows.find((item) => item.id === rowId);
|
||||
if (!row || row.name === name) return;
|
||||
row.name = name;
|
||||
const state = node.__ausbossLoraState;
|
||||
if (state && !state.disposed && !state.readOnly && state.widget === widget) {
|
||||
commitRows(state, rows, { structural: true });
|
||||
return;
|
||||
}
|
||||
widget.value = serializeRows(rows);
|
||||
node.graph?.setDirtyCanvas(true, true);
|
||||
syncLoraFiles(node);
|
||||
notifyAusbossChange();
|
||||
}
|
||||
|
||||
// A box shows its loader's rows the way the loader does: one strength per
|
||||
// row, or model and CLIP apart.
|
||||
function linked(state) {
|
||||
@@ -3027,6 +3066,7 @@ function syncRows(state) {
|
||||
state.toggleSnapshot = snapshotEnabled(state.rows);
|
||||
renderRows(state);
|
||||
fitNode(state);
|
||||
syncLoraFiles(state.node);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3324,6 +3364,12 @@ app.registerExtension({
|
||||
});
|
||||
chainCallback(nodeType.prototype, "onConfigure", function () {
|
||||
resetUnknownValues(this.widgets, RESET_UNKNOWN);
|
||||
// Now, not later: ComfyUI reads its missing-models list right after
|
||||
// the workflow is restored.
|
||||
syncLoraFiles(this);
|
||||
});
|
||||
chainCallback(nodeType.prototype, "onConnectionsChange", function () {
|
||||
syncLoraFiles(this);
|
||||
});
|
||||
},
|
||||
// A box (subgraph node) shows the rows of a loader inside once they come
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// App mode and the pack's cards. Pure logic, no DOM: tested under node:test.
|
||||
//
|
||||
// App mode is ComfyUI's simple form view of a workflow: a saved list of
|
||||
// fields (extra.linearData.inputs) and a Run button. Each field is a
|
||||
// widget. A node with a card or panel hides its standard widgets and shows
|
||||
// its own controls instead, and App mode reads that hidden flag too, so the
|
||||
// form drew an empty row for every field on such a node.
|
||||
//
|
||||
// While a workflow is in App mode, the widgets its form lists are shown
|
||||
// again; App mode draws its own control for each. Back in the graph they are
|
||||
// hidden again, so the node's face is unchanged. Only listed widgets move.
|
||||
import { hideWidget, isWidgetHidden, showWidget } from "./widget_visibility.mjs";
|
||||
|
||||
export const APP_MODE = "app";
|
||||
|
||||
// "app", "graph" or "builder:..." for the open workflow.
|
||||
export function workflowMode(workflow) {
|
||||
return workflow?.activeMode ?? workflow?.initialMode ?? "graph";
|
||||
}
|
||||
|
||||
// The form's fields as { nodeId, widget } pairs. A field is saved as
|
||||
// [nodeId, widgetName] or [nodeId, widgetName, { description }].
|
||||
export function appFields(linearData) {
|
||||
const inputs = Array.isArray(linearData?.inputs) ? linearData.inputs : [];
|
||||
const fields = [];
|
||||
for (const entry of inputs) {
|
||||
if (!Array.isArray(entry) || entry.length < 2) continue;
|
||||
const [nodeId, widget] = entry;
|
||||
if ((typeof nodeId !== "string" && typeof nodeId !== "number") || typeof widget !== "string") continue;
|
||||
fields.push({ nodeId: String(nodeId), widget });
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
// find(nodeId, widgetName) -> { node, widget } or null
|
||||
// changed(node) is called after a widget on that node changed visibility.
|
||||
export function createAppModeSync({ find, changed = () => {} }) {
|
||||
const lent = new Map(); // widget -> node, shown for the form
|
||||
return function sync(mode, linearData) {
|
||||
if (mode === APP_MODE) {
|
||||
for (const { nodeId, widget: name } of appFields(linearData)) {
|
||||
const found = find(nodeId, name);
|
||||
if (!found?.widget || !isWidgetHidden(found.widget)) continue;
|
||||
showWidget(found.widget);
|
||||
// An explicit false, not a deleted flag: the frontend keeps its own
|
||||
// copy of the hidden state and only hears about a written value.
|
||||
if (found.widget.options) found.widget.options.hidden = false;
|
||||
lent.set(found.widget, found.node);
|
||||
changed(found.node);
|
||||
}
|
||||
return lent.size;
|
||||
}
|
||||
for (const [widget, node] of lent) {
|
||||
if (hideWidget(widget)) changed(node);
|
||||
}
|
||||
lent.clear();
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
@@ -289,3 +289,86 @@ export function repointLinks(text, nodes, groups) {
|
||||
.replace(ARROW_RE, (all, _arrow, id) => (id === undefined ? all : `${all.slice(0, -id.length - 1)}${follow(`#${id}`)}`));
|
||||
return changed ? next : null;
|
||||
}
|
||||
|
||||
// Info card: a small card with a title, rows and small print, chosen from the
|
||||
// note's menu. Its text is the note's ordinary text with one addition: a line
|
||||
// with a | in it is a row, the words before it on the left and the rest on
|
||||
// the right. A row in **bold** is the one to notice and is drawn in teal. The
|
||||
// first line is the card's title; a clock, info, warning, bulb or tick emoji
|
||||
// at its start is drawn as a small icon. A plain callout reads none of this,
|
||||
// so every note written before looks as it did, and a release before this
|
||||
// one shows the card as a plain note with its rows written out.
|
||||
const CARD_ICONS = new Map([
|
||||
["⏱", "clock"], ["⏲", "clock"], ["⏰", "clock"], ["\u{1F552}", "clock"], ["⌛", "clock"], ["⏳", "clock"],
|
||||
["ℹ", "info"], ["⚠", "warning"], ["\u{1F4A1}", "tip"], ["✅", "check"], ["✔", "check"],
|
||||
]);
|
||||
const CARD_ICON_RE = new RegExp(`^(${[...CARD_ICONS.keys()].join("|")})${VS16}?\\s*`, "u");
|
||||
export const CARD_TEMPLATE = [
|
||||
"ℹ️ Title",
|
||||
`${SMALL_MARK}A line of small print under the title.`,
|
||||
"",
|
||||
"Label | value",
|
||||
"**The one to notice | value**",
|
||||
"",
|
||||
`${SMALL_MARK}A note at the bottom.`,
|
||||
].join("\n");
|
||||
|
||||
// Where a row splits: the first | that is not inside a link, or -1.
|
||||
function cellSplit(line) {
|
||||
const masked = line.replace(WORDS_LINK_RE, (all) => " ".repeat(all.length));
|
||||
return masked.indexOf("|");
|
||||
}
|
||||
|
||||
// A row's two sides, or null when the line is not a row. The outer pipes of
|
||||
// a pasted Markdown table row are dropped.
|
||||
export function cardCells(line) {
|
||||
const bare = String(line ?? "").trim().replace(/^\|/, "").replace(/\|$/, "");
|
||||
const at = cellSplit(bare);
|
||||
if (at < 0) return null;
|
||||
let label = bare.slice(0, at).trim();
|
||||
let value = bare.slice(at + 1).trim();
|
||||
if (!label || !value) return null;
|
||||
// **label | value** marks the whole row.
|
||||
if (label.startsWith("**") && !label.slice(2).includes("**") && value.endsWith("**") && !value.slice(0, -2).includes("**")) {
|
||||
label = `${label}**`;
|
||||
value = `**${value}`;
|
||||
}
|
||||
return [label, value];
|
||||
}
|
||||
|
||||
// Text -> blocks of lines. A line is { kind: "title", icon, pieces },
|
||||
// { kind: "row", cells: [pieces, pieces], highlight } or { kind: "text",
|
||||
// pieces }; small print carries `small: true`. A Markdown table's ---|---
|
||||
// line is dropped.
|
||||
export function parseCard(text) {
|
||||
const blocks = [];
|
||||
let lines = [];
|
||||
let first = true;
|
||||
const flush = () => {
|
||||
if (lines.length) blocks.push(lines);
|
||||
lines = [];
|
||||
};
|
||||
for (const raw of String(text ?? "").replace(/\r\n?/g, "\n").split("\n")) {
|
||||
const line = raw.replace(HEADING_RE, "").trim();
|
||||
if (!line) { flush(); continue; }
|
||||
if (/^\|?[\s:|-]*-[\s:|-]*\|?$/.test(line) && line.includes("|")) continue;
|
||||
const small = SMALL_RE.test(raw);
|
||||
const cells = cardCells(line);
|
||||
let item;
|
||||
if (first && !small && !cells) {
|
||||
const icon = CARD_ICON_RE.exec(line);
|
||||
item = { kind: "title", icon: icon ? CARD_ICONS.get(icon[1]) : null, pieces: pieces(icon ? line.slice(icon[0].length) : line) };
|
||||
} else if (cells) {
|
||||
const sides = cells.map((cell) => pieces(cell));
|
||||
const shown = sides.flat().filter((piece) => piece.arrow || piece.text?.trim());
|
||||
item = { kind: "row", cells: sides, highlight: shown.length > 0 && shown.every((piece) => piece.bold) };
|
||||
} else {
|
||||
item = { kind: "text", pieces: pieces(line) };
|
||||
}
|
||||
first = false;
|
||||
if (small) item.small = true;
|
||||
lines.push(item);
|
||||
}
|
||||
flush();
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
// in js/canvas_passthrough/ wires them to the page.
|
||||
|
||||
// The wheel belongs to the panel while it can still scroll that way (a long
|
||||
// text box, a list of rows), or while a text field has the keyboard.
|
||||
// text box, a list of rows). A text box with the cursor in it is no
|
||||
// exception: when it has nothing left to scroll, the wheel zooms the graph,
|
||||
// as it does over ComfyUI's own text boxes.
|
||||
export function canScrollFurther(element, delta, axis = "y") {
|
||||
if (!element || !delta) return false;
|
||||
const horizontal = axis === "x";
|
||||
@@ -25,10 +27,11 @@ export function canScrollFurther(element, delta, axis = "y") {
|
||||
// and the panel's own root? `styleOf` is getComputedStyle, passed in so this
|
||||
// stays testable without a page. `host` is the frontend's wrapper around the
|
||||
// panel: a pointer on the wrapper itself is on nothing inside the panel.
|
||||
export function panelKeepsWheel(target, event, { root, host, styleOf, activeElement }) {
|
||||
// Ctrl + wheel, which is also how a trackpad pinch arrives, always zooms the
|
||||
// graph; left to a scrolling box it would zoom the whole page.
|
||||
export function panelKeepsWheel(target, event, { root, host, styleOf }) {
|
||||
if (event.ctrlKey || event.metaKey) return false;
|
||||
for (let element = target; element && element !== root && element !== host; element = element.parentElement) {
|
||||
const tag = String(element.tagName ?? "").toUpperCase();
|
||||
if ((tag === "TEXTAREA" || tag === "INPUT") && element === activeElement) return true;
|
||||
const style = styleOf(element);
|
||||
const overflow = style?.overflowY;
|
||||
if ((overflow === "auto" || overflow === "scroll") && canScrollFurther(element, event.deltaY)) return true;
|
||||
|
||||
+64
-16
@@ -1,30 +1,78 @@
|
||||
// Read only literal numeric sources. Calculated inputs must remain unknown
|
||||
// until execution; never evaluate an arbitrary upstream graph for a label.
|
||||
export function inputNumber(node, name, fallback) {
|
||||
const input = node.inputs?.find((slot) => slot.name === name || slot.widget?.name === name);
|
||||
if (input?.link == null) return fallback;
|
||||
const graph = node.graph;
|
||||
let linkId = input.link;
|
||||
// A subgraph's output that comes straight from a literal inside it (Person
|
||||
// Swap's "Pick the model files" hands out its video fps that way) counts as
|
||||
// that literal: it is still a typed number, not a calculation.
|
||||
function tableLink(graph, id) {
|
||||
if (id == null || !graph) return null;
|
||||
return graph.getLink?.(id) ?? graph.links?.get?.(id) ?? graph.links?.[id] ?? graph._links?.get?.(id) ?? null;
|
||||
}
|
||||
|
||||
// The link into one of a node's inputs: the frontend's own accessor first
|
||||
// (newer frontends warn on reading input.link), the link table after it.
|
||||
// undefined when nothing is connected.
|
||||
function linkInto(node, index, graph) {
|
||||
if (typeof node?.getInputLink === "function" && node.graph) {
|
||||
try {
|
||||
return node.getInputLink(index) ?? undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
const id = node?.inputs?.[index]?.link;
|
||||
return id == null ? undefined : tableLink(node.graph ?? graph, id);
|
||||
}
|
||||
|
||||
// Where a linked input really comes from: the node and output slot at the
|
||||
// far end, through Reroutes and into a subgraph whose output is wired
|
||||
// straight to a node inside it. null for a muted or bypassed source, a loop,
|
||||
// or a subgraph output with nothing behind it. undefined when the input is
|
||||
// not linked at all.
|
||||
export function linkOrigin(node, name) {
|
||||
const index = node?.inputs?.findIndex((slot) => slot?.name === name || slot?.widget?.name === name) ?? -1;
|
||||
if (index < 0) return undefined;
|
||||
let graph = node.graph;
|
||||
let link = linkInto(node, index, graph);
|
||||
if (link === undefined) return undefined;
|
||||
const seen = new Set();
|
||||
for (let depth = 0; depth < 16; depth++) {
|
||||
if (seen.has(linkId)) return null;
|
||||
seen.add(linkId);
|
||||
const link = graph?.links?.[linkId] ?? graph?._links?.get?.(linkId);
|
||||
const source = graph?.getNodeById?.(link?.origin_id);
|
||||
if (!link || seen.has(link)) return null;
|
||||
seen.add(link);
|
||||
const source = graph?.getNodeById?.(link.origin_id);
|
||||
if (!source || (source.mode ?? 0) !== 0) return null;
|
||||
if (source.type === "Reroute") {
|
||||
linkId = source.inputs?.[0]?.link;
|
||||
if (linkId == null) return null;
|
||||
if ((source.comfyClass ?? source.type) === "Reroute") {
|
||||
link = linkInto(source, 0, graph) ?? null;
|
||||
continue;
|
||||
}
|
||||
if (!["PrimitiveFloat", "PrimitiveInt", "AUSBOSS_NODES_Integer", "AUSBOSS_NODES_Float"].includes(source.type) || link.origin_slot !== 0) return null;
|
||||
if (source.inputs?.some((slot) => slot.name === "value" && slot.link != null)) return null;
|
||||
const value = source.widgets?.find((widget) => widget.name === "value")?.value;
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
const inner = source.subgraph;
|
||||
if (inner && typeof source.isSubgraphNode === "function" && source.isSubgraphNode()) {
|
||||
link = tableLink(inner, inner.outputs?.[link.origin_slot]?.linkIds?.[0]);
|
||||
graph = inner;
|
||||
continue;
|
||||
}
|
||||
return { node: source, slot: link.origin_slot };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const LITERALS = ["PrimitiveFloat", "PrimitiveInt", "AUSBOSS_NODES_Integer", "AUSBOSS_NODES_Float"];
|
||||
|
||||
export function inputNumber(node, name, fallback) {
|
||||
const origin = linkOrigin(node, name);
|
||||
if (origin === undefined) return fallback;
|
||||
if (!origin) return null;
|
||||
const { node: source, slot } = origin;
|
||||
// ComfyUI's older Primitive node holds the value of the widget it feeds.
|
||||
if ((source.comfyClass ?? source.type) === "PrimitiveNode") {
|
||||
const value = source.widgets?.[0]?.value;
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
}
|
||||
if (!LITERALS.includes(source.type) || slot !== 0) return null;
|
||||
if (source.inputs?.some((input) => input.name === "value" && input.link != null)) return null;
|
||||
const value = source.widgets?.find((widget) => widget.name === "value")?.value;
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
}
|
||||
|
||||
export function clipOutputRate(node, sourceFps, everyNth = 1) {
|
||||
const forced = inputNumber(node, "force_rate", 0);
|
||||
const nth = inputNumber(node, "every_nth", everyNth);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { linkOrigin } from "./clip_rate.mjs";
|
||||
|
||||
// The same live-input rule used by the writer timeline: muted/bypassed
|
||||
// sources do not reach this node. This inspects the wire, never media bytes.
|
||||
export function linkSource(node, name) {
|
||||
@@ -9,6 +11,43 @@ export function linkSource(node, name) {
|
||||
return (source?.mode ?? 0) === 0 ? source ?? null : null;
|
||||
}
|
||||
|
||||
// Keep in step with Python video_frames (node_h3_prompt_writer.py): H3 makes
|
||||
// 5 frames plus steps of 17, at most 15 s at 24 fps, rounding a clip down.
|
||||
export const H3_FPS = 24;
|
||||
export function h3VideoFrames(frames) {
|
||||
const count = Math.trunc(Number(frames));
|
||||
if (!(count > 0)) return null;
|
||||
return Math.max(1, Math.floor((Math.min(count, 15 * H3_FPS) - 5) / 17)) * 17 + 5;
|
||||
}
|
||||
|
||||
// What the clip node's face last worked out for its run ({frames,
|
||||
// startSeconds, endSeconds}), or null when the clip is not that node or its
|
||||
// count is only known at run time.
|
||||
export function clipTimingFor(node) {
|
||||
// Through Reroutes and subgraphs, as every linked value is read.
|
||||
const timing = linkOrigin(node, "video")?.node?.__ausbossClipTiming;
|
||||
return timing && timing.frames > 0 ? timing : null;
|
||||
}
|
||||
|
||||
// The words under "From the clip": what H3 will make of the clip's frames.
|
||||
export function clipLengthWords(timing) {
|
||||
if (!timing) return null;
|
||||
const made = h3VideoFrames(timing.frames);
|
||||
const seconds = (frames) => String(Number((frames / H3_FPS).toFixed(2)));
|
||||
if (made < timing.frames) {
|
||||
const up = made + 17;
|
||||
const room = timing.roomFrames ?? Infinity;
|
||||
const stops = timing.startSeconds + made / H3_FPS;
|
||||
return {
|
||||
title: `H3 makes ${made} of the clip's ${timing.frames} frames · ${seconds(made)} s`,
|
||||
note: `Stops at ${String(Number(stops.toFixed(2)))} s in the video. To use all of it, set the clip's Duration to ${seconds(made)} s${up <= Math.min(room, 15 * H3_FPS) ? ` or ${seconds(up)} s` : ""}.`,
|
||||
warn: true,
|
||||
};
|
||||
}
|
||||
if (made === timing.frames) return { title: `H3 uses all ${made} frames · ${seconds(made)} s`, note: "The clip is already a length H3 makes.", warn: false };
|
||||
return { title: `H3 makes ${made} frames · ${seconds(made)} s`, note: `That is its shortest length; the clip has ${timing.frames} frames.`, warn: true };
|
||||
}
|
||||
|
||||
// Keep in step with Python KEEPS_ITS_LENGTH. Other jobs use seconds normally.
|
||||
export function clipSetsDuration(node, values) {
|
||||
return ["swap the person", "new voice", "change something"].includes(values.video_job)
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import { app } from "../../../scripts/app.js";
|
||||
// Must match `version` in pyproject.toml — scripts/release_preflight.py
|
||||
// enforces it. The backend serves its copy at /ausboss/pack_version; a
|
||||
// mismatch means the browser cached JavaScript from an older install.
|
||||
export const AUSBOSS_JS_VERSION = "2.24.0";
|
||||
export const AUSBOSS_JS_VERSION = "2.26.2";
|
||||
|
||||
export const BRAND = "#00b4aa"; // AusBoss teal — keep node accents consistent.
|
||||
export const BRAND_DARK = "#007f78";
|
||||
|
||||
@@ -107,16 +107,59 @@ export function outputRecordQuery(record, index = null) {
|
||||
}).toString();
|
||||
}
|
||||
|
||||
// The /view query of the small copy Save Image writes for its face
|
||||
// ({ ausboss_preview: ["ausboss_preview/<name>.webp"] }, one for each entry
|
||||
// of images, in the temp folder). Null when the record has none: an older
|
||||
// run, another node, or the preview switched off.
|
||||
export function lightPreviewQuery(record, index = null) {
|
||||
const places = record?.ausboss_preview;
|
||||
const count = outputRecordCount(record);
|
||||
if (!count || !Array.isArray(places) || places.length !== count) return null;
|
||||
const at = Number.isInteger(index) && index >= 0 && index < count ? index : count - 1;
|
||||
const place = places[at];
|
||||
if (typeof place !== "string" || !place) return null;
|
||||
const slash = place.lastIndexOf("/");
|
||||
return new URLSearchParams({
|
||||
filename: place.slice(slash + 1),
|
||||
subfolder: slash >= 0 ? place.slice(0, slash) : "",
|
||||
type: "temp",
|
||||
}).toString();
|
||||
}
|
||||
|
||||
// How many pictures the node's last run left in its output record.
|
||||
export function outputRecordCount(record) {
|
||||
return Array.isArray(record?.images) ? record.images.length : 0;
|
||||
}
|
||||
|
||||
// Is node.imgs the picture of this output record?
|
||||
//
|
||||
// The frontend loads a result into node.imgs with a time limit (two tries of
|
||||
// about 8 seconds). A picture that takes longer, a big one over a slow link,
|
||||
// is dropped without a word and node.imgs keeps the run before. `loadedFor`
|
||||
// is the record that was current when node.imgs was last set; the file name
|
||||
// is compared as well, for a newer run that arrived while a picture loaded.
|
||||
export function ownResultIsCurrent(node, record, loadedFor) {
|
||||
const images = node?.imgs;
|
||||
const src = Array.isArray(images) && images.length ? images[images.length - 1]?.src : null;
|
||||
if (typeof src !== "string" || !src) return false;
|
||||
const wanted = outputRecordQuery(record);
|
||||
// No stored picture to compare with, or a frame streamed during the run.
|
||||
if (!wanted || !/[?&]filename=/.test(src)) return true;
|
||||
if (loadedFor !== record) return false;
|
||||
const have = new URLSearchParams(src.slice(src.indexOf("?") + 1));
|
||||
const want = new URLSearchParams(wanted);
|
||||
return ["filename", "subfolder", "type"].every((key) => (have.get(key) ?? "") === (want.get(key) ?? ""));
|
||||
}
|
||||
|
||||
// What the panel shows, best first: this node's result (node.imgs, then the
|
||||
// URL of its stored output), then whatever feeds it, then nothing.
|
||||
export function describeNodePreview(node, inputName, storedUrl = null) {
|
||||
return describeOwnResult(node)
|
||||
?? (storedUrl ? { kind: "url", url: storedUrl } : null)
|
||||
// `ownIsCurrent` false: node.imgs is an older run's (ownResultIsCurrent), so
|
||||
// the stored output goes first.
|
||||
export function describeNodePreview(node, inputName, storedUrl = null, ownIsCurrent = true) {
|
||||
const stored = storedUrl ? { kind: "url", url: storedUrl } : null;
|
||||
return (ownIsCurrent ? null : stored)
|
||||
?? describeOwnResult(node)
|
||||
?? stored
|
||||
?? describeSourcePreview(upstreamNode(node, inputName));
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// what it always was. The turn is made in canvas pixels, so a turned box is a
|
||||
// true rectangle on a canvas of any shape (nodes/_layout_boxes_helpers.py
|
||||
// turns it the same way).
|
||||
import { linkOrigin } from "./clip_rate.mjs";
|
||||
|
||||
export const DIM_MIN = 64;
|
||||
export const DIM_MAX = 16384;
|
||||
@@ -683,8 +684,10 @@ const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
||||
// (Integer, Primitive). Reroutes are followed. Null when the input is not
|
||||
// wired or the value is only known once the workflow runs.
|
||||
export function wiredNumber(node, inputName) {
|
||||
const source = wiredSource(node, inputName);
|
||||
return source ? wiredFrom(source.node, source.slot) : null;
|
||||
// Through Reroutes and into subgraphs (js/shared/clip_rate.mjs), then
|
||||
// this node's own rule for which numbers count.
|
||||
const origin = linkOrigin(node, inputName);
|
||||
return origin ? wiredFrom(origin.node, origin.slot) : null;
|
||||
}
|
||||
|
||||
// The node (and its output slot) an input is wired to, through Reroutes.
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
// The row under the file picker on Load Image: arrows that step through the
|
||||
// input folder, where the file is in the list ("14 / 212"), and the size the
|
||||
// picture goes in at and comes out at ("912 × 1632 → 1144 × 2048"). The
|
||||
// widgets underneath stay the source of truth: an arrow only changes the
|
||||
// image widget's value, the way picking from the list does.
|
||||
//
|
||||
// Under it, the preview: the picture as it goes in with the part that is
|
||||
// kept lit, and the picture as it comes out, both on one scale, with what
|
||||
// the size choice does in words. While the choice cuts something, a click
|
||||
// on the first picture picks the part to keep.
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { CROP_MODES, changeText, cropSideAt, keptPart, placeText, planLoadSize, shapeText, sizeText, stepFile, thumbSizes } from "./load_size.mjs";
|
||||
import { mediaViewQuery } from "./media_list.mjs";
|
||||
import { FONT_UI, RADIUS_CONTROL, THEME as T } from "./theme.mjs";
|
||||
import { commitWidgetValue, comboValues } from "./widget_card_math.mjs";
|
||||
|
||||
const CSS_ID = "ausboss-load-strip-css";
|
||||
// Sizes already read, by file: stepping back to a picture shows its size at once.
|
||||
const SIZES_KEPT = 200;
|
||||
const sizes = new Map();
|
||||
|
||||
function ensureCss() {
|
||||
if (document.getElementById(CSS_ID)) return;
|
||||
const style = document.createElement("style");
|
||||
style.id = CSS_ID;
|
||||
style.textContent = `
|
||||
.ausboss-load-strip{display:flex;align-items:center;gap:6px;height:100%;min-width:0;font:500 11px/1 ${FONT_UI};color:${T.label}}
|
||||
.ausboss-load-step{flex:none;width:26px;height:100%;padding:0;border:1px solid transparent;border-radius:${RADIUS_CONTROL}px;background:${T.fill};color:${T.inkSoft};font:600 11px/1 ${FONT_UI};cursor:pointer}
|
||||
.ausboss-load-step:hover{background:${T.fillHover};color:${T.inkHover}}
|
||||
.ausboss-load-step:focus-visible{outline:2px solid ${T.brand};outline-offset:1px}
|
||||
.ausboss-load-step:disabled{opacity:.4;cursor:default}
|
||||
.ausboss-load-place{flex:none;color:${T.faint};font-variant-numeric:tabular-nums;white-space:nowrap;user-select:none}
|
||||
.ausboss-load-size{flex:1 1 0;min-width:0;overflow:hidden;text-align:right;white-space:nowrap;text-overflow:ellipsis;color:${T.inkSoft};font-weight:600;font-variant-numeric:tabular-nums}
|
||||
.ausboss-load-size b{color:${T.brandInk};font-weight:700}
|
||||
.ausboss-load-size i{color:${T.faint};font-style:normal;margin:0 5px}
|
||||
.ausboss-load-view{display:flex;align-items:center;justify-content:center;gap:10px;height:100%;min-width:0;font:500 10px/1.25 ${FONT_UI};color:${T.faint}}
|
||||
.ausboss-load-thumb{position:relative;flex:none;overflow:hidden;border-radius:2px;background-color:${T.fill};background-repeat:no-repeat}
|
||||
.ausboss-load-thumb.in{background-size:100% 100%}
|
||||
.ausboss-load-thumb.in.pick{cursor:pointer}
|
||||
.ausboss-load-thumb.out{outline:1px solid ${T.brand};outline-offset:0}
|
||||
.ausboss-load-kept{position:absolute;box-sizing:border-box;border:1px solid ${T.brand};box-shadow:0 0 0 400px rgba(8,10,11,.68);pointer-events:none}
|
||||
.ausboss-load-note{flex:0 1 auto;min-width:0;display:flex;flex-direction:column;align-items:center;gap:2px;text-align:center;user-select:none}
|
||||
.ausboss-load-note b{color:${T.inkSoft};font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}
|
||||
.ausboss-load-note span{white-space:nowrap}
|
||||
`;
|
||||
document.head.append(style);
|
||||
}
|
||||
|
||||
const viewUrl = (value) => api.apiURL(`/view?${mediaViewQuery(value)}`);
|
||||
|
||||
// The picture's own size, read from the file the way the browser shows it.
|
||||
function readSize(file, done) {
|
||||
const known = sizes.get(file);
|
||||
if (known) return known;
|
||||
const picture = new Image();
|
||||
picture.onload = () => {
|
||||
if (sizes.size >= SIZES_KEPT) sizes.delete(sizes.keys().next().value);
|
||||
sizes.set(file, { width: picture.naturalWidth, height: picture.naturalHeight });
|
||||
done();
|
||||
};
|
||||
picture.src = viewUrl(file);
|
||||
return null;
|
||||
}
|
||||
|
||||
// The widest and tallest a preview picture is drawn.
|
||||
const THUMB_WIDTH = 76;
|
||||
const THUMB_HEIGHT = 68;
|
||||
|
||||
export function loadImagePreview(node) {
|
||||
ensureCss();
|
||||
const root = document.createElement("div");
|
||||
root.className = "ausboss-load-view";
|
||||
const input = document.createElement("div");
|
||||
input.className = "ausboss-load-thumb in";
|
||||
const kept = document.createElement("div");
|
||||
kept.className = "ausboss-load-kept";
|
||||
input.append(kept);
|
||||
const note = document.createElement("div");
|
||||
note.className = "ausboss-load-note";
|
||||
const output = document.createElement("div");
|
||||
output.className = "ausboss-load-thumb out";
|
||||
root.append(input, note, output);
|
||||
let last = {};
|
||||
|
||||
const side = () => node.widgets?.find((item) => item.name === "crop_from") ?? null;
|
||||
const sideLinked = () => node.inputs?.find((slot) => slot?.widget?.name === "crop_from")?.link != null;
|
||||
input.addEventListener("click", (event) => {
|
||||
const widget = side();
|
||||
if (!widget || !input.classList.contains("pick")) return;
|
||||
const box = input.getBoundingClientRect();
|
||||
if (!(box.width > 0 && box.height > 0)) return;
|
||||
const next = cropSideAt((event.clientX - box.left) / box.width, (event.clientY - box.top) / box.height);
|
||||
if (next === widget.value) return;
|
||||
commitWidgetValue(node, widget, next, app.canvas);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
});
|
||||
|
||||
const line = (tag, text) => {
|
||||
const item = document.createElement(tag);
|
||||
item.textContent = text;
|
||||
return item;
|
||||
};
|
||||
const sync = (values = last) => {
|
||||
last = values;
|
||||
const file = String(values.image ?? "");
|
||||
const source = file ? readSize(file, () => { if (String(last.image ?? "") === file) sync(); }) : null;
|
||||
const plan = source ? planLoadSize(source.width, source.height, values) : null;
|
||||
root.style.visibility = plan ? "" : "hidden";
|
||||
if (!plan) return;
|
||||
const picture = `url(${JSON.stringify(viewUrl(file))})`;
|
||||
const sizes = thumbSizes(source.width, source.height, plan, THUMB_WIDTH, THUMB_HEIGHT);
|
||||
const part = keptPart(plan);
|
||||
Object.assign(input.style, { width: `${sizes.input[0]}px`, height: `${sizes.input[1]}px`, backgroundImage: picture });
|
||||
Object.assign(kept.style, {
|
||||
left: `${part.x * 100}%`, top: `${part.y * 100}%`,
|
||||
width: `${part.width * 100}%`, height: `${part.height * 100}%`,
|
||||
});
|
||||
const spareWide = plan.resizeWidth - plan.width;
|
||||
const spareHigh = plan.resizeHeight - plan.height;
|
||||
Object.assign(output.style, {
|
||||
width: `${sizes.output[0]}px`, height: `${sizes.output[1]}px`, backgroundImage: picture,
|
||||
backgroundSize: `${(plan.resizeWidth / plan.width) * 100}% ${(plan.resizeHeight / plan.height) * 100}%`,
|
||||
backgroundPosition: `${spareWide > 0 ? (plan.cropX / spareWide) * 100 : 0}% ${spareHigh > 0 ? (plan.cropY / spareHigh) * 100 : 0}%`,
|
||||
});
|
||||
const picks = CROP_MODES.includes(values.size) && !sideLinked();
|
||||
input.classList.toggle("pick", picks);
|
||||
input.title = picks
|
||||
? "The picture going in. The lit part is kept. Click the part you want to keep."
|
||||
: "The picture going in. The lit part is kept.";
|
||||
output.title = "The picture coming out.";
|
||||
const from = shapeText(source.width, source.height);
|
||||
const to = shapeText(plan.width, plan.height);
|
||||
const change = changeText(source.width, source.height, plan);
|
||||
note.replaceChildren(
|
||||
line("b", from === to ? from : `${from} → ${to}`),
|
||||
...(change ? change.split(" · ").map((text) => line("span", text)) : [line("span", "no change")]),
|
||||
);
|
||||
};
|
||||
return { element: root, sync };
|
||||
}
|
||||
|
||||
export function loadImageStrip(node) {
|
||||
ensureCss();
|
||||
const root = document.createElement("div");
|
||||
root.className = "ausboss-load-strip";
|
||||
const widget = () => node.widgets?.find((item) => item.name === "image") ?? null;
|
||||
const linked = () => {
|
||||
const slot = node.inputs?.find((input) => input?.widget?.name === "image" || input?.name === "image");
|
||||
return slot?.link != null;
|
||||
};
|
||||
let last = {};
|
||||
|
||||
const step = (delta, label, title) => {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.className = "ausboss-load-step";
|
||||
button.textContent = label;
|
||||
button.title = title;
|
||||
button.addEventListener("click", () => {
|
||||
const image = widget();
|
||||
if (!image) return;
|
||||
const next = stepFile(comboValues(image), image.value, delta);
|
||||
if (next === null || next === image.value) return;
|
||||
commitWidgetValue(node, image, next, app.canvas);
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
});
|
||||
root.append(button);
|
||||
return button;
|
||||
};
|
||||
const back = step(-1, "◀", "The picture before this one in the input folder");
|
||||
const on = step(1, "▶", "The next picture in the input folder");
|
||||
const place = document.createElement("span");
|
||||
place.className = "ausboss-load-place";
|
||||
place.title = "Where this picture is in the input folder's list";
|
||||
const size = document.createElement("span");
|
||||
size.className = "ausboss-load-size";
|
||||
root.append(place, size);
|
||||
|
||||
const sync = (values = last) => {
|
||||
last = values;
|
||||
const image = widget();
|
||||
const files = comboValues(image);
|
||||
const file = String(values.image ?? "");
|
||||
place.textContent = placeText(files, file);
|
||||
const stuck = linked() || stepFile(files, file, 1) === null;
|
||||
back.disabled = stuck;
|
||||
on.disabled = stuck;
|
||||
const source = file ? readSize(file, () => { if (String(last.image ?? "") === file) sync(); }) : null;
|
||||
size.replaceChildren();
|
||||
if (!source) {
|
||||
size.title = "";
|
||||
return;
|
||||
}
|
||||
const plan = planLoadSize(source.width, source.height, values);
|
||||
const text = sizeText(source.width, source.height, plan);
|
||||
const [from, to] = text.split(" → ");
|
||||
size.append(from);
|
||||
if (to) {
|
||||
const arrow = document.createElement("i");
|
||||
arrow.textContent = "→";
|
||||
const out = document.createElement("b");
|
||||
out.textContent = to;
|
||||
size.append(arrow, out);
|
||||
}
|
||||
size.title = to
|
||||
? `The file is ${from}. The picture comes out at ${to}.`
|
||||
: `The picture comes out at its own size, ${from}.`;
|
||||
};
|
||||
return { element: root, sync };
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
// Load Image: the size a picture comes out at, worked out in the browser so
|
||||
// the node can show it before a run. This repeats plan_load_size in
|
||||
// nodes/_load_image_helpers.py; tests/fixtures/load_size_cases.json holds
|
||||
// both to the same answers. No DOM in here.
|
||||
|
||||
export const SIZE_MODES = Object.freeze(["off", "megapixels", "longest side", "scale", "fit inside", "crop to fill", "crop", "crop to ratio"]);
|
||||
// Which part of the picture a crop keeps, as a 3 x 3 grid read row by row.
|
||||
export const CROP_GRID = Object.freeze(["top left", "top", "top right", "left", "center", "right", "bottom left", "bottom", "bottom right"]);
|
||||
// The choices that cut something off, so the kept part matters.
|
||||
export const CROP_MODES = Object.freeze(["crop to fill", "crop", "crop to ratio"]);
|
||||
|
||||
const roundHalfUp = (value) => Math.floor(value + 0.5);
|
||||
const whole = (value, fallback) => (Number.isFinite(Number(value)) ? Math.trunc(Number(value)) : fallback);
|
||||
// Nearest multiple, never below one step.
|
||||
const nearest = (value, step) => Math.max(step, roundHalfUp(value / step) * step);
|
||||
// The largest multiple that is not above the value, never below one step.
|
||||
const below = (value, step) => Math.max(step, Math.floor(value / step) * step);
|
||||
// Rounded down to a multiple, or left alone when smaller than one step.
|
||||
const inside = (value, step) => (value >= step ? Math.floor(value / step) * step : value);
|
||||
// Where a cut starts along one edge with `spare` pixels to lose.
|
||||
const cropStart = (spare, side, low, high) => (side.includes(low) ? 0 : side.includes(high) ? spare : Math.floor(spare / 2));
|
||||
|
||||
function ratioTerms(ratio, width, height) {
|
||||
if (ratio === "width : height") return [Math.max(1, width), Math.max(1, height)];
|
||||
const [across, down] = String(ratio ?? "1:1").split(":").map((term) => Math.trunc(Number(term)));
|
||||
return [Math.max(1, across || 1), Math.max(1, down || 1)];
|
||||
}
|
||||
|
||||
function target(sourceW, sourceH, size, { megapixels, longest_side: longestSide, scale, width, height }) {
|
||||
const scaled = (factor) => [Math.max(1, roundHalfUp(sourceW * factor)), Math.max(1, roundHalfUp(sourceH * factor))];
|
||||
if (size === "megapixels") {
|
||||
const amount = Number(megapixels);
|
||||
return amount > 0 ? scaled(Math.sqrt((amount * 1e6) / (sourceW * sourceH))) : [sourceW, sourceH];
|
||||
}
|
||||
if (size === "longest side") {
|
||||
const edge = whole(longestSide, 0);
|
||||
if (edge <= 0) return [sourceW, sourceH];
|
||||
const [w, h] = scaled(edge / Math.max(sourceW, sourceH));
|
||||
return sourceW >= sourceH ? [edge, h] : [w, edge];
|
||||
}
|
||||
if (size === "scale") {
|
||||
const factor = Number(scale);
|
||||
return factor > 0 ? scaled(factor) : [sourceW, sourceH];
|
||||
}
|
||||
const fit = Math.min(Math.max(1, whole(width, 1)) / sourceW, Math.max(1, whole(height, 1)) / sourceH);
|
||||
return scaled(fit);
|
||||
}
|
||||
|
||||
// { resizeWidth, resizeHeight, cropX, cropY, width, height } for a picture of
|
||||
// sourceWidth x sourceHeight and the node's values, or null when the picture
|
||||
// has no size yet or the choice is not one the node knows.
|
||||
export function planLoadSize(sourceWidth, sourceHeight, values = {}) {
|
||||
const sourceW = whole(sourceWidth, 0);
|
||||
const sourceH = whole(sourceHeight, 0);
|
||||
const size = values.size ?? "off";
|
||||
if (sourceW <= 0 || sourceH <= 0 || !SIZE_MODES.includes(size)) return null;
|
||||
const same = { resizeWidth: sourceW, resizeHeight: sourceH, cropX: 0, cropY: 0, width: sourceW, height: sourceH };
|
||||
if (size === "off") return same;
|
||||
const step = Math.max(1, whole(values.multiple, 1));
|
||||
const enlarge = values.enlarge !== false;
|
||||
const boxW = Math.max(1, whole(values.width, 1024));
|
||||
const boxH = Math.max(1, whole(values.height, 1024));
|
||||
const side = CROP_GRID.includes(values.crop_from) ? values.crop_from : "center";
|
||||
const cut = (resizeWidth, resizeHeight, width, height) => ({
|
||||
resizeWidth, resizeHeight,
|
||||
cropX: cropStart(resizeWidth - width, side, "left", "right"),
|
||||
cropY: cropStart(resizeHeight - height, side, "top", "bottom"),
|
||||
width, height,
|
||||
});
|
||||
|
||||
if (size === "crop") {
|
||||
return cut(sourceW, sourceH, inside(Math.min(boxW, sourceW), step), inside(Math.min(boxH, sourceH), step));
|
||||
}
|
||||
|
||||
if (size === "crop to ratio") {
|
||||
const [across, down] = ratioTerms(values.ratio, boxW, boxH);
|
||||
let width = sourceW;
|
||||
let height = sourceH;
|
||||
if (sourceW * down >= sourceH * across) width = Math.min(sourceW, Math.max(1, roundHalfUp((sourceH * across) / down)));
|
||||
else height = Math.min(sourceH, Math.max(1, roundHalfUp((sourceW * down) / across)));
|
||||
return cut(sourceW, sourceH, inside(width, step), inside(height, step));
|
||||
}
|
||||
|
||||
if (size === "crop to fill") {
|
||||
let width = boxW;
|
||||
let height = boxH;
|
||||
if (enlarge) {
|
||||
width = nearest(width, step);
|
||||
height = nearest(height, step);
|
||||
} else {
|
||||
const grow = Math.max(width / sourceW, height / sourceH);
|
||||
if (grow > 1) {
|
||||
width = Math.max(1, Math.floor(width / grow + 1e-6));
|
||||
height = Math.max(1, Math.floor(height / grow + 1e-6));
|
||||
}
|
||||
width = Math.min(below(width, step), Math.max(step, sourceW));
|
||||
height = Math.min(below(height, step), Math.max(step, sourceH));
|
||||
}
|
||||
const cover = Math.max(width / sourceW, height / sourceH);
|
||||
const resizeWidth = Math.max(width, Math.ceil(sourceW * cover - 1e-6));
|
||||
const resizeHeight = Math.max(height, Math.ceil(sourceH * cover - 1e-6));
|
||||
return cut(resizeWidth, resizeHeight, width, height);
|
||||
}
|
||||
|
||||
let [targetW, targetH] = target(sourceW, sourceH, size, { ...values, width: boxW, height: boxH });
|
||||
if (!enlarge && (targetW > sourceW || targetH > sourceH)) [targetW, targetH] = [sourceW, sourceH];
|
||||
const rounded = (wanted, source, box) => {
|
||||
let value = nearest(wanted, step);
|
||||
if (size === "fit inside" && value > box) value = below(box, step);
|
||||
if (!enlarge && value > source) value = below(source, step);
|
||||
return value;
|
||||
};
|
||||
const width = rounded(targetW, sourceW, boxW);
|
||||
const height = rounded(targetH, sourceH, boxH);
|
||||
return { resizeWidth: width, resizeHeight: height, cropX: 0, cropY: 0, width, height };
|
||||
}
|
||||
|
||||
// "912 × 1632" for a picture that comes out as it went in, "912 × 1632 →
|
||||
// 1144 × 2048" when its size changes, "" while the picture's size is unknown.
|
||||
export function sizeText(sourceWidth, sourceHeight, plan) {
|
||||
if (!(sourceWidth > 0 && sourceHeight > 0)) return "";
|
||||
const from = `${sourceWidth} × ${sourceHeight}`;
|
||||
if (!plan || (plan.width === sourceWidth && plan.height === sourceHeight)) return from;
|
||||
return `${from} → ${plan.width} × ${plan.height}`;
|
||||
}
|
||||
|
||||
// What a plan does to the picture, in a few words for the node: how much it
|
||||
// is resized and how much is cut off, in the file's own pixels. "" when the
|
||||
// picture comes out as it went in.
|
||||
export function changeText(sourceWidth, sourceHeight, plan) {
|
||||
if (!plan || !(sourceWidth > 0 && sourceHeight > 0)) return "";
|
||||
const parts = [];
|
||||
const percent = Math.round((plan.resizeWidth / sourceWidth) * 100);
|
||||
if (plan.resizeWidth !== sourceWidth || plan.resizeHeight !== sourceHeight) parts.push(`${percent}% size`);
|
||||
const cutWide = Math.round(((plan.resizeWidth - plan.width) * sourceWidth) / plan.resizeWidth);
|
||||
const cutHigh = Math.round(((plan.resizeHeight - plan.height) * sourceHeight) / plan.resizeHeight);
|
||||
if (cutWide > 0 && cutHigh > 0) parts.push(`cuts ${cutWide} × ${cutHigh} px`);
|
||||
else if (cutWide > 0) parts.push(`cuts ${cutWide} px of width`);
|
||||
else if (cutHigh > 0) parts.push(`cuts ${cutHigh} px of height`);
|
||||
return parts.join(" · ");
|
||||
}
|
||||
|
||||
const SHAPES = [[1, 1], [5, 4], [4, 3], [3, 2], [16, 10], [16, 9], [2, 1], [21, 9]];
|
||||
|
||||
// A picture's shape in words people use: "3:4", "16:9". A size within one
|
||||
// percent of a common shape gets that name (rounding to a multiple moves a
|
||||
// 16:9 picture a few pixels off it); any other gets "~1.34:1" or "~1:1.34".
|
||||
export function shapeText(width, height) {
|
||||
if (!(width > 0 && height > 0)) return "";
|
||||
const wide = width >= height;
|
||||
const value = wide ? width / height : height / width;
|
||||
const near = SHAPES.find(([across, down]) => Math.abs(value - across / down) <= (across / down) * 0.01);
|
||||
if (near) return wide ? `${near[0]}:${near[1]}` : `${near[1]}:${near[0]}`;
|
||||
const rounded = Math.round(value * 100) / 100;
|
||||
return wide ? `~${rounded}:1` : `~1:${rounded}`;
|
||||
}
|
||||
|
||||
// The part of the file a plan keeps, as fractions of the file's width and
|
||||
// height: { x, y, width, height }, all 0 to 1.
|
||||
export function keptPart(plan) {
|
||||
if (!plan) return { x: 0, y: 0, width: 1, height: 1 };
|
||||
return {
|
||||
x: plan.cropX / plan.resizeWidth,
|
||||
y: plan.cropY / plan.resizeHeight,
|
||||
width: Math.min(1, plan.width / plan.resizeWidth),
|
||||
height: Math.min(1, plan.height / plan.resizeHeight),
|
||||
};
|
||||
}
|
||||
|
||||
// The sizes two small pictures are drawn at so their difference shows: both
|
||||
// on one scale, the larger filling a box of maxWidth x maxHeight, and neither
|
||||
// edge under `least` pixels.
|
||||
export function thumbSizes(sourceWidth, sourceHeight, plan, maxWidth, maxHeight, least = 10) {
|
||||
const outW = plan?.width ?? sourceWidth;
|
||||
const outH = plan?.height ?? sourceHeight;
|
||||
const scale = Math.min(maxWidth / Math.max(sourceWidth, outW), maxHeight / Math.max(sourceHeight, outH));
|
||||
const at = (value) => Math.max(least, Math.round(value * scale));
|
||||
return { input: [at(sourceWidth), at(sourceHeight)], output: [at(outW), at(outH)] };
|
||||
}
|
||||
|
||||
// The crop side under a click at (x, y), each 0 to 1 across the picture.
|
||||
export function cropSideAt(x, y) {
|
||||
const third = (value) => (value < 1 / 3 ? 0 : value < 2 / 3 ? 1 : 2);
|
||||
return CROP_GRID[third(y) * 3 + third(x)];
|
||||
}
|
||||
|
||||
// The file one step before or after the current one in the list, going
|
||||
// round at the ends. A file that is not in the list steps to the first or
|
||||
// the last. null when the list has nothing to step to.
|
||||
export function stepFile(files, current, delta) {
|
||||
const list = (Array.isArray(files) ? files : []).filter((name) => name !== "" && name != null);
|
||||
if (!list.length) return null;
|
||||
const at = list.indexOf(current);
|
||||
if (at < 0) return delta < 0 ? list[list.length - 1] : list[0];
|
||||
if (list.length === 1) return null;
|
||||
return list[(at + (delta < 0 ? -1 : 1) + list.length) % list.length];
|
||||
}
|
||||
|
||||
// "14 / 212": where the current file is in the list. "" for an empty list,
|
||||
// "– / 212" for a file that is not in it.
|
||||
export function placeText(files, current) {
|
||||
const list = (Array.isArray(files) ? files : []).filter((name) => name !== "" && name != null);
|
||||
if (!list.length) return "";
|
||||
const at = list.indexOf(current);
|
||||
return `${at < 0 ? "–" : at + 1} / ${list.length}`;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// ComfyUI's missing-models list (the Issues panel, "Download all") only
|
||||
// looks at list widgets: a model is listed when a list on some node holds a
|
||||
// file name that is not one of its choices. LoRA Loader keeps its files in
|
||||
// the rows' text, so a LoRA a workflow needs never made that list, and
|
||||
// "Download all" then Run stopped on "missing LoRA file".
|
||||
//
|
||||
// The loader therefore carries one hidden list widget per row that needs a
|
||||
// file. Nothing else reads them: they are kept out of the saved workflow and
|
||||
// the prompt, have no socket, and are made again from the rows every time.
|
||||
// The rows stay the one source of truth.
|
||||
|
||||
import { resolveLoraName } from "./lora_stack.mjs";
|
||||
|
||||
export const FILE_WIDGET_PREFIX = "ausboss_lora_file_";
|
||||
export const FILE_WIDGET_FLAG = "ausbossLoraFile";
|
||||
|
||||
// Rows the server needs a file for when it runs: named, on, in a group that
|
||||
// is on, and not at zero strength (nodes/_lora_helpers.py, missing_lora_rows).
|
||||
export function rowsNeedingFiles(rows) {
|
||||
return (Array.isArray(rows) ? rows : []).filter((row) => {
|
||||
const name = typeof row?.name === "string" ? row.name.trim() : "";
|
||||
if (!name || row.enabled === false || row.group_off === true) return false;
|
||||
const strength = Number(row.strength ?? 1);
|
||||
const clip = Number(row.strength_clip ?? strength);
|
||||
return !(strength === 0 && clip === 0);
|
||||
});
|
||||
}
|
||||
|
||||
// The list ComfyUI checks a row's file against. A file the loader would
|
||||
// find anyway (saved in another folder, or with other capitals) counts as
|
||||
// installed; so does every file while the install's list is unknown, so a
|
||||
// slow list never shows a false alarm.
|
||||
export function fileChoices(name, installed) {
|
||||
if (!Array.isArray(installed)) return [name];
|
||||
return resolveLoraName(name, installed).status === "missing" ? installed : [...installed, name];
|
||||
}
|
||||
|
||||
// The install's LoRA files as ComfyUI's own LoRA loader lists them. The node
|
||||
// list arrives before any workflow opens, so this answers at once; null when
|
||||
// there is no such node to ask.
|
||||
export function coreLoraList(definition) {
|
||||
const spec = definition?.input?.required?.lora_name;
|
||||
if (!Array.isArray(spec)) return null;
|
||||
if (Array.isArray(spec[0])) return spec[0];
|
||||
if (spec[0] === "COMBO" && Array.isArray(spec[1]?.options)) return spec[1].options;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isFileWidget(widget) {
|
||||
return Boolean(widget?.[FILE_WIDGET_FLAG]);
|
||||
}
|
||||
|
||||
// Bring the node's file widgets in line with its rows. `installed()` returns
|
||||
// the install's files (or null), `hide(widget)` folds a widget away, and
|
||||
// `onPick(rowId, name)` runs when ComfyUI puts another file in a widget
|
||||
// (choosing a replacement in the Issues panel). Returns true when a widget
|
||||
// was added or removed.
|
||||
export function syncFileWidgets(node, rows, { installed, hide, onPick }) {
|
||||
if (!node || !Array.isArray(node.widgets)) return false;
|
||||
const needed = rowsNeedingFiles(rows);
|
||||
const current = node.widgets.filter(isFileWidget);
|
||||
let changed = false;
|
||||
needed.forEach((row, index) => {
|
||||
let widget = current[index];
|
||||
if (!widget) {
|
||||
widget = node.addWidget("combo", `${FILE_WIDGET_PREFIX}${index + 1}`, row.name, (value) => {
|
||||
if (typeof value === "string" && value !== widget.ausbossRowName) onPick?.(widget.ausbossRowId, value);
|
||||
}, { values: () => fileChoices(widget.value, installed?.()), serialize: false });
|
||||
widget[FILE_WIDGET_FLAG] = true;
|
||||
widget.serialize = false;
|
||||
hide?.(widget);
|
||||
changed = true;
|
||||
}
|
||||
widget.value = row.name;
|
||||
widget.ausbossRowName = row.name;
|
||||
widget.ausbossRowId = row.id;
|
||||
});
|
||||
for (const widget of current.slice(needed.length)) {
|
||||
if (typeof node.removeWidget === "function") node.removeWidget(widget);
|
||||
else {
|
||||
const at = node.widgets.indexOf(widget);
|
||||
if (at >= 0) node.widgets.splice(at, 1);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// bar as long as the clip, with the cuts as marks. The server reads the script with the same code a run uses,
|
||||
// so the bar shows what will happen. It also colours the script box, so the
|
||||
// words the node reads as instructions (@1, 3s:, a cut) stand out.
|
||||
import { clipSetsDuration, linkSource } from "./h3_duration.mjs";
|
||||
import { clipLengthWords, clipSetsDuration, clipTimingFor, linkSource } from "./h3_duration.mjs";
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { BRAND, chainCallback } from "./index.mjs";
|
||||
@@ -290,12 +290,15 @@ export function momentStrip(node) {
|
||||
asked += 1;
|
||||
ruler.textContent = "";
|
||||
track.textContent = "";
|
||||
const message = el("ausboss-strip-words", "Length comes from the clip");
|
||||
// Say what H3 will make of the clip's frames, when the clip node knows
|
||||
// its count; it rounds down to 5 + 17n, so a 48-frame clip gives 39.
|
||||
const words = clipLengthWords(clipTimingFor(node));
|
||||
const message = el("ausboss-strip-words", words?.title ?? "Length comes from the clip");
|
||||
message.style.cssText = "display:flex;align-items:center;height:100%";
|
||||
track.append(message);
|
||||
note.textContent = "Set the clip's length upstream. Timing controls are unavailable here.";
|
||||
note.textContent = words?.note ?? "Set the clip's length on the clip node. H3 makes 5 + 17n frames (22, 39, 56 ...), rounding the clip down.";
|
||||
note.title = note.textContent;
|
||||
note.classList.remove("warn");
|
||||
note.classList.toggle("warn", Boolean(words?.warn));
|
||||
return;
|
||||
}
|
||||
if (wired(node, "script")) {
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
// 2.0 draws each node as an element on the page, which can run past those
|
||||
// bounds (its frame, a footer), so there the element itself is measured.
|
||||
// Groups are drawn on the canvas in both looks.
|
||||
//
|
||||
// A frameless tile (a link tile, a title, a note tile) draws only a card
|
||||
// inside a transparent node, so what people see is the card, not the node's
|
||||
// bounds. Such a node names that card as `ausbossOutlineElement`, and its
|
||||
// outline is the card's, in both looks.
|
||||
|
||||
function graphRectOf(element, canvas) {
|
||||
const box = element.getBoundingClientRect();
|
||||
@@ -34,6 +39,11 @@ export function nodeElements() {
|
||||
}
|
||||
|
||||
export function outlineOf(item, canvas, { node = true, elements = null } = {}) {
|
||||
const face = node && !item?.flags?.collapsed ? item?.ausbossOutlineElement : null;
|
||||
if (face?.isConnected && canvas?.canvas && canvas.ds) {
|
||||
const rect = graphRectOf(face, canvas);
|
||||
if (rect) return rect;
|
||||
}
|
||||
if (node && globalThis.LiteGraph?.vueNodesMode === true && item?.id != null && canvas?.canvas && canvas.ds) {
|
||||
const element = elements
|
||||
? elements.get(String(item.id))
|
||||
|
||||
@@ -25,7 +25,11 @@ export function ensurePanelControls() {
|
||||
.ausboss-panel-switch i::after{content:"";position:absolute;top:2px;left:2px;width:9px;height:9px;border-radius:50%;background:${T.inkSoft}}
|
||||
.ausboss-panel-switch[aria-checked=true] i{background:${T.brand}}
|
||||
.ausboss-panel-switch[aria-checked=true] i::after{left:13px;background:${T.inkHover}}
|
||||
.ausboss-compact-action:focus-visible,.ausboss-panel-switch:focus-visible{outline:2px solid ${T.brand};outline-offset:1px}
|
||||
.ausboss-primary-action{box-sizing:border-box;flex:none;height:22px;min-width:24px;padding:0 14px;border:0;border-radius:${RADIUS_XS}px;background:${T.brand};color:${T.onBrand};font:700 11px/1 ${controlFont};white-space:nowrap;cursor:pointer;pointer-events:auto}
|
||||
.ausboss-primary-action:hover:enabled{filter:brightness(1.12)}
|
||||
.ausboss-primary-action.quiet{background:${T.fill};color:${T.inkSoft}}
|
||||
.ausboss-primary-action:disabled{opacity:.6;cursor:default}
|
||||
.ausboss-compact-action:focus-visible,.ausboss-primary-action:focus-visible,.ausboss-panel-switch:focus-visible{outline:2px solid ${T.brand};outline-offset:1px}
|
||||
`;
|
||||
document.head.append(style);
|
||||
}
|
||||
@@ -40,6 +44,19 @@ export function compactAction(label, title = "") {
|
||||
return button;
|
||||
}
|
||||
|
||||
// The one thing a panel wants done next, as a solid button: Save Image's
|
||||
// "Save picture" over a picture that is not saved yet. `quiet` (a class the
|
||||
// panel sets) is the same button once it has nothing left to do.
|
||||
export function primaryAction(label, title = "") {
|
||||
ensurePanelControls();
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.className = "ausboss-primary-action";
|
||||
button.textContent = label;
|
||||
button.title = title;
|
||||
return button;
|
||||
}
|
||||
|
||||
export function panelSwitch(label, title) {
|
||||
ensurePanelControls();
|
||||
const button = document.createElement("button");
|
||||
|
||||
@@ -69,3 +69,25 @@ export function heldPlaces(record) {
|
||||
});
|
||||
return held.length && held.every(Boolean) ? held : [];
|
||||
}
|
||||
|
||||
// What the row over held pictures says, and what its button does.
|
||||
// held how many pictures the node holds
|
||||
// kept how many of them are saved already
|
||||
// all a click keeps every picture (one picture, the grid, preview off)
|
||||
// done nothing is left to keep where the click would act
|
||||
// saving a save is on its way
|
||||
// name the file a single picture was saved as, when known
|
||||
// `quiet` is the button once it has nothing left to do.
|
||||
export function keepWords({ held = 0, kept = 0, all = true, done = false, saving = false, name = "" } = {}) {
|
||||
const note = !kept
|
||||
? "Not saved yet"
|
||||
: held < 2
|
||||
? (name ? `Saved as ${name}` : "Saved")
|
||||
: kept >= held ? `All ${held} saved` : `${kept} of ${held} saved`;
|
||||
if (saving) return { note, button: "Saving...", quiet: false };
|
||||
if (done) return { note, button: "Saved", quiet: true };
|
||||
const button = held < 2
|
||||
? "Save picture"
|
||||
: !all ? "Save this one" : kept ? "Save the rest" : `Save all ${held}`;
|
||||
return { note, button, quiet: false };
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ export const SOURCE_LOADERS = Object.freeze({
|
||||
LoadImageOutput: picture("image"),
|
||||
LoadVideo: video("file"),
|
||||
AUSBOSS_NODES_ImageCropRotatePad: picture("image"),
|
||||
AUSBOSS_NODES_LoadImage: picture("image"),
|
||||
// A wired source_image replaces the file, so the file may stay blank.
|
||||
AUSBOSS_NODES_LoadImagePad: (inputs) => (linked(inputs?.source_image) ? null : picture("image")(inputs)),
|
||||
AUSBOSS_NODES_LoadAudio: sound("audio"),
|
||||
|
||||
@@ -28,11 +28,15 @@ export function setTileFace(node, root, enabled, onEdit) {
|
||||
});
|
||||
}
|
||||
const listeners = new AbortController();
|
||||
// Snap into line and Line up use the card people see, not the
|
||||
// transparent node around it (js/shared/outline.mjs).
|
||||
node.ausbossOutlineElement = root.querySelector(".ausboss-callout-card,.ausboss-note-card") || root;
|
||||
installTileDrag(node, root, listeners.signal, onEdit);
|
||||
installTileResize(node, root, listeners.signal);
|
||||
originalDescriptors.set(node, { descriptors, listeners });
|
||||
} else {
|
||||
previous.listeners.abort();
|
||||
delete node.ausbossOutlineElement;
|
||||
for (const [key, descriptor] of previous.descriptors) {
|
||||
if (descriptor) Object.defineProperty(node, key, descriptor);
|
||||
else delete node[key];
|
||||
@@ -44,6 +48,9 @@ export function setTileFace(node, root, enabled, onEdit) {
|
||||
|
||||
function skipBadges() {}
|
||||
|
||||
// Sent from a tile's own drag after each move: js/snap_lines/ lines it up.
|
||||
export const TILE_MOVE = "ausboss-tile-move";
|
||||
|
||||
// A normal node moves by its header. Give the tile that gesture while
|
||||
// keeping a short click on a link or the info button as its usual action.
|
||||
function installTileDrag(node, root, signal, onEdit) {
|
||||
@@ -87,6 +94,9 @@ function installTileDrag(node, root, signal, onEdit) {
|
||||
for (const start of press.starts) start.item.pos = [start.x + dx / zoom, start.y + dy / zoom];
|
||||
node.setDirtyCanvas?.(true, true);
|
||||
event.stopPropagation();
|
||||
// The move stops here (Nodes 2.0 would pan the canvas with it), so tell
|
||||
// Snap into line separately, after the tile has been placed.
|
||||
root.dispatchEvent(new CustomEvent(TILE_MOVE, { bubbles: true, detail: event }));
|
||||
}, capture);
|
||||
const finish = (event) => {
|
||||
if (event.pointerId !== press?.id) return;
|
||||
|
||||
@@ -217,6 +217,16 @@ export function latestFirstFor(info, frames, everyNth = 1) {
|
||||
return Math.max(0, info.count - 1 - (lastFrameFor(0, frames, everyNth)));
|
||||
}
|
||||
|
||||
// How far a drag can move IN while a Length is on. A Length that fits stops
|
||||
// IN where OUT meets the source's end, so the count stays whole. A Length
|
||||
// as long as the clip or longer cannot keep its count anywhere: it only caps
|
||||
// the clip, the source's end is OUT, and IN moves over the whole clip.
|
||||
export function latestInFor(info, frames, everyNth = 1) {
|
||||
if (!info?.count) return 0;
|
||||
const latest = latestFirstFor(info, frames, everyNth);
|
||||
return latest > 0 ? latest : info.count - 1;
|
||||
}
|
||||
|
||||
// Everything the rail draws for the clip node, from the stored values:
|
||||
// mode which way sets the length (lengthMode)
|
||||
// first IN, the first source frame the run keeps
|
||||
@@ -263,7 +273,14 @@ export function clipLengthPlan(info, values = {}) {
|
||||
latestStart = clamp(Math.floor((end - lastTick - TRIM_EPSILON) * info.fps), 0, endFrame);
|
||||
}
|
||||
}
|
||||
if (values.resampled) return { ...base, last: cap > 0 ? null : window.last, requested, latestStart };
|
||||
if (values.resampled) {
|
||||
// A known output rate places every output frame: the backend samples
|
||||
// and holds on ticks at start + k / rate (decode_video_range), so the
|
||||
// count, the last source frame shown and the end are all known here.
|
||||
if (!(values.outputFps > 0) || !(info.fps > 0)) return { ...base, last: cap > 0 ? null : window.last, requested, latestStart };
|
||||
const resampled = resampledFrames(info, values, nth, requested, snap);
|
||||
return { ...base, ...resampled, requested, latestStart, truncated: requested != null && resampled.frames < requested };
|
||||
}
|
||||
const kept = keptFrames(window, nth, cap, snap);
|
||||
return { ...base, last: kept.lastKept, frames: kept.frames, requested, latestStart, truncated: requested != null && kept.frames < requested };
|
||||
};
|
||||
@@ -278,6 +295,27 @@ export function clipLengthPlan(info, values = {}) {
|
||||
return capped(mode === "length" ? stored : 0);
|
||||
}
|
||||
|
||||
// Output frames of a run that resamples to a known rate: ticks at
|
||||
// start + k / tickRate while before the end, thinned by every nth, capped,
|
||||
// then snapped. `last` is the source frame the final tick holds.
|
||||
export function resampledFrames(info, values, everyNth = 1, cap = null, snap = "free") {
|
||||
const nth = Math.max(1, Math.floor(finite(everyNth, 1)) || 1);
|
||||
const tickRate = finite(values.outputFps) * nth;
|
||||
const duration = info.duration || info.count / info.fps;
|
||||
const start = Math.max(0, finite(values.start));
|
||||
const end = finite(values.end) > 0 ? Math.min(finite(values.end), duration) : duration;
|
||||
const ticks = Math.max(0, Math.ceil((end - start) * tickRate - TRIM_EPSILON));
|
||||
let frames = Math.ceil(ticks / nth);
|
||||
if (cap != null && cap > 0) frames = Math.min(frames, cap);
|
||||
frames = snapFrameCount(frames, snap);
|
||||
const first = frameWindow(info, start, values.end).first;
|
||||
const lastTime = start + Math.max(0, frames - 1) * nth / tickRate;
|
||||
const last = clamp(Math.floor(lastTime * info.fps + TRIM_EPSILON), first, info.count - 1);
|
||||
const windowLast = frameWindow(info, start, values.end).last;
|
||||
// The last frame is held for one output frame, but never past the video.
|
||||
return { first, last, windowLast, frames, endSeconds: Math.min(end, start + frames / finite(values.outputFps)) };
|
||||
}
|
||||
|
||||
// Playback rate for a label, trimmed of float noise: 24 -> "24",
|
||||
// 23.976023... -> "23.976".
|
||||
export function formatFps(value) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Small pieces every timing card shares (the clip node, Load Video, Load
|
||||
// Audio): the seconds | frames choice and the "linked" button that goes to
|
||||
// the node feeding a value.
|
||||
import { app } from "../../../scripts/app.js";
|
||||
|
||||
// Seconds or frames on a timing card: a per-browser choice, like a view
|
||||
// setting. It never changes a stored value.
|
||||
const UNITS_KEY = "AusBoss.ClipTiming.Units";
|
||||
let unitsCache = null;
|
||||
export function timingUnits(next) {
|
||||
if (next === "s" || next === "f") {
|
||||
unitsCache = next;
|
||||
try { localStorage.setItem(UNITS_KEY, next); } catch { /* private window */ }
|
||||
return next;
|
||||
}
|
||||
if (unitsCache) return unitsCache;
|
||||
try { unitsCache = localStorage.getItem(UNITS_KEY) === "f" ? "f" : "s"; } catch { unitsCache = "s"; }
|
||||
return unitsCache;
|
||||
}
|
||||
|
||||
// The node feeding a linked input, by its title, with a way to go to it.
|
||||
export function linkedNodeInfo(node, name) {
|
||||
const slot = node.inputs?.find((input) => input?.name === name || input?.widget?.name === name);
|
||||
if (slot?.link == null) return null;
|
||||
const graph = node.graph;
|
||||
const link = graph?.links?.get?.(slot.link) ?? graph?.links?.[slot.link] ?? graph?._links?.get?.(slot.link);
|
||||
const source = graph?.getNodeById?.(link?.origin_id);
|
||||
if (!source) return { title: "the subgraph's input", go: null };
|
||||
const title = source.title || source.type || "another node";
|
||||
return {
|
||||
title,
|
||||
go: () => {
|
||||
try {
|
||||
app.canvas?.selectNode?.(source);
|
||||
app.canvas?.centerOnNode?.(source);
|
||||
app.canvas?.setDirty?.(true, true);
|
||||
} catch { /* an older canvas */ }
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -57,9 +57,9 @@ export function goesBehind(flying, ask, epoch) {
|
||||
|
||||
// The pack's own picture loaders. One of them wired straight into Mask by
|
||||
// Touch is run by the node itself, the way a press on Show picture runs it:
|
||||
// it may crop, turn or pad its file, so the file alone is not the picture,
|
||||
// it may crop, turn, pad or resize its file, so the file alone is not the picture,
|
||||
// but running it costs next to nothing.
|
||||
export const OWN_LOADERS = new Set(["AUSBOSS_NODES_ImageCropRotatePad", "AUSBOSS_NODES_LoadImagePad"]);
|
||||
export const OWN_LOADERS = new Set(["AUSBOSS_NODES_ImageCropRotatePad", "AUSBOSS_NODES_LoadImage", "AUSBOSS_NODES_LoadImagePad"]);
|
||||
|
||||
// What a loader will hand on, as far as the page can tell: its file and its
|
||||
// settings, as one text. Another text means another picture. Widgets that
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { api } from "../../../scripts/api.js";
|
||||
import { app } from "../../../scripts/app.js";
|
||||
import { linkedNodeInfo, timingUnits as clipUnits } from "./timing_links.mjs";
|
||||
import { PANEL_LABELS } from "./panel_controls.mjs";
|
||||
import { hideInputsInDef, hideWidget } from "./widget_visibility.mjs";
|
||||
import { mountTransformTrim } from "./transform_trim.mjs";
|
||||
@@ -103,7 +104,6 @@ const trimInputDriven = (node, name) => node.inputs?.some(
|
||||
|
||||
const RESIZE_METHODS = ["lanczos", "area", "bicubic", "bilinear", "nearest-exact"];
|
||||
// The widest the control rows get on a big node; the picture takes the rest.
|
||||
const CONTROL_MAX_WIDTH = 460;
|
||||
const TRANSFORM_DEFAULTS = resetTransformValues(false);
|
||||
const CORE_IMAGE_PREVIEW_WIDGET = "$$canvas-image-preview";
|
||||
|
||||
@@ -150,7 +150,7 @@ function installStyles() {
|
||||
style.id = "ausboss-transform-styles";
|
||||
style.textContent = `
|
||||
.ausboss-transform-panel{display:flex;flex-direction:column;gap:8px;padding:8px;color:#ddd;font:12px system-ui;box-sizing:border-box;width:100%;height:100%;overflow:hidden}
|
||||
.ausboss-transform-panel>:not(.ausboss-transform-preview){width:100%;max-width:${CONTROL_MAX_WIDTH}px;align-self:center;box-sizing:border-box}
|
||||
.ausboss-transform-panel>:not(.ausboss-transform-preview){width:100%;align-self:stretch;box-sizing:border-box}
|
||||
.ausboss-transform-preview{width:100%;flex:1 1 180px;min-height:0;border:1px solid #50555b;border-radius:8px;background:#111;display:block;touch-action:none}
|
||||
.ausboss-transform-source{display:flex;flex-direction:column;gap:7px;flex:0 0 auto;padding:8px;border:1px solid rgba(0,184,174,.28);border-radius:8px;background:rgba(0,0,0,.24)}
|
||||
.ausboss-transform-source-image{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center}
|
||||
@@ -189,13 +189,14 @@ function installStyles() {
|
||||
.ausboss-transform-group-meta{min-width:0;overflow:hidden;text-overflow:ellipsis}
|
||||
.ausboss-transform-group-body{display:flex;flex-direction:column;gap:7px;padding:8px;box-sizing:border-box}
|
||||
.ausboss-transform-group-body[hidden]{display:none}
|
||||
.ausboss-transform-readout{flex:0 0 auto;margin-top:-3px;color:#c9d0d6;font:11px/14px system-ui;font-variant-numeric:tabular-nums;text-align:center;overflow:hidden;cursor:default;user-select:none}
|
||||
.ausboss-transform-readout{flex:0 0 auto;margin:-5px 0 -3px;color:#c9d0d6;font:11px/14px system-ui;font-variant-numeric:tabular-nums;text-align:center;overflow:hidden;cursor:default;user-select:none}
|
||||
.ausboss-transform-readout:empty{display:none}
|
||||
.ausboss-transform-readout span{color:#8ca8a5}.ausboss-transform-readout b{color:#fff;font-weight:600}
|
||||
.ausboss-transform-readout>div,.ausboss-transform-readout i{display:flex;align-items:center;justify-content:center;gap:3px;height:14px;white-space:nowrap}
|
||||
.ausboss-transform-readout .ausboss-transform-ellipsis{min-width:0;overflow:hidden;text-overflow:ellipsis;color:inherit}
|
||||
.ausboss-transform-readout b,.ausboss-transform-readout button{flex:none}
|
||||
.ausboss-transform-readout i{color:#ffc46b;font-style:normal}
|
||||
.ausboss-transform-readout i:empty{display:none}
|
||||
.ausboss-transform-readout em{color:#8ca8a5;font-style:normal}
|
||||
.ausboss-transform-readout em.note.ausboss-transform-ellipsis{color:#ffc46b}
|
||||
.ausboss-transform-readout button{margin:0 0 0 6px;height:14px;padding:0 6px;border:1px solid #6b5a33;border-radius:3px;background:#2a2417;color:#ffd79a;font:600 9.5px/12px system-ui;cursor:pointer;vertical-align:top}
|
||||
@@ -2320,6 +2321,11 @@ function buildTrim(state) {
|
||||
onTogglePlayback: () => timelineCommand(state, "play"),
|
||||
onSeek: (frame, settled) => scrubTo(state, frame, settled),
|
||||
onCommit: notifyAusbossChange,
|
||||
linkInfo: (name) => linkedNodeInfo(state.node, name),
|
||||
// H3 Prompt Writer reads this to say what H3 makes of the clip.
|
||||
publish: (timing) => { state.node.__ausbossClipTiming = timing; },
|
||||
units: () => clipUnits(),
|
||||
setUnits: (next) => { clipUnits(next); for (const view of state.trimViews) view.sync(); },
|
||||
});
|
||||
state.trimViews.add(control);
|
||||
return control.root;
|
||||
@@ -2340,6 +2346,7 @@ function setPlayhead(state, index) {
|
||||
// also snaps the widgets to the decoded frame.
|
||||
function scrubTo(state, index, settled) {
|
||||
if (state.playing) stopPlayback(state, false);
|
||||
state.pausedAt = null;
|
||||
const frame = setPlayhead(state, index);
|
||||
syncTimelineRange(state);
|
||||
if (settled) { void seekFrame(state); return; }
|
||||
@@ -2400,7 +2407,11 @@ function startPlayback(state) {
|
||||
const trim = [...state.trimViews][0];
|
||||
const { first, last } = trim.window();
|
||||
const head = clampFrame(value(state.node, "frame_index", 0), info);
|
||||
let next = head < first || head >= last ? first : head + 1;
|
||||
// Play shows the clip from its start, so what plays is what the run
|
||||
// keeps; only a resume right after a pause inside the clip carries on.
|
||||
const resume = state.pausedAt != null && state.pausedAt === head && head >= first && head < last;
|
||||
let next = resume ? head + 1 : first;
|
||||
state.pausedAt = null;
|
||||
state.playing = true;
|
||||
syncTimelineRange(state);
|
||||
const session = ++state.playbackSession;
|
||||
@@ -2421,6 +2432,7 @@ function startPlayback(state) {
|
||||
function stopPlayback(state, settle = true) {
|
||||
const wasPlaying = Boolean(state.playing);
|
||||
state.playing = false;
|
||||
if (wasPlaying) state.pausedAt = clampFrame(value(state.node, "frame_index", 0), clipInfo(state.metadata));
|
||||
state.playbackSession = (state.playbackSession || 0) + 1; // orphan in-flight ticks
|
||||
if (state.playbackTimer) clearTimeout(state.playbackTimer);
|
||||
state.playbackTimer = null;
|
||||
|
||||
+390
-169
@@ -32,7 +32,7 @@ import {
|
||||
framesThrough,
|
||||
keyboardStep,
|
||||
lastFrameFor,
|
||||
latestFirstFor,
|
||||
latestInFor,
|
||||
railZone,
|
||||
setTrimFrame,
|
||||
slideRange,
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
windowSeconds,
|
||||
} from "./timeline_math.mjs";
|
||||
|
||||
const CSS_ID = "ausboss-transform-trim-css-v4";
|
||||
const CSS_ID = "ausboss-transform-trim-css-v5";
|
||||
const HANDLE_HIT_PX = 9;
|
||||
// Connected inputs that set the length themselves, in the backend's order of
|
||||
// precedence: fixed_frames replaces the window, a cap replaces the Length.
|
||||
@@ -101,6 +101,25 @@ function installCss() {
|
||||
.ausboss-transform-trim-reset{flex:none;height:18px;box-sizing:border-box;border:1px solid #2c4d4b;border-radius:4px;background:#1b2627;color:#cadddb;font:600 10px/16px system-ui;cursor:pointer;padding:0 8px;white-space:nowrap}
|
||||
.ausboss-transform-trim-reset:hover{border-color:#8fa3a1;color:#fff}
|
||||
.ausboss-transform-trim-reset:disabled{opacity:.45;cursor:not-allowed}
|
||||
.ausboss-transform-trim-span.is-room{background:repeating-linear-gradient(90deg,rgba(0,180,170,.38) 0 6px,rgba(0,180,170,.1) 6px 12px)}
|
||||
.ausboss-transform-trim-line .ausboss-transform-trim-readout{text-align:left}
|
||||
.ausboss-transform-trim-inside{color:#45d6cb}
|
||||
.ausboss-transform-trim-outside{color:#8ca8a5}
|
||||
.ausboss-transform-trim-clip{flex:1 1 0;min-width:0;color:#45d6cb;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}
|
||||
.ausboss-transform-trim-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;min-width:0}
|
||||
.ausboss-transform-trim-field{display:flex;flex-direction:column;gap:3px;min-width:0}
|
||||
.ausboss-transform-trim-field .ausboss-scrub{width:100%;box-sizing:border-box}
|
||||
.ausboss-transform-trim-field-label{color:#cadddb;display:flex;align-items:center;gap:6px;min-width:0}
|
||||
.ausboss-transform-trim-go[hidden]{display:none}
|
||||
.ausboss-transform-trim-sub{color:#8ca8a5;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums;min-height:12px}
|
||||
.ausboss-transform-trim-link{color:#9fe3dc;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.ausboss-transform-trim-link[hidden]{display:none}
|
||||
.ausboss-transform-trim-go{border:0;background:transparent;padding:0;color:#45d6cb;font:600 10px system-ui;text-decoration:underline;cursor:pointer}
|
||||
.ausboss-transform-trim-note{display:flex;align-items:center;gap:6px;flex-wrap:wrap;color:#9fe3dc;font-size:11px;line-height:1.35}
|
||||
.ausboss-transform-trim-note[hidden]{display:none}
|
||||
.ausboss-transform-trim-note>span{flex:1 1 180px;min-width:0}
|
||||
.ausboss-transform-trim-note.warn{background:#3a2a10;box-shadow:inset 3px 0 0 #e0a040;border-radius:6px;padding:6px 8px;color:#ffdca8}
|
||||
.ausboss-transform-trim-note button[hidden]{display:none}
|
||||
`;
|
||||
document.head.append(style);
|
||||
}
|
||||
@@ -113,6 +132,8 @@ function el(tag, className = "", text = "") {
|
||||
}
|
||||
|
||||
const pct = (fraction) => `${(fraction * 100).toFixed(3)}%`;
|
||||
// Seconds for people: at most two decimals (1, 1.5, 2.17).
|
||||
const secondsText = (value) => String(Number((Number(value) || 0).toFixed(2)));
|
||||
|
||||
// options:
|
||||
// get(name, fallback) / set(name, value) widget access
|
||||
@@ -126,7 +147,12 @@ const pct = (fraction) => `${(fraction * 100).toFixed(3)}%`;
|
||||
// (the clip node) or playhead only
|
||||
// onSeek(frame, settled) the playhead moved; settled on release
|
||||
// onCommit() a stored value settled (undo point)
|
||||
export function mountTransformTrim({ get, set, has = () => true, driven = () => false, number = (name, fallback) => get(name, fallback), outputRate, metadata, trim = true, isPlaying, onTogglePlayback, onSeek, onCommit }) {
|
||||
// linkInfo(name) {title, go()} of the node feeding
|
||||
// a linked input, or null
|
||||
// publish(timing) the clip's {frames, startSeconds,
|
||||
// endSeconds, roomFrames}, or null
|
||||
// units() / setUnits(units) "s" (seconds) or "f" (frames)
|
||||
export function mountTransformTrim({ get, set, has = () => true, driven = () => false, number = (name, fallback) => get(name, fallback), outputRate, metadata, trim = true, isPlaying, onTogglePlayback, onSeek, onCommit, linkInfo = () => null, publish, units: getUnits = () => "s", setUnits = () => {}, play: showPlay = true }) {
|
||||
installCss();
|
||||
const root = el("div", "ausboss-transform-trim");
|
||||
const rail = el("div", "ausboss-transform-trim-rail");
|
||||
@@ -144,7 +170,9 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
const play = el("button", "ausboss-transform-trim-play");
|
||||
play.type = "button";
|
||||
play.addEventListener("click", onTogglePlayback);
|
||||
transport.append(play, rail);
|
||||
// A host with its own player (Load Video) leaves out the Play button.
|
||||
if (showPlay) transport.append(play);
|
||||
transport.append(rail);
|
||||
const info = () => clipInfo(metadata());
|
||||
const everyNth = () => Math.max(1, Math.trunc(Number(number("every_nth", get("every_nth", 1))) || 1));
|
||||
const snapRule = () => String(get("frame_snap", "free"));
|
||||
@@ -160,11 +188,10 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
return number(name, get(name, 0)) ?? get(name, 0);
|
||||
};
|
||||
const countAtRunTime = () => COUNT_INPUTS.some((name) => driven(name) && number(name, null) == null);
|
||||
const plan = () => {
|
||||
if (!trim) return null;
|
||||
const clip = info();
|
||||
const outFps = () => (outputRate ? outputRate() : info().fps / everyNth());
|
||||
const planValues = () => {
|
||||
const wired = wiredBy();
|
||||
return clipLengthPlan(clip, {
|
||||
return {
|
||||
start: boundSeconds("start"),
|
||||
end: boundSeconds("end"),
|
||||
everyNth: everyNth(),
|
||||
@@ -173,9 +200,48 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
fixedFrames: driven("fixed_frames") ? 0 : get("fixed_frames", 0),
|
||||
wired,
|
||||
wiredFrames: wired ? number(wired, null) : null,
|
||||
outputFps: outputRate ? outputRate() : clip.fps,
|
||||
outputFps: outputRate ? outputRate() : info().fps,
|
||||
resampled: driven("force_rate"),
|
||||
});
|
||||
};
|
||||
};
|
||||
const plan = () => (trim ? clipLengthPlan(info(), planValues()) : null);
|
||||
// Output frames that fit between IN and the end of the video: the most a
|
||||
// Duration can be from here.
|
||||
const roomFrames = () => {
|
||||
if (!trim) return null;
|
||||
const room = clipLengthPlan(info(), { ...planValues(), maxFrames: 0, fixedFrames: 0, wired: null, wiredFrames: null });
|
||||
return room.frames ?? null;
|
||||
};
|
||||
// Where the clip ends, in source seconds (exclusive), when it is known.
|
||||
const endSecondsOf = (current) => {
|
||||
const clip = info();
|
||||
if (current?.endSeconds != null) return current.endSeconds;
|
||||
if (current?.last == null || !clip.fps) return null;
|
||||
return (current.last + 1) / clip.fps;
|
||||
};
|
||||
const endDriven = () => driven("end_frame") || driven("end_seconds");
|
||||
// The latest IN that keeps the whole Duration. With a connected rate the
|
||||
// count is in output frames, so the source grid would stop IN far too soon
|
||||
// (the 2.25 face stopped a 240-frame Length at IN 7 on a 247-frame clip).
|
||||
const latestIn = (current) => {
|
||||
const clip = info();
|
||||
if (driven("force_rate")) {
|
||||
if (current.latestStart == null) return clip.count - 1;
|
||||
return current.latestStart > 0 ? current.latestStart : clip.count - 1;
|
||||
}
|
||||
return latestInFor(clip, current.requested ?? get("max_frames", 1), everyNth());
|
||||
};
|
||||
// A Duration as long as the whole video only caps it: IN moves freely and
|
||||
// the clip runs to the end.
|
||||
const durationFills = (current) => {
|
||||
if (current.mode !== "length" || current.requested == null) return false;
|
||||
const whole = roomFromStart();
|
||||
return whole != null && current.requested >= whole;
|
||||
};
|
||||
const roomFromStart = () => {
|
||||
if (!trim) return null;
|
||||
const room = clipLengthPlan(info(), { ...planValues(), start: 0, maxFrames: 0, fixedFrames: 0, wired: null, wiredFrames: null });
|
||||
return room.frames ?? null;
|
||||
};
|
||||
const currentWindow = () => {
|
||||
const clip = info();
|
||||
@@ -185,7 +251,8 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
};
|
||||
const playheadFrame = () => clampFrame(get("frame_index", 0), info());
|
||||
const controls = {};
|
||||
let syncLength = () => {};
|
||||
// A short line under the fields after a drag stops at the video's end.
|
||||
let stopNote = "";
|
||||
// IN is locked by a connected bound; OUT by a connected bound in free
|
||||
// trim, and always when a connected input sets the length.
|
||||
const locked = (edge) => {
|
||||
@@ -196,10 +263,10 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
return false;
|
||||
};
|
||||
const lockTip = (edge) => edge === "start"
|
||||
? "The starting frame is supplied by a connected input. Disconnect it to edit IN here."
|
||||
? "The starting frame is supplied by a connected input. Disconnect it to set Start here."
|
||||
: wiredBy()
|
||||
? `The connected ${wiredBy()} input sets the length, so the clip ends where it says. Disconnect it to use OUT or Length.`
|
||||
: "The ending frame is supplied by a connected input. Disconnect it to edit OUT here.";
|
||||
? `The connected ${wiredBy()} input sets the length, so the clip ends where it says. Disconnect it to set Duration or Ends at here.`
|
||||
: "The ending frame is supplied by a connected input. Disconnect it to set Ends at here.";
|
||||
const disableControl = (control, disabled, tip) => {
|
||||
if (!control) return;
|
||||
control.root.style.opacity = disabled ? ".45" : "";
|
||||
@@ -217,7 +284,16 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
const writeEnd = (first, last) => set("end_seconds", windowSeconds(info(), first, last).end_seconds);
|
||||
// An older face's Fixed frames reads as a Length; the first edit makes it
|
||||
// one, keeping the window where the fixed count had placed it.
|
||||
// The face has no modes: a clip is a Start and a Duration. A window saved
|
||||
// as IN -> OUT (Length off) becomes a Duration of the same frames on its
|
||||
// first edit, so the run outputs exactly what it did. A connected end
|
||||
// keeps the window as it is.
|
||||
const adoptLength = (current) => {
|
||||
if (current.mode === "free" && !endDriven() && current.frames != null) {
|
||||
set("max_frames", Math.max(1, current.frames));
|
||||
set("end_seconds", 0);
|
||||
return plan();
|
||||
}
|
||||
if (current.mode !== "fixed") return current;
|
||||
set("fixed_frames", 0);
|
||||
set("max_frames", Math.max(1, current.requested ?? current.frames ?? 1));
|
||||
@@ -235,8 +311,14 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
let parked;
|
||||
if (edge === "start") {
|
||||
if (current.mode === "length") {
|
||||
// A Length drags the whole window, stopping where OUT meets the end.
|
||||
parked = Math.max(0, Math.min(clampFrame(frame, clip), latestFirstFor(clip, current.requested ?? get("max_frames", 1), nth)));
|
||||
// A Duration drags the whole clip, stopping where its end meets the
|
||||
// video's end; a Duration past the video's end only caps it, so IN
|
||||
// moves freely.
|
||||
const latest = latestIn(current);
|
||||
parked = Math.max(0, Math.min(clampFrame(frame, clip), latest));
|
||||
stopNote = clampFrame(frame, clip) > latest
|
||||
? `Start stops at ${secondsText(parked / clip.fps)} s so all ${current.requested} frames fit.`
|
||||
: "";
|
||||
set("end_seconds", 0);
|
||||
} else if (current.mode === "wired" && current.latestStart != null && !countAtRunTime()) {
|
||||
parked = Math.min(clampFrame(frame, clip), current.latestStart);
|
||||
@@ -246,11 +328,18 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
writeStart(parked);
|
||||
} else {
|
||||
const target = Math.max(current.first, clampFrame(frame, clip));
|
||||
const frames = framesThrough(current.first, target, nth, snapRule());
|
||||
stopNote = "";
|
||||
let frames = framesThrough(current.first, target, nth, snapRule());
|
||||
if (driven("force_rate") && outFps() > 0) {
|
||||
// Output frames at the linked rate from IN to the handle's boundary.
|
||||
frames = snapToValid(Math.max(1, Math.round(((target + 1) / clip.fps - boundSeconds("start")) * outFps())), snapRule());
|
||||
const room = roomFrames();
|
||||
if (room != null) frames = Math.min(frames, Math.max(1, room));
|
||||
}
|
||||
if (current.mode === "length") {
|
||||
set("max_frames", frames);
|
||||
set("end_seconds", 0);
|
||||
parked = Math.min(clip.count - 1, lastFrameFor(current.first, frames, nth));
|
||||
parked = plan()?.last ?? Math.min(clip.count - 1, lastFrameFor(current.first, frames, nth));
|
||||
} else {
|
||||
parked = driven("force_rate") ? target : lastFrameFor(current.first, frames, nth);
|
||||
writeEnd(current.first, parked);
|
||||
@@ -262,7 +351,8 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
// The grip slides the kept part: a Length moves with IN (OUT follows), a
|
||||
// free window keeps its span and both edges move.
|
||||
const canSlide = () => {
|
||||
if (!trim || locked("start")) return false;
|
||||
// With a connected rate, IN itself slides the clip at its Duration.
|
||||
if (!trim || locked("start") || driven("force_rate")) return false;
|
||||
const current = plan();
|
||||
if (!current || !["length", "fixed", "free"].includes(current.mode)) return false;
|
||||
if (current.mode === "free" && locked("end")) return false;
|
||||
@@ -284,26 +374,6 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
}
|
||||
moveEdge("start", first, settled);
|
||||
};
|
||||
// Length on keeps what the rail shows now as the count; off turns the
|
||||
// Length into an OUT at the same frame. Either way nothing moves.
|
||||
const setLength = (on) => {
|
||||
const current = plan();
|
||||
if (!current || current.mode === "wired" || (on === (current.mode !== "free"))) return;
|
||||
if (on) {
|
||||
const frames = current.frames ?? framesThrough(current.first, current.windowLast, everyNth(), snapRule());
|
||||
set("max_frames", Math.max(1, frames));
|
||||
set("end_seconds", 0);
|
||||
} else {
|
||||
const last = current.last ?? current.windowLast;
|
||||
writeStart(current.first);
|
||||
writeEnd(current.first, last);
|
||||
set("max_frames", 0);
|
||||
if (!driven("fixed_frames")) set("fixed_frames", 0);
|
||||
}
|
||||
sync();
|
||||
onCommit?.();
|
||||
};
|
||||
|
||||
const readout = el("span", "ausboss-transform-trim-readout");
|
||||
const summary = el("div", "ausboss-transform-trim-summary");
|
||||
|
||||
@@ -311,7 +381,7 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
const clip = info();
|
||||
const playing = isPlaying();
|
||||
play.setAttribute("aria-label", playing ? "Pause" : "Play");
|
||||
play.title = playing ? "Pause on this frame" : trim ? "Play the selected clip" : "Play the video to pick a frame";
|
||||
play.title = playing ? "Pause on this frame" : trim ? "Play the clip from its start" : "Play the video to pick a frame";
|
||||
play.classList.toggle("is-playing", playing);
|
||||
play.disabled = !clip.count;
|
||||
const head = playheadFrame();
|
||||
@@ -319,33 +389,41 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
playhead.style.left = pct(fractionOfFrame(head, clip, "center"));
|
||||
playhead.style.visibility = clip.count ? "" : "hidden";
|
||||
readout.replaceChildren();
|
||||
const current = trim ? plan() : null;
|
||||
if (clip.count) {
|
||||
readout.append(el("b", "", `fr ${head}`), document.createTextNode(` · ${formatTimecode(frameTime(head, clip))}`));
|
||||
readout.title = `Playhead: frame ${head} of ${clip.count} at ${frameTime(head, clip).toFixed(3)} s. Press or drag the rail to scrub; ${trim ? "the trim handles carry it with them." : "this is the frame the node outputs."}`;
|
||||
readout.append(document.createTextNode("Preview "), el("b", "", `${secondsText(frameTime(head, clip))} s`), document.createTextNode(` · src fr ${head}`));
|
||||
if (trim) {
|
||||
const end = countAtRunTime() ? null : current.last;
|
||||
const inside = head >= current.first && (end == null || head <= end);
|
||||
readout.append(el("span", inside ? "ausboss-transform-trim-inside" : "ausboss-transform-trim-outside", inside ? " · in the clip" : " · outside the clip"));
|
||||
}
|
||||
readout.title = `The picture shows frame ${head} of ${clip.count}, ${frameTime(head, clip).toFixed(2)} seconds into the video. Press or drag the bar to look at another frame${trim ? "; Use as start starts the clip here." : "; this is the frame the node outputs."}`;
|
||||
}
|
||||
controls.frame?.set(head);
|
||||
if (!trim) return;
|
||||
const current = plan();
|
||||
const wired = wiredBy();
|
||||
const unknown = countAtRunTime();
|
||||
const hasOut = current.last != null && current.mode !== "wired";
|
||||
const hasOut = current.last != null && current.mode !== "wired" && !unknown;
|
||||
const outFrame = current.last ?? current.windowLast;
|
||||
const startFraction = fractionOfFrame(current.first, clip, "start");
|
||||
const endFraction = fractionOfFrame(outFrame, clip, "end");
|
||||
const endSec = endSecondsOf(current);
|
||||
const endFraction = endSec != null && !unknown
|
||||
? Math.max(startFraction, Math.min(1, endSec * clip.fps / clip.count))
|
||||
: fractionOfFrame(outFrame, clip, "end");
|
||||
// Dim: frames the free window holds but the run drops (every nth, snap).
|
||||
const tailFraction = current.mode === "free" ? fractionOfFrame(current.windowLast, clip, "end") : endFraction;
|
||||
span.style.left = pct(startFraction);
|
||||
span.style.width = pct(current.last == null && current.mode !== "free" ? 0 : Math.max(0, tailFraction - startFraction));
|
||||
span.classList.toggle("is-room", unknown || current.last == null);
|
||||
// A length only the run knows: the dim part is the room the clip has.
|
||||
span.style.width = pct(unknown || current.last == null ? 1 - startFraction : Math.max(0, tailFraction - startFraction));
|
||||
kept.style.left = pct(startFraction);
|
||||
kept.style.width = current.last == null || unknown ? "0%" : pct(Math.max(0, endFraction - startFraction));
|
||||
const fills = lengthFillsClip(clip, current, everyNth());
|
||||
span.title = unknown || current.last == null ? "Room for the clip: its length is set when the graph runs." : "";
|
||||
const railWidth = rail.getBoundingClientRect().width || 0;
|
||||
const keptWidth = Math.max(0, endFraction - startFraction) * railWidth;
|
||||
grip.hidden = !canSlide() || unknown || (railWidth > 0 && keptWidth < 34);
|
||||
grip.style.left = pct((startFraction + endFraction) / 2);
|
||||
grip.title = current.mode === "free"
|
||||
? "Drag to slide the kept part: IN and OUT move together."
|
||||
: "Drag to slide the clip: OUT follows at the Length.";
|
||||
grip.title = "Drag to slide the clip; its Duration stays.";
|
||||
for (const edge of ["start", "end"]) {
|
||||
const handle = handles[edge];
|
||||
const frame = edge === "start" ? current.first : outFrame;
|
||||
@@ -358,10 +436,9 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
handle.style.cursor = isLocked ? "not-allowed" : "";
|
||||
handle.title = isLocked ? lockTip(edge)
|
||||
: edge === "start"
|
||||
? current.mode === "free" ? "Drag IN to trim; Shift + arrow moves one frame."
|
||||
: fills ? "The Length is the whole clip, so IN has nowhere to go. Shorten the Length to move IN."
|
||||
: "Drag IN to move the clip; OUT follows at the Length. Shift + arrow moves one frame."
|
||||
: current.mode === "free" ? "Drag OUT to trim; it lands on the last frame the run keeps." : "Drag OUT to change the Length; IN stays.";
|
||||
? durationFills(current) ? "Drag to start later. The Duration is longer than the video, so the clip runs to its end."
|
||||
: "Drag to move the clip; its Duration stays. Shift + arrow moves one frame."
|
||||
: "Drag to change the Duration; the start stays.";
|
||||
handle.setAttribute("aria-valuemin", "0");
|
||||
const maxFrame = edge === "start" && current.mode === "wired" && !unknown
|
||||
? current.latestStart ?? current.windowLast : Math.max(0, clip.count - 1);
|
||||
@@ -369,16 +446,16 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
handle.setAttribute("aria-valuenow", String(frame));
|
||||
handle.setAttribute("aria-valuetext", `frame ${frame}, ${formatTimecode(frameTime(frame, clip))}`);
|
||||
}
|
||||
controls.start_seconds?.set(current.first);
|
||||
controls.end_seconds?.set(outFrame);
|
||||
disableControl(controls.start_seconds, locked("start"), lockTip("start"));
|
||||
disableControl(controls.end_seconds, locked("end") || !hasOut, lockTip("end"));
|
||||
syncLength(current, wired);
|
||||
if (useStart) {
|
||||
useStart.disabled = !clip.count || locked("start");
|
||||
useStart.title = locked("start") ? lockTip("start") : "Start the clip at the frame on the stage. The Duration stays.";
|
||||
}
|
||||
if (clip.count) syncFields(clip, current, wired, unknown);
|
||||
if (controls.reset) {
|
||||
const free = current.mode === "free";
|
||||
controls.reset.textContent = free ? "Full clip" : "To start";
|
||||
controls.reset.title = free ? "Reset IN/OUT to the full source. Keeps Every nth and Frames for." : "Move IN to the start of the source; the length stays.";
|
||||
controls.reset.disabled = !free && locked("start");
|
||||
const free = current.mode !== "wired";
|
||||
controls.reset.textContent = free ? "Whole video" : "To start";
|
||||
controls.reset.title = free ? `Use the whole video: start at 0 with no Duration limit. Keeps Every nth${has("frame_snap") ? " and Frames for" : ""}.` : "Move the start to the beginning of the video; the linked length stays.";
|
||||
controls.reset.disabled = locked("start") && !free;
|
||||
}
|
||||
controls.every_nth?.set(get("every_nth", 1));
|
||||
disableControl(controls.every_nth, driven("every_nth"), "Every nth is supplied by a connected input.");
|
||||
@@ -386,50 +463,21 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
controls.frame_snap.value = snapRule();
|
||||
const exact = current.mode === "fixed" || (current.mode === "wired" && wired === "fixed_frames");
|
||||
controls.frame_snap.disabled = exact || driven("frame_snap");
|
||||
controls.frame_snap.title = exact ? "An exact fixed_frames count is used as it is; this does not apply." : "Keep a frame count the video model takes: LTX wants 8n+1 (49, 97, 121), Wan 4n+1. OUT and Length step to those counts. Any keeps every frame.";
|
||||
controls.frame_snap.title = exact ? "An exact fixed_frames count is used as it is; this does not apply." : "Keep a frame count the video model takes: LTX wants 8n+1 (49, 97, 121), Wan 4n+1. The Duration steps to those counts. Any keeps every frame.";
|
||||
}
|
||||
syncSummary(clip, current, wired, unknown);
|
||||
syncSummary(clip);
|
||||
};
|
||||
|
||||
const syncSummary = (clip, current, wired, unknown) => {
|
||||
const syncSummary = (clip) => {
|
||||
if (!clip.count) {
|
||||
summary.textContent = "Choose a source to set the clip window";
|
||||
summary.textContent = "Choose a source to set the clip";
|
||||
summary.title = "";
|
||||
return;
|
||||
}
|
||||
const rate = outputRate?.();
|
||||
const fps = `Source ${formatFps(clip.fps)} fps → Output ${rate == null ? "rate at run time" : `${formatFps(rate)} fps`}`;
|
||||
if (current.mode === "wired") {
|
||||
summary.textContent = current.frames == null ? `${fps} · length from ${wired} at run time` : `${fps} · ${current.frames} frames from ${wired}`;
|
||||
summary.title = `The connected ${wired} input sets the length, so only IN is set here. Disconnect it to use OUT or a Length.`;
|
||||
return;
|
||||
}
|
||||
if (unknown || current.frames == null) {
|
||||
summary.textContent = `${fps} · frame count at run time`;
|
||||
summary.title = "IN, OUT and the playhead refer to source frames. A connected input decides the exact frame count when the workflow runs. Connect the fps output to the next video node's fps input.";
|
||||
return;
|
||||
}
|
||||
const from = formatTimecode(frameTime(current.first, clip));
|
||||
const to = formatTimecode((current.last + 1) / clip.fps);
|
||||
if (current.mode === "fixed") {
|
||||
summary.textContent = current.tooLong
|
||||
? `Fixed length needs more than the source's ${clip.duration.toFixed(3)}s`
|
||||
: `${fps} · exactly ${current.frames} frames · ${from} → ${to}`;
|
||||
summary.title = "An older Fixed frames value: an exact count from IN. Any change here turns it into a Length.";
|
||||
return;
|
||||
}
|
||||
const total = current.windowLast - current.first + 1;
|
||||
const count = current.mode === "length"
|
||||
? current.truncated ? `${current.frames} of ${current.requested} frames, source ends` : `${current.frames} frames`
|
||||
: current.frames < total ? `${current.frames} of ${total} frames` : `${current.frames} frames`;
|
||||
summary.textContent = `${fps} · ${count} · ${from} → ${to}`;
|
||||
summary.title = current.mode === "length"
|
||||
? current.truncated
|
||||
? `The source ends ${current.frames} frames after IN, before the Length of ${current.requested}. Move IN earlier or shorten the Length.`
|
||||
: "Length keeps OUT this many output frames after IN; drag IN to move the clip, OUT to change the Length."
|
||||
: current.frames < total
|
||||
? `The window holds ${total} frames; every nth and the snap rule keep ${current.frames}, ending at frame ${current.last}, where OUT sits. The dim part is dropped.`
|
||||
: "Frames the run outputs, at the fps the node reports.";
|
||||
summary.textContent = `Source ${formatFps(clip.fps)} fps · ${clip.count} frames · ends at ${secondsText(clip.duration || clip.count / clip.fps)} s · clip out at ${rate == null ? "the rate set at run time" : `${formatFps(rate)} fps`}`;
|
||||
summary.title = "Start and Ends at are places in the source video. Duration counts the frames the clip sends on, at the output rate.";
|
||||
if (trim) rail.title = [clipLine?.textContent, summary.textContent, readout.textContent].filter(Boolean).join("\n");
|
||||
};
|
||||
|
||||
// --- rail gestures --------------------------------------------------------
|
||||
@@ -531,21 +579,19 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
}
|
||||
|
||||
// --- rows -----------------------------------------------------------------
|
||||
const timeRow = el("div", "ausboss-transform-trim-line");
|
||||
// The clip node: Preview (the playhead, and Use as start), the clip in
|
||||
// words with a Seconds | Frames switch, then Start, Duration and Ends at.
|
||||
// Start and Ends at are positions in the source video; Duration counts the
|
||||
// frames the clip sends on, at the output rate. No modes: dragging IN
|
||||
// slides the clip, dragging OUT or typing a Duration or an end changes the
|
||||
// Duration.
|
||||
const previewRow = el("div", "ausboss-transform-trim-line");
|
||||
let useStart = null;
|
||||
if (trim) {
|
||||
for (const [name, caption, edge] of [["start_seconds", "IN", "start"], ["end_seconds", "OUT", "end"]]) {
|
||||
const label = el("label");
|
||||
label.append(el("span", "ausboss-transform-trim-caption", caption));
|
||||
controls[name] = makeScrubInput({
|
||||
value: 0, min: 0, max: 10000000, step: 1, decimals: 0,
|
||||
title: edge === "start" ? "IN frame: the first frame the run keeps (stored as start_seconds)." : "OUT frame: the last frame the run keeps. With Length on it follows IN; typing it changes the Length.",
|
||||
onChange: (frame) => moveEdge(edge, frame, false),
|
||||
onSettle: () => { const window = currentWindow(); seek(edge === "start" ? window.first : window.last, true); onCommit?.(); },
|
||||
});
|
||||
label.append(controls[name].root);
|
||||
timeRow.append(label);
|
||||
if (edge === "start") timeRow.append(readout);
|
||||
}
|
||||
useStart = el("button", "ausboss-transform-trim-reset", "Use as start");
|
||||
useStart.type = "button";
|
||||
useStart.title = "Start the clip at the frame on the stage. The Duration stays.";
|
||||
useStart.addEventListener("click", () => moveEdge("start", playheadFrame(), true));
|
||||
} else {
|
||||
const label = el("label");
|
||||
label.append(el("span", "ausboss-transform-trim-caption", "FRAME"));
|
||||
@@ -556,67 +602,237 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
onSettle: () => seek(playheadFrame(), true),
|
||||
});
|
||||
label.append(controls.frame.root);
|
||||
timeRow.append(label, readout);
|
||||
previewRow.append(label, readout);
|
||||
}
|
||||
root.append(transport, timeRow);
|
||||
root.append(transport);
|
||||
if (!trim) root.append(previewRow);
|
||||
|
||||
// Length: off, OUT ends the clip; on, a frame count from IN (max_frames,
|
||||
// end left open), so OUT follows IN and the count survives a new source.
|
||||
if (trim && has("max_frames")) {
|
||||
const lengthRow = el("div", "ausboss-transform-trim-line wrap");
|
||||
const label = el("label", "", "Length");
|
||||
const pill = el("div", "ausboss-transform-trim-pill");
|
||||
const off = el("button", "", "off");
|
||||
const on = el("button", "", "on");
|
||||
off.type = on.type = "button";
|
||||
off.title = "OUT ends the clip: drag both handles freely.";
|
||||
on.title = "Set the clip by a frame count from IN: OUT follows IN, and the count stays when you swap the video.";
|
||||
off.addEventListener("click", () => setLength(false));
|
||||
on.addEventListener("click", () => setLength(true));
|
||||
pill.append(off, on);
|
||||
const hint = el("span", "ausboss-transform-trim-hint");
|
||||
const count = makeScrubInput({ value: 1, min: 1, max: 100000, step: 1, decimals: 0, unit: "fr", width: 72,
|
||||
title: "Output frames from IN. Under a snap rule it steps to the counts the model keeps (97, 105, ... for 8n+1).",
|
||||
onChange: (next) => {
|
||||
const current = adoptLength(plan());
|
||||
if (current.mode !== "length") { sync(); return; }
|
||||
const was = current.requested ?? get("max_frames", 1);
|
||||
set("max_frames", snapToValid(next, snapRule(), Math.sign(next - was)));
|
||||
set("end_seconds", 0);
|
||||
sync();
|
||||
},
|
||||
onSettle: () => { const window = currentWindow(); seek(window.last, true); onCommit?.(); },
|
||||
});
|
||||
label.append(pill, count.root);
|
||||
lengthRow.append(label, hint);
|
||||
root.append(lengthRow);
|
||||
syncLength = (current, wired) => {
|
||||
const active = current.mode !== "free";
|
||||
const blocked = current.mode === "wired";
|
||||
off.classList.toggle("on", !active);
|
||||
on.classList.toggle("on", active);
|
||||
off.setAttribute("aria-pressed", String(!active));
|
||||
on.setAttribute("aria-pressed", String(active));
|
||||
pill.classList.toggle("is-disabled", blocked);
|
||||
off.disabled = on.disabled = blocked;
|
||||
pill.title = blocked ? lockTip("end") : "";
|
||||
count.root.style.display = active ? "" : "none";
|
||||
const step = snapStep(snapRule());
|
||||
count.setStep(step, step);
|
||||
count.set(blocked ? (current.requested ?? current.frames ?? 0) : (current.requested ?? get("max_frames", 1)));
|
||||
disableControl(count, blocked, lockTip("end"));
|
||||
const fills = lengthFillsClip(info(), current, everyNth());
|
||||
hint.textContent = blocked ? `from ${wired}` : current.mode === "fixed" ? "exact (older setting)" : fills ? "= the whole clip. Shorten it to move IN" : active ? "" : "OUT ends the clip";
|
||||
hint.classList.toggle("note", fills && !blocked);
|
||||
hint.title = fills && !blocked ? `The Length (${current.requested ?? current.frames} frames) covers the whole clip, so IN and the clip cannot move. The bar still scrubs.` : "";
|
||||
const fields = {};
|
||||
let clipLine = null;
|
||||
let unitPill = null;
|
||||
let noteRow = null;
|
||||
let noteText = null;
|
||||
const noteButtons = [];
|
||||
if (trim) {
|
||||
const clipRow = el("div", "ausboss-transform-trim-line");
|
||||
clipLine = el("span", "ausboss-transform-trim-clip");
|
||||
unitPill = el("div", "ausboss-transform-trim-pill");
|
||||
for (const [key, words, tip] of [["s", "s", "Show times in seconds."], ["f", "fr", "Show times in frames: source frames for Start and Ends at, clip frames for Duration."]]) {
|
||||
const button = el("button", "", words);
|
||||
button.type = "button";
|
||||
button.dataset.units = key;
|
||||
button.title = tip;
|
||||
button.addEventListener("click", () => { setUnits(key); sync(); });
|
||||
unitPill.append(button);
|
||||
}
|
||||
|
||||
const grid = el("div", "ausboss-transform-trim-fields");
|
||||
const toFrames = {
|
||||
start: (value) => (getUnits() === "f" ? Math.round(value) : Math.round(value * info().fps)),
|
||||
};
|
||||
// Output frames for a Duration typed in the current units.
|
||||
const durationFrames = (value) => {
|
||||
if (getUnits() === "f") return Math.round(value);
|
||||
const rate = outFps();
|
||||
return rate > 0 ? Math.round(value * rate) : null;
|
||||
};
|
||||
// Output frames from IN to an end typed in the current units.
|
||||
const framesToEnd = (value) => {
|
||||
const clip = info();
|
||||
const current = plan();
|
||||
const end = getUnits() === "f" ? (Math.round(value) + 1) / clip.fps : value;
|
||||
if (driven("force_rate")) {
|
||||
const rate = outFps();
|
||||
return rate > 0 ? Math.round((end - boundSeconds("start")) * rate) : null;
|
||||
}
|
||||
return framesThrough(current.first, Math.ceil(end * clip.fps - 1e-7) - 1, everyNth(), snapRule());
|
||||
};
|
||||
const setDuration = (frames) => {
|
||||
if (frames == null || !Number.isFinite(frames)) return;
|
||||
const current = adoptLength(plan());
|
||||
if (current.mode !== "length") return;
|
||||
const was = current.requested ?? get("max_frames", 1);
|
||||
set("max_frames", snapToValid(Math.max(1, frames), snapRule(), Math.sign(frames - was)));
|
||||
set("end_seconds", 0);
|
||||
stopNote = "";
|
||||
};
|
||||
const defs = [
|
||||
["start", "Start", "Where the clip starts in the source video."],
|
||||
["duration", "Duration", "How long the clip is. Counted in clip frames at the output rate."],
|
||||
["end", "Ends at", "Where the clip ends in the source video. Typing it changes the Duration."],
|
||||
];
|
||||
for (const [key, caption, tip] of defs) {
|
||||
const cell = el("div", "ausboss-transform-trim-field");
|
||||
const label = el("span", "ausboss-transform-trim-field-label", caption);
|
||||
const go = el("button", "ausboss-transform-trim-go", "linked");
|
||||
go.type = "button";
|
||||
label.append(go);
|
||||
const control = makeScrubInput({
|
||||
value: 0, min: 0, max: 10000000, step: 1, decimals: 2, minDecimals: 0, unit: "s", unitWidth: 34,
|
||||
title: tip,
|
||||
onChange: (value) => {
|
||||
if (key === "start") {
|
||||
if (locked("start")) return;
|
||||
// A typed start is kept even when the Duration no longer fits;
|
||||
// the note below says what fits and offers both fixes.
|
||||
adoptLength(plan());
|
||||
const frame = clampFrame(toFrames.start(value), info());
|
||||
writeStart(frame);
|
||||
stopNote = "";
|
||||
seek(frame, false);
|
||||
return;
|
||||
}
|
||||
if (key === "duration") setDuration(durationFrames(value));
|
||||
else setDuration(framesToEnd(value));
|
||||
sync();
|
||||
},
|
||||
onSettle: () => { const window = currentWindow(); seek(key === "start" ? window.first : window.last, true); onCommit?.(); },
|
||||
});
|
||||
cell.append(label, control.root);
|
||||
grid.append(cell);
|
||||
fields[key] = { control, go, cell, label };
|
||||
}
|
||||
|
||||
noteRow = el("div", "ausboss-transform-trim-note");
|
||||
noteText = el("span");
|
||||
noteRow.append(noteText);
|
||||
for (let index = 0; index < 2; index++) {
|
||||
const button = el("button", "ausboss-transform-trim-reset");
|
||||
button.type = "button";
|
||||
noteButtons.push(button);
|
||||
noteRow.append(button);
|
||||
}
|
||||
root.append(grid, noteRow);
|
||||
}
|
||||
|
||||
// One field's look: its value in the current units, the line under it,
|
||||
// and, when another node sets it, that node's name and a Go to button.
|
||||
const showField = (key, { value, unit, decimals, sub, lockedBy, readOnly, placeholder = "" }) => {
|
||||
const field = fields[key];
|
||||
if (!field) return;
|
||||
field.control.setRange({ decimals, minDecimals: 0, step: decimals ? 0.1 : 1, fineStep: decimals ? 0.01 : 1 });
|
||||
field.control.set(value);
|
||||
if (value == null) field.control.input.value = "";
|
||||
field.control.input.placeholder = placeholder;
|
||||
const unitSlot = field.control.root.querySelector(".ausboss-scrub-unit");
|
||||
if (unitSlot) unitSlot.textContent = unit;
|
||||
const tip = lockedBy ? `Set by ${lockedBy.title}: ${sub}. Click "linked" to go to that node.` : sub;
|
||||
disableControl(field.control, readOnly, tip);
|
||||
field.cell.title = tip;
|
||||
field.go.hidden = !lockedBy;
|
||||
if (lockedBy) {
|
||||
field.go.title = `Set by ${lockedBy.title}. Click to go to that node.`;
|
||||
field.go.onclick = () => lockedBy.go?.();
|
||||
}
|
||||
};
|
||||
const showNote = (text, kind = "", actions = []) => {
|
||||
if (!noteRow) return;
|
||||
noteRow.hidden = !text;
|
||||
noteRow.classList.toggle("warn", kind === "warn");
|
||||
noteText.textContent = text;
|
||||
noteButtons.forEach((button, index) => {
|
||||
const action = actions[index];
|
||||
button.hidden = !action;
|
||||
if (action) { button.textContent = action.label; button.onclick = () => { action.run(); sync(); onCommit?.(); }; }
|
||||
});
|
||||
};
|
||||
|
||||
const syncFields = (clip, current, wired, unknown) => {
|
||||
const seconds = getUnits() !== "f";
|
||||
for (const button of unitPill.children) button.classList.toggle("on", button.dataset.units === (seconds ? "s" : "f"));
|
||||
const rate = outFps();
|
||||
const rateText = rate > 0 ? `${formatFps(rate)} fps` : "the output rate";
|
||||
const first = current.first;
|
||||
const endSec = unknown ? null : endSecondsOf(current);
|
||||
const frames = unknown ? null : current.frames;
|
||||
const startLink = locked("start") ? linkInfo(driven("start_frame") ? "start_frame" : "start_seconds") : null;
|
||||
const lengthLink = current.mode === "wired" && wired ? linkInfo(wired) : null;
|
||||
const endLink = endDriven() && current.mode === "free" ? linkInfo(driven("end_frame") ? "end_frame" : "end_seconds") : null;
|
||||
const room = roomFrames();
|
||||
const fills = durationFills(current);
|
||||
|
||||
showField("start", {
|
||||
value: seconds ? frameTime(first, clip) : first,
|
||||
unit: seconds ? "s" : "fr", decimals: seconds ? 2 : 0,
|
||||
sub: seconds ? `source frame ${first}` : `source frame · ${secondsText(frameTime(first, clip))} s`,
|
||||
lockedBy: startLink, readOnly: locked("start"),
|
||||
});
|
||||
|
||||
// Duration: what was asked for (a Duration longer than what is left
|
||||
// only caps the clip), in clip frames or seconds at the output rate.
|
||||
const asked = current.mode === "wired" ? current.requested ?? current.frames : current.mode === "length" ? current.requested : frames;
|
||||
let durationSub;
|
||||
if (current.mode === "wired" && current.frames == null && current.requested == null) {
|
||||
durationSub = room != null && rate > 0 ? `up to ${secondsText(room / rate)} s (${room} frames) fit after this start` : "set when the graph runs";
|
||||
} else if (current.mode === "wired" && wired !== "fixed_frames" && current.truncated) {
|
||||
durationSub = `the video ends first: ${frames} frames${rate > 0 ? ` (${secondsText(frames / rate)} s)` : ""}`;
|
||||
} else if (current.mode === "wired") {
|
||||
durationSub = wired === "fixed_frames" ? `${asked} clip frames required` : `up to ${asked} clip frames`;
|
||||
} else if (frames == null) {
|
||||
durationSub = "frame count at run time";
|
||||
} else if (current.truncated) {
|
||||
durationSub = `the video ends first: ${frames} frames${rate > 0 ? ` (${secondsText(frames / rate)} s)` : ""}`;
|
||||
} else {
|
||||
durationSub = seconds ? `${frames} clip frames at ${rateText}` : rate > 0 ? `clip frames · ${secondsText(frames / rate)} s at ${rateText}` : "seconds known at run time";
|
||||
}
|
||||
const durationInSeconds = seconds && rate > 0;
|
||||
showField("duration", {
|
||||
value: asked == null ? null : durationInSeconds ? asked / rate : asked,
|
||||
unit: durationInSeconds ? "s" : "fr", decimals: durationInSeconds ? 2 : 0,
|
||||
sub: durationSub, lockedBy: lengthLink,
|
||||
readOnly: current.mode === "wired" || Boolean(endLink) || asked == null,
|
||||
placeholder: current.mode === "wired" && asked == null ? "at run time" : "",
|
||||
});
|
||||
|
||||
const lastSource = endSec == null ? null : Math.min(clip.count - 1, Math.max(first, Math.ceil(endSec * clip.fps - 1e-7) - 1));
|
||||
showField("end", {
|
||||
value: endSec == null ? null : seconds ? endSec : lastSource,
|
||||
unit: seconds ? "s" : "fr", decimals: seconds ? 2 : 0,
|
||||
sub: endSec == null ? "known after the run" : seconds ? `last source frame ${lastSource}` : `last source frame · ${secondsText(endSec)} s`,
|
||||
lockedBy: endLink, readOnly: current.mode === "wired" || Boolean(endLink) || endSec == null,
|
||||
placeholder: endSec == null ? "after Run" : "",
|
||||
});
|
||||
|
||||
// The clip in words.
|
||||
if (endSec == null) {
|
||||
clipLine.textContent = `Clip from ${seconds ? `${secondsText(frameTime(first, clip))} s` : `src fr ${first}`} · length set when the graph runs`;
|
||||
} else {
|
||||
const span = seconds
|
||||
? `Clip ${secondsText(frameTime(first, clip))} → ${secondsText(endSec)} s`
|
||||
: `Clip src fr ${first} → ${lastSource}`;
|
||||
clipLine.textContent = `${span} · ${frames} frames out`;
|
||||
}
|
||||
|
||||
// What needs saying: a start that leaves too little video, a linked
|
||||
// exact count that does not fit, or a drag that stopped at the end.
|
||||
const latest = current.mode === "length" ? latestIn(current) : current.latestStart;
|
||||
if (current.mode === "wired" && wired === "fixed_frames" && current.tooLong) {
|
||||
showNote(`Needs ${asked} frames; the video is shorter.`, "warn");
|
||||
} else if (current.mode === "wired" && wired === "fixed_frames" && latest != null && first > latest && !unknown) {
|
||||
showNote(`Needs ${asked} frames; only ${room ?? "fewer"} fit from here. The run will fail.`, "warn",
|
||||
locked("start") ? [] : [{ label: `Move start to ${secondsText(latest / clip.fps)} s`, run: () => writeStart(latest) }]);
|
||||
} else if (current.mode === "length" && current.truncated && !fills) {
|
||||
const actions = [{ label: `Shorten to ${rate > 0 ? `${secondsText(frames / rate)} s` : `${frames} frames`}`, run: () => { set("max_frames", Math.max(1, frames)); set("end_seconds", 0); } }];
|
||||
if (!locked("start") && latest != null && latest < first) actions.push({ label: `Move start to ${secondsText(latest / clip.fps)} s`, run: () => writeStart(latest) });
|
||||
showNote(`Only ${frames} of ${current.requested} frames fit from here.`, "warn", actions);
|
||||
} else if (current.mode === "wired" && wired !== "fixed_frames" && current.truncated && frames != null) {
|
||||
showNote(`Video ends first: ${frames} of ${asked} frames.`);
|
||||
} else if (current.mode === "length" && fills && current.truncated) {
|
||||
showNote("Runs to the end of the video.");
|
||||
} else if (stopNote) {
|
||||
showNote(stopNote);
|
||||
} else {
|
||||
showNote("");
|
||||
}
|
||||
|
||||
publish?.(endSec == null || frames == null ? null : { frames, startSeconds: frameTime(first, clip), endSeconds: endSec, roomFrames: room });
|
||||
};
|
||||
|
||||
if (trim) {
|
||||
const sampling = el("div", "ausboss-transform-trim-line wrap");
|
||||
const nthLabel = el("label", "", "Every nth");
|
||||
controls.every_nth = makeScrubInput({ value: get("every_nth", 1), min: 1, max: 512, step: 1, decimals: 0,
|
||||
title: "Keep one frame in this many. Output fps is adjusted to keep real-time playback; a Length counts the frames kept.",
|
||||
title: "Keep one frame in this many. Output fps is adjusted to keep real-time playback; the Duration counts the frames kept.",
|
||||
onChange: (next) => { if (!driven("every_nth")) set("every_nth", next); sync(); }, onSettle: onCommit,
|
||||
});
|
||||
nthLabel.append(controls.every_nth.root);
|
||||
@@ -648,15 +864,20 @@ export function mountTransformTrim({ get, set, has = () => true, driven = () =>
|
||||
reset.type = "button";
|
||||
reset.addEventListener("click", () => {
|
||||
const current = plan();
|
||||
if (current.mode === "free") {
|
||||
if (current.mode !== "wired") {
|
||||
// The whole video: no start, no end, no Duration limit.
|
||||
if (!locked("start")) set("start_seconds", 0);
|
||||
if (!locked("end")) set("end_seconds", 0);
|
||||
sync(); onCommit?.();
|
||||
if (!endDriven()) set("end_seconds", 0);
|
||||
set("max_frames", 0);
|
||||
if (!driven("fixed_frames")) set("fixed_frames", 0);
|
||||
stopNote = "";
|
||||
seek(0, true); onCommit?.();
|
||||
} else {
|
||||
moveEdge("start", 0, true);
|
||||
}
|
||||
});
|
||||
footer.append(summary, reset);
|
||||
sampling.append(unitPill);
|
||||
footer.append(useStart, el("span", "spacer"), reset);
|
||||
root.append(sampling, footer);
|
||||
}
|
||||
root.addEventListener("pointerdown", (event) => {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// panel's hidden storage widget stays hidden whichever renderer is on.
|
||||
|
||||
const STASH = "__ausbossVisibilityStash";
|
||||
const PAINT_KEYS = ["computeSize", "computeLayoutSize", "draw"];
|
||||
|
||||
// Collapse a widget to zero height. Returns true when this call changed
|
||||
// visibility, false when it was already hidden (callers use the return to
|
||||
@@ -27,6 +28,10 @@ export function hideWidget(widget) {
|
||||
computeSize: widget.computeSize,
|
||||
computeLayoutSize: widget.computeLayoutSize,
|
||||
draw: widget.draw,
|
||||
// Which of the three the widget carried itself. One it lacked is deleted
|
||||
// again on show: left behind as `undefined`, the frontend takes it for a
|
||||
// custom-drawn widget and App mode draws an empty row.
|
||||
own: Object.fromEntries(PAINT_KEYS.map((key) => [key, Object.prototype.hasOwnProperty.call(widget, key)])),
|
||||
hidden: widget.hidden,
|
||||
optionsHidden: options.hidden,
|
||||
optionsDescriptor: Object.getOwnPropertyDescriptor(widget, "options"),
|
||||
@@ -61,9 +66,10 @@ export function hideWidget(widget) {
|
||||
export function showWidget(widget) {
|
||||
const stash = widget?.[STASH];
|
||||
if (!stash) return false;
|
||||
widget.computeSize = stash.computeSize;
|
||||
widget.computeLayoutSize = stash.computeLayoutSize;
|
||||
widget.draw = stash.draw;
|
||||
for (const key of PAINT_KEYS) {
|
||||
if (stash.own && !stash.own[key]) delete widget[key];
|
||||
else widget[key] = stash[key];
|
||||
}
|
||||
widget.hidden = stash.hidden;
|
||||
const options = widget.options;
|
||||
try {
|
||||
@@ -84,6 +90,11 @@ export function showWidget(widget) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// True while hideWidget holds the widget hidden.
|
||||
export function isWidgetHidden(widget) {
|
||||
return Boolean(widget?.[STASH]);
|
||||
}
|
||||
|
||||
// Drive a widget toward a target visibility; true when anything changed.
|
||||
export function setWidgetVisible(widget, visible) {
|
||||
return visible ? showWidget(widget) : hideWidget(widget);
|
||||
|
||||
@@ -213,6 +213,19 @@ export function matchInstalled(name, files) {
|
||||
return loose ? { found: true, path: loose } : { found: false, path: null };
|
||||
}
|
||||
|
||||
// The copy of `name` to pick without asking: the exact path when the folder
|
||||
// has it, else the only file of that name in any subfolder. Two copies in
|
||||
// different subfolders give null: which one to use is the user's choice.
|
||||
export function onlyCopy(name, files) {
|
||||
const match = matchInstalled(name, files);
|
||||
if (!match.found) return null;
|
||||
const wanted = str(name, 1000).trim().replace(/\\/g, "/").toLowerCase();
|
||||
if (match.path.toLowerCase() === wanted) return match.path;
|
||||
const base = baseName(name).toLowerCase();
|
||||
const copies = files.filter((file) => baseName(str(file, 1000).replace(/\\/g, "/")).toLowerCase() === base);
|
||||
return copies.length === 1 ? match.path : null;
|
||||
}
|
||||
|
||||
// Node packs present in a graph, from each node type's python_module
|
||||
// ("custom_nodes.ComfyUI-AusBoss"). Core modules ("nodes",
|
||||
// "comfy_extras.*") are skipped: nobody needs to install those. The first
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
unionOf,
|
||||
} from "../shared/snap_lines.mjs";
|
||||
import { boundsOf, nodeElements, outlineOf } from "../shared/outline.mjs";
|
||||
import { TILE_MOVE } from "../shared/tile_face.mjs";
|
||||
|
||||
// Snap into line: a node or group being dragged lines up with the nodes and
|
||||
// groups around it, and a teal line shows what it lines up with. A corner
|
||||
@@ -294,6 +295,13 @@ function onPointerMove(event) {
|
||||
});
|
||||
}
|
||||
|
||||
// A frameless tile moves itself and keeps its pointer moves to itself
|
||||
// (js/shared/tile_face.mjs), then reports each move here once placed.
|
||||
function onTileMove(event) {
|
||||
if (!state.before || !event.detail) return;
|
||||
step(event.detail);
|
||||
}
|
||||
|
||||
function end() {
|
||||
state.before = null;
|
||||
state.corner = null;
|
||||
@@ -348,6 +356,7 @@ function install() {
|
||||
window.addEventListener("pointerdown", onPointerDown, true);
|
||||
window.addEventListener("pointerdown", afterPointerDown);
|
||||
window.addEventListener("pointermove", onPointerMove);
|
||||
window.addEventListener(TILE_MOVE, onTileMove);
|
||||
// Capture phase: the classic canvas stops its pointerup from bubbling.
|
||||
window.addEventListener("pointerup", end, true);
|
||||
window.addEventListener("pointercancel", end, true);
|
||||
|
||||
@@ -12,6 +12,7 @@ import { formatWidgetVisibility } from "../shared/save_video_formats.mjs";
|
||||
import { hideInputsInDef } from "../shared/widget_visibility.mjs";
|
||||
import { castChips } from "../shared/h3_cast_chips.mjs";
|
||||
import { clipSetsDuration } from "../shared/h3_duration.mjs";
|
||||
import { loadImagePreview, loadImageStrip } from "../shared/load_image_strip.mjs";
|
||||
import { momentStrip } from "../shared/moment_strip.mjs";
|
||||
import { mountWidgetCard } from "../shared/widget_card.mjs";
|
||||
import { FONT_UI, THEME } from "../shared/theme.mjs";
|
||||
@@ -27,6 +28,9 @@ import { valueToTake, wiredLimits } from "../shared/wired_limits.mjs";
|
||||
const viewUrl = (value) => api.apiURL(`/view?${mediaViewQuery(value)}`);
|
||||
|
||||
const isMode = (name, ...modes) => (values) => modes.includes(values[name]);
|
||||
// Load Image: the choices that read the width and height boxes.
|
||||
const loadImageUsesBox = (values) => ["fit inside", "crop to fill", "crop"].includes(values.size)
|
||||
|| (values.size === "crop to ratio" && values.ratio === "width : height");
|
||||
// Stitch Inpaint: Seam lives in the card's gear menu (shared/stitch_seam.mjs
|
||||
// holds the menu and the rules). The gear in the card's corner opens the
|
||||
// menu; a "blend in" chip beside it shows the mode at a glance and opens the
|
||||
@@ -129,7 +133,13 @@ const CARDS = {
|
||||
{ widget: "tolerance", label: "Tolerance", decimals: 2, suffix: "×" },
|
||||
],
|
||||
},
|
||||
AUSBOSS_NODES_EditLockRestore: { minWidth: 300, rows: [{ widget: "feather", label: "Feather", suffix: "px" }] },
|
||||
AUSBOSS_NODES_EditLockRestore: {
|
||||
minWidth: 300,
|
||||
rows: [
|
||||
{ widget: "feather", label: "Feather", suffix: "px" },
|
||||
{ widget: "remove_tint", label: "Remove tint" },
|
||||
],
|
||||
},
|
||||
AUSBOSS_NODES_ColorMatch: {
|
||||
minWidth: 300,
|
||||
rows: [
|
||||
@@ -414,24 +424,50 @@ const CARDS = {
|
||||
],
|
||||
},
|
||||
AUSBOSS_NODES_LoadVideo: {
|
||||
minWidth: 320, first: true, hide: ["upload"],
|
||||
// Every nth and the frame limit (as Duration) are in the timing card
|
||||
// under the player (js/load_video). The card hides them, so App mode can
|
||||
// still show them as fields.
|
||||
minWidth: 320, first: true, hide: ["upload", "every_nth", "max_frames"],
|
||||
rows: [
|
||||
{ widget: "video", label: "Source", kind: "select", preview: { kind: "video", url: viewUrl },
|
||||
button: { text: PANEL_LABELS.load, title: "Upload a video into ComfyUI's input folder", onClick: (node) => node.widgets?.find((w) => w.name === "upload")?.callback?.() } },
|
||||
{ widget: "custom_width", label: "Width", suffix: "px", title: "0 keeps the source width; set one side only to keep the aspect." },
|
||||
{ widget: "custom_height", label: "Height", suffix: "px", title: "0 keeps the source height; set one side only to keep the aspect." },
|
||||
{ widget: "every_nth", label: "Every nth" },
|
||||
{ widget: "max_frames", label: "Limit" },
|
||||
],
|
||||
},
|
||||
AUSBOSS_NODES_LoadAudio: {
|
||||
// The wave, IN and OUT live in the panel under the card (js/load_audio).
|
||||
minWidth: 280, first: true, hide: ["upload"],
|
||||
// The wave and Start, Duration and Ends at live in the panel under the
|
||||
// card (js/load_audio); max_seconds is the Duration there. The card
|
||||
// hides it, so App mode can still show it as a field.
|
||||
minWidth: 280, first: true, hide: ["upload", "max_seconds"],
|
||||
rows: [
|
||||
{ widget: "audio", label: "Source", kind: "select",
|
||||
button: { text: PANEL_LABELS.load, title: "Upload a sound file into ComfyUI's input folder", onClick: (node) => node.widgets?.find((w) => w.name === "upload")?.callback?.() } },
|
||||
{ widget: "max_seconds", label: "Max length", suffix: "s", decimals: 1, trimZeros: true,
|
||||
title: "The longest the sound may be. Anything past it is cut off and shows in red. 0 means no limit." },
|
||||
],
|
||||
},
|
||||
// Load Image: the file, then where it is in the folder and the size it
|
||||
// goes in and comes out at, then the size settings. ComfyUI's own picture
|
||||
// preview sits under the card, so its mask editor and copy and paste work
|
||||
// as they do on the stock loader.
|
||||
AUSBOSS_NODES_LoadImage: {
|
||||
minWidth: 320, first: true, hide: ["upload"],
|
||||
rows: [
|
||||
{ widget: "image", label: "Source", kind: "select", preview: { kind: "image", url: viewUrl },
|
||||
button: { text: PANEL_LABELS.load, title: "Upload a picture into ComfyUI's input folder", onClick: (node) => node.widgets?.find((w) => w.name === "upload")?.callback?.() } },
|
||||
{ panel: loadImageStrip, height: 26 },
|
||||
{ panel: loadImagePreview, height: 72 },
|
||||
{ widget: "size", label: "Size", kind: "select" },
|
||||
{ widget: "megapixels", label: "Megapixels", suffix: "MP", when: isMode("size", "megapixels") },
|
||||
{ widget: "longest_side", label: "Longest side", suffix: "px", when: isMode("size", "longest side") },
|
||||
{ widget: "scale", label: "Scale", suffix: "\u00d7", when: isMode("size", "scale") },
|
||||
{ widget: "ratio", label: "Ratio", kind: "select", when: isMode("size", "crop to ratio") },
|
||||
{ widget: "width", label: "Width", suffix: "px", when: loadImageUsesBox },
|
||||
{ widget: "height", label: "Height", suffix: "px", when: loadImageUsesBox },
|
||||
{ widget: "crop_from", label: "Keep", kind: "select", when: isMode("size", "crop to fill", "crop", "crop to ratio") },
|
||||
{ widget: "multiple", label: "Round to", snap: true, step: 8, when: (values) => values.size !== "off" },
|
||||
{ group: "more", label: "More" },
|
||||
{ widget: "method", label: "Method", kind: "select", group: "more" },
|
||||
{ widget: "enlarge", label: "Enlarge", group: "more" },
|
||||
],
|
||||
},
|
||||
AUSBOSS_NODES_LoadImagePad: {
|
||||
|
||||
+61
-19
@@ -15,7 +15,7 @@ import { app } from "../../../scripts/app.js";
|
||||
import { setTileFace, TILE_FACE_CSS } from "../shared/tile_face.mjs";
|
||||
import { NOTE_TYPES, serializeNoteIdentity } from "../shared/note_identity.mjs";
|
||||
import { compactAction } from "../shared/panel_controls.mjs";
|
||||
import { BRAND, chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange } from "../shared/index.mjs";
|
||||
import { BRAND, chainCallback, keepDomWidgetWidthAuto, notifyAusbossChange, showToast } from "../shared/index.mjs";
|
||||
import { collectGraphNodes } from "../shared/appearance.mjs";
|
||||
import { copyToClipboard } from "../shared/clipboard.mjs";
|
||||
import { confirmDiscard } from "../shared/discard_prompt.mjs";
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
noteIsEmpty,
|
||||
noteShowsTileFace,
|
||||
normalizeNote,
|
||||
onlyCopy,
|
||||
packsFromGraph,
|
||||
parseMarkdown,
|
||||
rowFromCells,
|
||||
@@ -46,8 +47,36 @@ import {
|
||||
} from "../shared/workflow_note.mjs";
|
||||
import { comboValues, commitWidgetValue } from "../shared/widget_card_math.mjs";
|
||||
import { parseRows, serializeRows } from "../shared/lora_stack.mjs";
|
||||
import { isFileWidget } from "../shared/lora_file_widgets.mjs";
|
||||
|
||||
const CSS_ID = "ausboss-workflow-note-css";
|
||||
const PICK_FOUND_SETTING = "AusBoss.Models.PickFoundCopy";
|
||||
|
||||
function pickFoundCopies() {
|
||||
return app.ui?.settings?.getSettingValue?.(PICK_FOUND_SETTING) !== false;
|
||||
}
|
||||
|
||||
// Point the loaders (and LoRA Loader rows) that ask for a file by another
|
||||
// spelling at the copy the note found. Returns how many it changed.
|
||||
function useFoundCopy(path, loaders, loraRows, files) {
|
||||
for (const entry of loaders) {
|
||||
commitWidgetValue(entry.node, entry.widget, listedSpelling(path, entry.options), app.canvas);
|
||||
entry.node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
const stacks = new Map();
|
||||
for (const entry of loraRows) stacks.set(entry.widget, [...(stacks.get(entry.widget) ?? []), entry]);
|
||||
for (const [widget, entries] of stacks) {
|
||||
const rows = parseRows(widget.value);
|
||||
for (const entry of entries) {
|
||||
if (rows[entry.index]) rows[entry.index] = { ...rows[entry.index], name: listedSpelling(path, files) };
|
||||
}
|
||||
commitWidgetValue(entries[0].node, widget, serializeRows(rows), app.canvas);
|
||||
entries[0].node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
app.graph?.setDirtyCanvas?.(true, true);
|
||||
notifyAusbossChange();
|
||||
return loaders.length + loraRows.length;
|
||||
}
|
||||
const WIDGET_NAME = "ausboss_workflow_note_panel";
|
||||
const PANEL_MIN_WIDTH = 300;
|
||||
const CARD_MIN_HEIGHT = 160;
|
||||
@@ -417,22 +446,7 @@ function modelRow(state, row) {
|
||||
use.title = `Point ${names} at ${path}.`;
|
||||
use.addEventListener("pointerdown", (event) => event.stopPropagation());
|
||||
use.addEventListener("click", () => {
|
||||
for (const entry of loaders) {
|
||||
commitWidgetValue(entry.node, entry.widget, listedSpelling(path, entry.options), app.canvas);
|
||||
entry.node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
const stacks = new Map();
|
||||
for (const entry of loraRows) stacks.set(entry.widget, [...(stacks.get(entry.widget) ?? []), entry]);
|
||||
for (const [widget, entries] of stacks) {
|
||||
const rows = parseRows(widget.value);
|
||||
for (const entry of entries) {
|
||||
if (rows[entry.index]) rows[entry.index] = { ...rows[entry.index], name: listedSpelling(path, files) };
|
||||
}
|
||||
commitWidgetValue(entries[0].node, widget, serializeRows(rows), app.canvas);
|
||||
entries[0].node.setDirtyCanvas?.(true, true);
|
||||
}
|
||||
app.graph?.setDirtyCanvas?.(true, true);
|
||||
notifyAusbossChange();
|
||||
useFoundCopy(path, loaders, loraRows, files);
|
||||
checkModels(state, false);
|
||||
});
|
||||
action.append(pill, use);
|
||||
@@ -628,6 +642,7 @@ function renderSections(state, scroll) {
|
||||
async function checkModels(state, fresh) {
|
||||
const generation = (state.checkGeneration = (state.checkGeneration || 0) + 1);
|
||||
const rows = state.rows;
|
||||
const picked = [];
|
||||
for (const entry of rows) setDot(entry.dot, "checking", "checking…");
|
||||
const byDir = new Map();
|
||||
for (const entry of rows) {
|
||||
@@ -666,7 +681,14 @@ async function checkModels(state, fresh) {
|
||||
const elsewhere = match.found && subfolderOf(match.path);
|
||||
const loaders = elsewhere ? loadersNeeding(entry.row.name, match.path, graphListWidgets()) : [];
|
||||
const loraRows = elsewhere ? loraRowsNeeding(entry.row.name, match.path, graphLoraLoaders(), files) : [];
|
||||
if (match.found && (loaders.length || loraRows.length)) {
|
||||
if (match.found && (loaders.length || loraRows.length) && pickFoundCopies() && onlyCopy(entry.row.name, files) === match.path) {
|
||||
// One copy, so nothing to choose: the loaders take it without a
|
||||
// click (App mode shows no Guide to click in).
|
||||
useFoundCopy(match.path, loaders, loraRows, files);
|
||||
picked.push(match.path);
|
||||
setDot(entry.dot, "ok", `Found in ${subfolderOf(match.path)}/ and picked: ${match.path}`);
|
||||
entry.showInstalled(match.path);
|
||||
} else if (match.found && (loaders.length || loraRows.length)) {
|
||||
setDot(entry.dot, "ok", `Found in ${subfolderOf(match.path)}/: ${match.path}`);
|
||||
entry.showElsewhere(match.path, loaders, loraRows, files);
|
||||
} else if (match.found) {
|
||||
@@ -678,6 +700,14 @@ async function checkModels(state, fresh) {
|
||||
}
|
||||
}
|
||||
}));
|
||||
if (picked.length && generation === state.checkGeneration) {
|
||||
const folders = [...new Set(picked.map(subfolderOf))].map((folder) => `${folder}/`).join(", ");
|
||||
showToast({
|
||||
summary: "Models found",
|
||||
detail: `${picked.length === 1 ? "1 model file" : `${picked.length} model files`} found in ${folders} and picked for this workflow.`,
|
||||
life: 4000,
|
||||
});
|
||||
}
|
||||
if (state.domWidget && generation === state.checkGeneration) fitNote(state);
|
||||
}
|
||||
|
||||
@@ -756,7 +786,7 @@ function graphListWidgets() {
|
||||
seen.add(graph);
|
||||
for (const node of graph._nodes ?? graph.nodes ?? []) {
|
||||
for (const widget of node.widgets ?? []) {
|
||||
if (widget?.type !== "combo" || typeof widget.value !== "string") continue;
|
||||
if (widget?.type !== "combo" || typeof widget.value !== "string" || isFileWidget(widget)) continue;
|
||||
out.push({ node, widget, value: widget.value, options: comboValues(widget) });
|
||||
}
|
||||
if (node.subgraph) walk(node.subgraph);
|
||||
@@ -1178,6 +1208,18 @@ function buildPanel(node) {
|
||||
|
||||
app.registerExtension({
|
||||
name: "AusBoss.WorkflowNote",
|
||||
settings: [
|
||||
{
|
||||
id: PICK_FOUND_SETTING,
|
||||
name: "Pick model files found in a subfolder",
|
||||
type: "boolean",
|
||||
defaultValue: true,
|
||||
category: ["🆎 AusBoss", "Models", "Pick found files"],
|
||||
tooltip:
|
||||
"When a workflow's Guide finds a model you already have in a subfolder, the workflow switches to that "
|
||||
+ "file by itself. Off: the Guide shows a Use it button instead.",
|
||||
},
|
||||
],
|
||||
beforeRegisterNodeDef(nodeType, nodeData) {
|
||||
if (!NOTE_TYPES.has(nodeData?.name)) return;
|
||||
hideInputsInDef(nodeData, ["note"]);
|
||||
|
||||
@@ -651,6 +651,71 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AUSBOSS_NODES_LoadImage": {
|
||||
"display_name": "加载图像 🆎",
|
||||
"description": "在同一个节点里加载图片并设定尺寸。可以选择文件、上传,或用箭头逐张浏览输入文件夹。尺寸可以关闭,也可以按百万像素、最长边、缩放倍数、放入一个框内,或裁剪填满一个框来调整。也可以不缩放,直接从图片中裁出一块或裁成某个比例,并选择保留哪一边。运行之前,节点就会显示输入和输出的图片及两者的尺寸。",
|
||||
"inputs": {
|
||||
"image": {
|
||||
"name": "图像"
|
||||
},
|
||||
"size": {
|
||||
"name": "尺寸"
|
||||
},
|
||||
"megapixels": {
|
||||
"name": "百万像素"
|
||||
},
|
||||
"longest_side": {
|
||||
"name": "最长边"
|
||||
},
|
||||
"scale": {
|
||||
"name": "缩放倍数"
|
||||
},
|
||||
"width": {
|
||||
"name": "宽度"
|
||||
},
|
||||
"height": {
|
||||
"name": "高度"
|
||||
},
|
||||
"multiple": {
|
||||
"name": "取整倍数"
|
||||
},
|
||||
"method": {
|
||||
"name": "插值"
|
||||
},
|
||||
"enlarge": {
|
||||
"name": "放大"
|
||||
},
|
||||
"crop_from": {
|
||||
"name": "保留部分"
|
||||
},
|
||||
"ratio": {
|
||||
"name": "比例"
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"0": {
|
||||
"name": "图像"
|
||||
},
|
||||
"1": {
|
||||
"name": "遮罩"
|
||||
},
|
||||
"2": {
|
||||
"name": "宽度"
|
||||
},
|
||||
"3": {
|
||||
"name": "高度"
|
||||
},
|
||||
"4": {
|
||||
"name": "文件名"
|
||||
},
|
||||
"5": {
|
||||
"name": "原始宽度"
|
||||
},
|
||||
"6": {
|
||||
"name": "原始高度"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AUSBOSS_NODES_LoadImagePad": {
|
||||
"display_name": "加载图像 + 扩边 🆎",
|
||||
"description": "在一个节点里加载图像并扩边成扩图画布。拖动节点上画布的任意一边,直观地设置每边的扩边量;遮罩正好覆盖新扩出的部分,可选择向内羽化跨过接缝。画布会取整到整数倍,但不会给你没扩的边加条带;设置百万像素目标时会先缩放原图,让遮罩接缝保持清晰。",
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
"""Edit Lock Restore's tint fix: take out the even tint an edit model adds to the whole picture.
|
||||
|
||||
MiniMax H3 Image gives every edit one even color shift: a little lighter,
|
||||
pinker and bluer (Lab L +1 to +3, a +2 to +7, b -1 to -6 at 16 MP). Edit
|
||||
Lock removes it wherever it locks, because those parts are your picture
|
||||
again. When the lock steps aside (new hair color, new background, rain) the
|
||||
shift stays. Here it is read from the part of the picture the edit left
|
||||
alone and subtracted from every pixel.
|
||||
|
||||
A shift is only taken out when it looks like that tint. An edit that is
|
||||
meant to recolor everything (golden hour, red light, a restyle) moves the
|
||||
colors much further or the other way, or leaves too little of the picture
|
||||
alone to read anything, and passes through untouched.
|
||||
|
||||
Pure torch, no ComfyUI imports.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
|
||||
from ._realign_helpers import measure, warp_to_source
|
||||
|
||||
# The pictures are compared at this long side; the fit is sub-pixel there.
|
||||
WORK = 1536
|
||||
# Cells closer than this to the running estimate count as "left alone".
|
||||
NEAR = 4.0
|
||||
# The tint as measured on 57 edits: lighter, pinker, bluer, within these
|
||||
# bounds (Lab units). Smaller than MIN_A is not worth touching.
|
||||
MIN_A = 0.5
|
||||
MAX_A = 10.0
|
||||
MAX_B = 0.0
|
||||
MIN_B = -8.0
|
||||
MIN_L = -1.0
|
||||
MAX_L = 6.0
|
||||
# At least this share of the picture must be left alone to read the tint.
|
||||
MIN_SHARE = 0.15
|
||||
|
||||
_D65 = (0.95047, 1.0, 1.08883)
|
||||
_TO_XYZ = ((0.4124564, 0.3575761, 0.1804375),
|
||||
(0.2126729, 0.7151522, 0.0721750),
|
||||
(0.0193339, 0.1191920, 0.9503041))
|
||||
_TO_RGB = ((3.2404542, -1.5371385, -0.4985314),
|
||||
(-0.9692660, 1.8760108, 0.0415560),
|
||||
(0.0556434, -0.2040259, 1.0572252))
|
||||
|
||||
|
||||
def rgb_to_lab(rgb: torch.Tensor) -> torch.Tensor:
|
||||
"""sRGB in 0..1, [..., 3] -> CIE Lab, float64."""
|
||||
x = rgb.double().clamp(0.0, 1.0)
|
||||
linear = torch.where(x > 0.04045, ((x + 0.055) / 1.055) ** 2.4, x / 12.92)
|
||||
xyz = linear @ torch.tensor(_TO_XYZ, dtype=torch.float64).T / torch.tensor(_D65, dtype=torch.float64)
|
||||
f = torch.where(xyz > 0.008856, xyz.clamp(min=1e-9) ** (1.0 / 3.0), 7.787 * xyz + 16.0 / 116.0)
|
||||
return torch.stack([116.0 * f[..., 1] - 16.0, 500.0 * (f[..., 0] - f[..., 1]),
|
||||
200.0 * (f[..., 1] - f[..., 2])], -1)
|
||||
|
||||
|
||||
def lab_to_rgb(lab: torch.Tensor) -> torch.Tensor:
|
||||
"""CIE Lab, [..., 3] -> sRGB in 0..1, float64."""
|
||||
fy = (lab[..., 0] + 16.0) / 116.0
|
||||
f = torch.stack([fy + lab[..., 1] / 500.0, fy, fy - lab[..., 2] / 200.0], -1)
|
||||
xyz = torch.where(f > 0.206893, f ** 3, (f - 16.0 / 116.0) / 7.787) * torch.tensor(_D65, dtype=torch.float64)
|
||||
linear = (xyz @ torch.tensor(_TO_RGB, dtype=torch.float64).T).clamp(0.0, 1.0)
|
||||
return torch.where(linear > 0.0031308, 1.055 * linear ** (1.0 / 2.4) - 0.055, 12.92 * linear).clamp(0.0, 1.0)
|
||||
|
||||
|
||||
def _fit(image: torch.Tensor, long_side: int) -> torch.Tensor:
|
||||
"""HWC float at most long_side px on its long side."""
|
||||
height, width = int(image.shape[0]), int(image.shape[1])
|
||||
scale = long_side / max(height, width)
|
||||
if scale >= 1.0:
|
||||
return image.float()
|
||||
size = (max(1, round(height * scale)), max(1, round(width * scale)))
|
||||
return F.interpolate(image.movedim(-1, 0)[None].float(), size=size, mode="bilinear",
|
||||
align_corners=False, antialias=True)[0].movedim(0, -1)
|
||||
|
||||
|
||||
def measure_tint(result: torch.Tensor, source: torch.Tensor) -> tuple[list[float] | None, float]:
|
||||
"""The even shift in (L, a, b) from source to result, read where the edit left the picture alone.
|
||||
|
||||
result, source: HWC float in 0..1, any sizes. Returns (shift or None, the
|
||||
share of the picture it was read on). The result is lined up with the
|
||||
source first, since edits often come back slightly zoomed or moved.
|
||||
"""
|
||||
src = _fit(source[..., :3], WORK)
|
||||
edit = _fit(result[..., :3], WORK)
|
||||
fit = measure(src, edit, mode="zoom + shift")
|
||||
if not fit.reliable:
|
||||
return None, 0.0
|
||||
height, width = int(src.shape[0]), int(src.shape[1])
|
||||
scaled = F.interpolate(edit.movedim(-1, 0)[None], size=(height, width), mode="bilinear",
|
||||
align_corners=False)[0].movedim(0, -1)
|
||||
try:
|
||||
warped = warp_to_source(scaled, fit.matrix, width, height)
|
||||
warped = warped[0] if isinstance(warped, tuple) else warped
|
||||
except Exception:
|
||||
warped = scaled
|
||||
# coarse cells of about 8 px at 1 MP, so grain and small detail drop out
|
||||
cell = max(4, round(8 / math.sqrt(1e6 / (width * height))))
|
||||
|
||||
def cells(img: torch.Tensor) -> torch.Tensor:
|
||||
return F.avg_pool2d(img.movedim(-1, 0)[None], cell, stride=cell)[0].movedim(0, -1)
|
||||
|
||||
diff = rgb_to_lab(cells(warped)) - rgb_to_lab(cells(src))
|
||||
margin = max(1, int(diff.shape[0]) // 12) # the edges carry the warp's filled strip
|
||||
diff = diff[margin:-margin, margin:-margin].reshape(-1, 3)
|
||||
if diff.shape[0] < 50:
|
||||
return None, 0.0
|
||||
centre = diff.median(0).values
|
||||
share = 1.0
|
||||
# start at the median change, then keep only the cells near it: a new
|
||||
# background or new hair is a big change, but not the same one everywhere
|
||||
for _ in range(5):
|
||||
near = (diff - centre).norm(dim=1) < NEAR
|
||||
if int(near.sum()) < 50:
|
||||
break
|
||||
centre = diff[near].mean(0)
|
||||
share = float(near.double().mean())
|
||||
return [float(v) for v in centre], share
|
||||
|
||||
|
||||
def looks_like_tint(shift: list[float] | None, share: float) -> bool:
|
||||
"""True for the model's own lighter-pinker-bluer shift; False for an intended recolor."""
|
||||
if shift is None or share < MIN_SHARE:
|
||||
return False
|
||||
light, a, b = shift
|
||||
return MIN_A <= a <= MAX_A and MIN_B <= b <= MAX_B and MIN_L <= light <= MAX_L
|
||||
|
||||
|
||||
def remove_tint(image: torch.Tensor, shift: list[float]) -> torch.Tensor:
|
||||
"""Subtract one (L, a, b) shift from every pixel. image: [B, H, W, C] in 0..1."""
|
||||
lab = rgb_to_lab(image[..., :3]) - torch.tensor(shift, dtype=torch.float64)
|
||||
out = image.clone()
|
||||
out[..., :3] = lab_to_rgb(lab).to(image.dtype)
|
||||
return out
|
||||
|
||||
|
||||
def take_out_tint(images: torch.Tensor, source: torch.Tensor) -> tuple[torch.Tensor, list[float] | None]:
|
||||
"""Each picture of the batch with its tint taken out when it looks like the model's tint.
|
||||
|
||||
Returns the pictures and the largest shift taken out (None when none was)."""
|
||||
out = images.clone()
|
||||
taken: list[float] | None = None
|
||||
for index in range(int(images.shape[0])):
|
||||
shift, share = measure_tint(images[index], source[0])
|
||||
if looks_like_tint(shift, share):
|
||||
out[index:index + 1] = remove_tint(images[index:index + 1], shift)
|
||||
if taken is None or abs(shift[1]) > abs(taken[1]):
|
||||
taken = shift
|
||||
return out, taken
|
||||
@@ -60,6 +60,26 @@ def add_module_version(source, token):
|
||||
return _MODULE_IMPORT.sub(lambda m: f"{m.group(1)}{m.group(2)}{m.group(3)}?v={token}{m.group(2)}", source)
|
||||
|
||||
|
||||
def list_served_scripts(js_root):
|
||||
"""The pack's own scripts by their address below the js folder:
|
||||
{"shared/index.mjs": <path>}. Made once at startup, so a request is
|
||||
only looked up in it and the address a browser sends never reaches the
|
||||
disk: no whole path, network share or ".." is ever opened. Links are
|
||||
left out, and anything that resolves outside the js folder."""
|
||||
root = Path(js_root).resolve()
|
||||
scripts = {}
|
||||
for path in sorted(root.rglob("*")):
|
||||
try:
|
||||
if path.suffix not in (".js", ".mjs") or path.is_symlink() or not path.is_file():
|
||||
continue
|
||||
if not path.resolve().is_relative_to(root):
|
||||
continue
|
||||
except OSError:
|
||||
continue
|
||||
scripts[path.relative_to(root).as_posix()] = path
|
||||
return scripts
|
||||
|
||||
|
||||
def make_revalidate_middleware(pack_name, js_root=None, token=None):
|
||||
"""aiohttp middleware for this pack's scripts, nothing else touched.
|
||||
|
||||
@@ -69,7 +89,7 @@ def make_revalidate_middleware(pack_name, js_root=None, token=None):
|
||||
from aiohttp import web
|
||||
|
||||
marker = f"/extensions/{pack_name}/"
|
||||
root = Path(js_root).resolve() if js_root and token else None
|
||||
scripts = list_served_scripts(js_root) if js_root and token else None
|
||||
served = {}
|
||||
|
||||
def versioned(path):
|
||||
@@ -90,15 +110,15 @@ def make_revalidate_middleware(pack_name, js_root=None, token=None):
|
||||
|
||||
def tagged_response(request):
|
||||
"""The tagged script for this request, or None to let ComfyUI serve it."""
|
||||
if root is None or request.method not in ("GET", "HEAD"):
|
||||
if not scripts or request.method not in ("GET", "HEAD"):
|
||||
return None
|
||||
start = request.path.find(marker)
|
||||
if start < 0 or not request.path.endswith((".js", ".mjs")):
|
||||
return None
|
||||
target = scripts.get(request.path[start + len(marker):])
|
||||
if target is None:
|
||||
return None
|
||||
try:
|
||||
target = (root / request.path[start + len(marker):]).resolve()
|
||||
if not target.is_relative_to(root) or not target.is_file():
|
||||
return None
|
||||
found = versioned(target)
|
||||
except (OSError, ValueError, UnicodeDecodeError):
|
||||
return None
|
||||
|
||||
@@ -82,9 +82,10 @@ def place_inside(folder, roots: dict) -> tuple[str, str] | None:
|
||||
This compares text only. A path that is outside those folders is never
|
||||
looked up on disk, and one on another machine is refused from its text."""
|
||||
text = str(folder or "").strip().strip('"').replace("\\", "/")
|
||||
if not looks_full(text) or text.startswith("//"):
|
||||
# A "~" path is not expanded: only a path written out in full can match.
|
||||
if not looks_full(text) or text.startswith("//") or text.startswith("~"):
|
||||
return None
|
||||
full = os.path.normpath(os.path.expanduser(text))
|
||||
full = os.path.normpath(text)
|
||||
for source, root in roots.items():
|
||||
for base in {os.path.normpath(str(root)), os.path.realpath(str(root))}:
|
||||
if full == base:
|
||||
|
||||
@@ -6,18 +6,26 @@ that are wanted: they are copied into the output folder under the names the
|
||||
node would have given them. Everything here works from names this module
|
||||
made itself; the only thing a caller sends is the run's token and which
|
||||
pictures to keep.
|
||||
|
||||
What a run holds (its settings, its count, what was kept) stays in this
|
||||
process's memory, never in a file. ComfyUI's temp folder takes uploads, so a
|
||||
list read back from there could be anyone's. The held pictures themselves
|
||||
are named from the token, their number and one of the node's own formats,
|
||||
and must still be in the held folder when they are copied.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import secrets
|
||||
import shutil
|
||||
import threading
|
||||
|
||||
from ._image_save_helpers import (
|
||||
FORMAT_EXTENSIONS,
|
||||
IMAGE_SAVE_LOCK,
|
||||
existing_action,
|
||||
name_stem,
|
||||
@@ -34,6 +42,14 @@ from ._image_save_helpers import (
|
||||
HELD_FOLDER = "ausboss_held"
|
||||
_TOKEN = re.compile(r"^[0-9a-f]{16}$")
|
||||
GONE = "These pictures are no longer held. Run the workflow again."
|
||||
# The held pictures' formats: the extensions Save Image writes, nothing else.
|
||||
HELD_EXTENSIONS = frozenset(FORMAT_EXTENSIONS.values())
|
||||
# A run holds at most this many pictures, and the server remembers this many
|
||||
# runs; the oldest is forgotten first and then says GONE.
|
||||
MAX_HELD_PICTURES = 10000
|
||||
MAX_HELD_RUNS = 256
|
||||
_RUNS: "OrderedDict[str, dict]" = OrderedDict()
|
||||
_RUNS_LOCK = threading.Lock()
|
||||
|
||||
|
||||
def plan_destinations(settings: dict, count: int, now: datetime, root: Path, output_root: Path, picks=None):
|
||||
@@ -88,15 +104,31 @@ def settle_destinations(planned, has_caption: bool, output_root: Path) -> list[s
|
||||
|
||||
|
||||
def _held_name(token: str, index: int, extension: str) -> str:
|
||||
if not _TOKEN.match(token) or extension not in HELD_EXTENSIONS or not 0 <= index < MAX_HELD_PICTURES:
|
||||
raise ValueError("Save Image: that is not a picture it is holding.")
|
||||
return f"{token}_{index:03d}.{extension}"
|
||||
|
||||
|
||||
def _held_source(folder: Path, token: str, index: int, extension: str) -> Path:
|
||||
"""A held picture's file, which must still sit directly in the held folder."""
|
||||
source = folder / _held_name(token, index, extension)
|
||||
if not source.is_file() or source.is_symlink() or source.resolve().parent != folder.resolve():
|
||||
raise LookupError(GONE)
|
||||
return source
|
||||
|
||||
|
||||
def hold_pictures(temp_root, frames, settings: dict, encode) -> tuple[str, list[dict]]:
|
||||
"""Write a run's pictures to the temp folder and remember how to name them.
|
||||
|
||||
`encode(path, frame)` writes one picture in the run's format. Returns
|
||||
the run's token and the entries the node shows them from.
|
||||
"""
|
||||
frames = list(frames)
|
||||
if len(frames) > MAX_HELD_PICTURES:
|
||||
raise ValueError(
|
||||
f"Save Image: {len(frames)} pictures are too many to hold (at most {MAX_HELD_PICTURES}). "
|
||||
"Turn Auto save on to save them straight away."
|
||||
)
|
||||
folder = Path(temp_root) / HELD_FOLDER
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
token = secrets.token_hex(8)
|
||||
@@ -105,8 +137,10 @@ def hold_pictures(temp_root, frames, settings: dict, encode) -> tuple[str, list[
|
||||
name = _held_name(token, index, settings["extension"])
|
||||
encode(folder / name, frame)
|
||||
previews.append({"filename": name, "subfolder": HELD_FOLDER, "type": "temp"})
|
||||
manifest = dict(settings, count=len(previews), kept={})
|
||||
(folder / f"{token}.json").write_text(json.dumps(manifest), encoding="utf-8")
|
||||
with _RUNS_LOCK:
|
||||
_RUNS[token] = dict(settings, count=len(previews), kept={})
|
||||
while len(_RUNS) > MAX_HELD_RUNS:
|
||||
_RUNS.popitem(last=False)
|
||||
return token, previews
|
||||
|
||||
|
||||
@@ -119,16 +153,18 @@ def keep_pictures(temp_root, output_root, token, picks=None, now: datetime | Non
|
||||
if not isinstance(token, str) or not _TOKEN.match(token):
|
||||
raise ValueError("Save Image: that is not a run it is holding.")
|
||||
folder = Path(temp_root) / HELD_FOLDER
|
||||
manifest_path = folder / f"{token}.json"
|
||||
if not manifest_path.is_file():
|
||||
with _RUNS_LOCK:
|
||||
manifest = _RUNS.get(token)
|
||||
if manifest is None:
|
||||
raise LookupError(GONE)
|
||||
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
||||
count = int(manifest["count"])
|
||||
kept = {int(index): str(path) for index, path in dict(manifest.get("kept") or {}).items()}
|
||||
kept = dict(manifest["kept"])
|
||||
|
||||
if picks is None:
|
||||
wanted = list(range(count))
|
||||
else:
|
||||
if len(picks) > MAX_HELD_PICTURES:
|
||||
raise ValueError("Save Image: that picture is not in this run.")
|
||||
wanted = []
|
||||
for pick in picks:
|
||||
if isinstance(pick, bool) or not isinstance(pick, int) or not 0 <= pick < count:
|
||||
@@ -151,17 +187,14 @@ def keep_pictures(temp_root, output_root, token, picks=None, now: datetime | Non
|
||||
if action == "skip":
|
||||
skipped.append(index)
|
||||
continue
|
||||
source = folder / _held_name(token, index, manifest["extension"])
|
||||
if not source.is_file():
|
||||
raise LookupError(GONE)
|
||||
source = _held_source(folder, token, index, manifest["extension"])
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source, path)
|
||||
if has_caption:
|
||||
sidecar_path(path).write_text(caption, encoding="utf-8")
|
||||
kept[index] = path.resolve().relative_to(resolved_root).as_posix()
|
||||
saved.append(index)
|
||||
manifest["kept"] = {str(index): path for index, path in kept.items()}
|
||||
manifest_path.write_text(json.dumps(manifest), encoding="utf-8")
|
||||
manifest["kept"] = kept
|
||||
return {
|
||||
"count": count,
|
||||
"saved": [{"index": index, "path": kept[index]} for index in saved],
|
||||
|
||||
@@ -10,6 +10,7 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import secrets
|
||||
import threading
|
||||
from datetime import datetime
|
||||
from pathlib import Path, PurePosixPath, PureWindowsPath
|
||||
@@ -271,6 +272,36 @@ def frame_to_pil(frame: torch.Tensor) -> Image.Image:
|
||||
return Image.fromarray(array)
|
||||
|
||||
|
||||
# A small copy of each picture, for the node's face. The saved file can be
|
||||
# tens of megabytes; this one is a few hundred kilobytes, so the picture
|
||||
# shows at once on a slow connection too. It lives in the temp folder, which
|
||||
# ComfyUI empties when it starts.
|
||||
PREVIEW_FOLDER = "ausboss_preview"
|
||||
PREVIEW_EDGE = 2048
|
||||
|
||||
|
||||
def write_light_previews(temp_root, frames) -> list[str]:
|
||||
"""Write one small WebP per frame; returns each place below the temp folder.
|
||||
|
||||
Never in the way of a save: if anything goes wrong the list is empty
|
||||
and the node shows the saved file itself, as it always did.
|
||||
"""
|
||||
try:
|
||||
folder = Path(temp_root) / PREVIEW_FOLDER
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
token = secrets.token_hex(8)
|
||||
places = []
|
||||
for index, frame in enumerate(frames):
|
||||
image = frame_to_pil(frame)
|
||||
image.thumbnail((PREVIEW_EDGE, PREVIEW_EDGE), Image.Resampling.LANCZOS)
|
||||
name = f"{token}_{index:03d}.webp"
|
||||
image.save(folder / name, format="WEBP", quality=88, method=2)
|
||||
places.append(f"{PREVIEW_FOLDER}/{name}")
|
||||
return places
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
|
||||
def _png_info(metadata: dict | None):
|
||||
if not metadata:
|
||||
return None
|
||||
@@ -340,6 +371,8 @@ __all__ = [
|
||||
"IMAGE_FORMATS",
|
||||
"IMAGE_SAVE_LOCK",
|
||||
"OUTPUT_DIR_RULE",
|
||||
"PREVIEW_EDGE",
|
||||
"PREVIEW_FOLDER",
|
||||
"counter_pattern",
|
||||
"encode_image",
|
||||
"existing_action",
|
||||
@@ -357,4 +390,5 @@ __all__ = [
|
||||
"sidecar_path",
|
||||
"split_prefix",
|
||||
"strip_image_extension",
|
||||
"write_light_previews",
|
||||
]
|
||||
|
||||
@@ -61,11 +61,8 @@ def list_lama_models() -> list[str]:
|
||||
|
||||
def resolve_lama_model(model_name: str) -> Path:
|
||||
register_lama_model_folder()
|
||||
if folder_paths is None:
|
||||
path = Path(model_name).expanduser().resolve()
|
||||
if path.is_file():
|
||||
return path
|
||||
else:
|
||||
# Only a name from ComfyUI's lama model folder: a typed path is never opened.
|
||||
if folder_paths is not None:
|
||||
resolved = folder_paths.get_full_path(MODEL_FOLDER, model_name)
|
||||
if resolved:
|
||||
return Path(resolved).resolve()
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
"""Load Image: the size a picture comes out at, as plain numbers.
|
||||
|
||||
``plan_load_size`` turns the node's size choice into what the picture is
|
||||
resized to and what is cut from it. It holds no tensors, so it is tested as
|
||||
numbers, and ``js/shared/load_size.mjs`` repeats it for the size the node
|
||||
shows before a run (``tests/fixtures/load_size_cases.json`` holds both to the
|
||||
same answers). ``apply_load_size`` runs a plan on a picture and its mask.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
from ._resize_helpers import plan_resize, resample_batch, resolve_target, snap_to_multiple
|
||||
|
||||
SIZE_MODES = (
|
||||
"off",
|
||||
"megapixels",
|
||||
"longest side",
|
||||
"scale",
|
||||
"fit inside",
|
||||
"crop to fill",
|
||||
"crop",
|
||||
"crop to ratio",
|
||||
)
|
||||
# Which part of the picture a crop keeps.
|
||||
CROP_SIDES = (
|
||||
"center",
|
||||
"top",
|
||||
"bottom",
|
||||
"left",
|
||||
"right",
|
||||
"top left",
|
||||
"top right",
|
||||
"bottom left",
|
||||
"bottom right",
|
||||
)
|
||||
# The last one takes its shape from the width and height boxes.
|
||||
RATIOS = (
|
||||
"1:1",
|
||||
"4:3",
|
||||
"3:4",
|
||||
"3:2",
|
||||
"2:3",
|
||||
"16:9",
|
||||
"9:16",
|
||||
"5:4",
|
||||
"4:5",
|
||||
"21:9",
|
||||
"9:21",
|
||||
"2:1",
|
||||
"1:2",
|
||||
"width : height",
|
||||
)
|
||||
|
||||
|
||||
def _round_half_up(value: float) -> int:
|
||||
return int(math.floor(value + 0.5))
|
||||
|
||||
|
||||
def _multiple_below(value: int, multiple: int) -> int:
|
||||
"""The largest multiple that is not above ``value``, never below one step."""
|
||||
step = max(1, int(multiple))
|
||||
return max(step, (int(value) // step) * step)
|
||||
|
||||
|
||||
def _multiple_inside(value: int, multiple: int) -> int:
|
||||
"""``value`` rounded down to a multiple, or left alone when it is smaller
|
||||
than one step: a cut never asks for more than the picture holds."""
|
||||
step = max(1, int(multiple))
|
||||
return (int(value) // step) * step if int(value) >= step else int(value)
|
||||
|
||||
|
||||
def _crop_start(spare: int, side: str, low: str, high: str) -> int:
|
||||
"""Where a cut starts along one edge with ``spare`` pixels to lose."""
|
||||
if low in side:
|
||||
return 0
|
||||
if high in side:
|
||||
return int(spare)
|
||||
return int(spare) // 2
|
||||
|
||||
|
||||
def _ratio_terms(ratio: str, width: int, height: int) -> tuple[int, int]:
|
||||
if ratio == "width : height":
|
||||
return max(1, int(width)), max(1, int(height))
|
||||
across, _, down = str(ratio).partition(":")
|
||||
return max(1, int(across)), max(1, int(down))
|
||||
|
||||
|
||||
def plan_load_size(
|
||||
source_width: int,
|
||||
source_height: int,
|
||||
size: str = "off",
|
||||
megapixels: float = 1.0,
|
||||
longest_side: int = 1024,
|
||||
scale: float = 1.0,
|
||||
width: int = 1024,
|
||||
height: int = 1024,
|
||||
multiple: int = 1,
|
||||
enlarge: bool = True,
|
||||
crop_from: str = "center",
|
||||
ratio: str = "1:1",
|
||||
) -> dict[str, int]:
|
||||
"""What one picture is resized to (``resize_width``/``resize_height``),
|
||||
where a crop starts in the resized picture (``crop_x``/``crop_y``) and
|
||||
the size that comes out (``width``/``height``).
|
||||
|
||||
``off`` gives the picture back as it is; ``multiple`` rounds only a size
|
||||
that is being changed. With ``enlarge`` off nothing comes out larger than
|
||||
the picture: a target above it leaves the picture at its own size, and
|
||||
``crop to fill`` cuts the box's shape out of the picture without growing
|
||||
it. ``fit inside`` rounds down, so the result never leaves its box.
|
||||
|
||||
``crop`` cuts a width x height piece out of the picture and ``crop to
|
||||
ratio`` cuts the largest piece of a shape; neither resizes. ``crop_from``
|
||||
names the part every cut keeps.
|
||||
"""
|
||||
source_w, source_h = int(source_width), int(source_height)
|
||||
if source_w <= 0 or source_h <= 0:
|
||||
raise ValueError("Load Image needs a picture larger than 0x0.")
|
||||
if size not in SIZE_MODES:
|
||||
raise ValueError(f"size must be one of {SIZE_MODES}, got '{size}'.")
|
||||
if crop_from not in CROP_SIDES:
|
||||
raise ValueError(f"crop_from must be one of {CROP_SIDES}, got '{crop_from}'.")
|
||||
if ratio not in RATIOS:
|
||||
raise ValueError(f"ratio must be one of {RATIOS}, got '{ratio}'.")
|
||||
if size == "off":
|
||||
return {
|
||||
"resize_width": source_w,
|
||||
"resize_height": source_h,
|
||||
"crop_x": 0,
|
||||
"crop_y": 0,
|
||||
"width": source_w,
|
||||
"height": source_h,
|
||||
}
|
||||
step = max(1, int(multiple))
|
||||
|
||||
def cut(resize_w: int, resize_h: int, out_w: int, out_h: int) -> dict[str, int]:
|
||||
return {
|
||||
"resize_width": resize_w,
|
||||
"resize_height": resize_h,
|
||||
"crop_x": _crop_start(resize_w - out_w, crop_from, "left", "right"),
|
||||
"crop_y": _crop_start(resize_h - out_h, crop_from, "top", "bottom"),
|
||||
"width": out_w,
|
||||
"height": out_h,
|
||||
}
|
||||
|
||||
if size == "crop":
|
||||
out_w = _multiple_inside(min(max(1, int(width)), source_w), step)
|
||||
out_h = _multiple_inside(min(max(1, int(height)), source_h), step)
|
||||
return cut(source_w, source_h, out_w, out_h)
|
||||
|
||||
if size == "crop to ratio":
|
||||
across, down = _ratio_terms(ratio, width, height)
|
||||
if source_w * down >= source_h * across:
|
||||
out_h = source_h
|
||||
out_w = min(source_w, max(1, _round_half_up(source_h * across / down)))
|
||||
else:
|
||||
out_w = source_w
|
||||
out_h = min(source_h, max(1, _round_half_up(source_w * down / across)))
|
||||
return cut(source_w, source_h, _multiple_inside(out_w, step), _multiple_inside(out_h, step))
|
||||
|
||||
if size == "crop to fill":
|
||||
box_w, box_h = max(1, int(width)), max(1, int(height))
|
||||
if not enlarge:
|
||||
grow = max(box_w / source_w, box_h / source_h)
|
||||
if grow > 1.0:
|
||||
# The box keeps its shape and shrinks to what the picture holds.
|
||||
box_w = max(1, int(math.floor(box_w / grow + 1e-6)))
|
||||
box_h = max(1, int(math.floor(box_h / grow + 1e-6)))
|
||||
canvas_w = min(_multiple_below(box_w, step), max(step, source_w))
|
||||
canvas_h = min(_multiple_below(box_h, step), max(step, source_h))
|
||||
else:
|
||||
canvas_w = snap_to_multiple(box_w, step)
|
||||
canvas_h = snap_to_multiple(box_h, step)
|
||||
plan = plan_resize(source_w, source_h, canvas_w, canvas_h, "cover_crop", 1)
|
||||
return cut(plan["resize_width"], plan["resize_height"], canvas_w, canvas_h)
|
||||
|
||||
if size == "megapixels":
|
||||
target_w, target_h = resolve_target(source_w, source_h, "megapixels", megapixels=megapixels)
|
||||
elif size == "longest side":
|
||||
target_w, target_h = resolve_target(source_w, source_h, "longest_edge", edge_length=longest_side)
|
||||
elif size == "scale":
|
||||
target_w, target_h = resolve_target(source_w, source_h, "scale_factor", scale_factor=scale)
|
||||
else: # fit inside
|
||||
fit = min(max(1, int(width)) / source_w, max(1, int(height)) / source_h)
|
||||
target_w = max(1, _round_half_up(source_w * fit))
|
||||
target_h = max(1, _round_half_up(source_h * fit))
|
||||
if not enlarge and (target_w > source_w or target_h > source_h):
|
||||
target_w, target_h = source_w, source_h
|
||||
|
||||
def rounded(target: int, source: int, box: int) -> int:
|
||||
value = snap_to_multiple(target, step)
|
||||
if size == "fit inside" and value > box:
|
||||
value = _multiple_below(box, step)
|
||||
if not enlarge and value > source:
|
||||
value = _multiple_below(source, step)
|
||||
return value
|
||||
|
||||
out_w = rounded(target_w, source_w, max(1, int(width)))
|
||||
out_h = rounded(target_h, source_h, max(1, int(height)))
|
||||
return {
|
||||
"resize_width": out_w,
|
||||
"resize_height": out_h,
|
||||
"crop_x": 0,
|
||||
"crop_y": 0,
|
||||
"width": out_w,
|
||||
"height": out_h,
|
||||
}
|
||||
|
||||
|
||||
def frames_to_image_and_mask(frames) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
"""RGBA PIL frames to a BHWC RGB batch and a BHW mask.
|
||||
|
||||
The mask is what ComfyUI's own Load Image gives: white where the picture
|
||||
is see-through, black where it is solid, and all black for a picture
|
||||
with no transparency (here at the picture's own size).
|
||||
"""
|
||||
images, masks = [], []
|
||||
for frame in frames:
|
||||
array = np.asarray(frame.convert("RGBA"), dtype=np.float32) / 255.0
|
||||
images.append(torch.from_numpy(array[..., :3].copy()))
|
||||
masks.append(torch.from_numpy(1.0 - array[..., 3]))
|
||||
return torch.stack(images, dim=0), torch.stack(masks, dim=0)
|
||||
|
||||
|
||||
def apply_load_size(
|
||||
image: torch.Tensor, mask: torch.Tensor, plan: dict[str, int], method: str
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
"""Run a plan on a BHWC picture and its BHW mask. A plan that changes
|
||||
nothing hands both back untouched."""
|
||||
resize_w, resize_h = int(plan["resize_width"]), int(plan["resize_height"])
|
||||
out_w, out_h = int(plan["width"]), int(plan["height"])
|
||||
if (int(image.shape[2]), int(image.shape[1])) != (resize_w, resize_h):
|
||||
image = resample_batch(image, resize_w, resize_h, method)
|
||||
mask = resample_batch(mask.unsqueeze(-1), resize_w, resize_h, method).squeeze(-1).clamp(0.0, 1.0)
|
||||
if (resize_w, resize_h) != (out_w, out_h):
|
||||
x0, y0 = int(plan["crop_x"]), int(plan["crop_y"])
|
||||
image = image[:, y0 : y0 + out_h, x0 : x0 + out_w, :].contiguous()
|
||||
mask = mask[:, y0 : y0 + out_h, x0 : x0 + out_w].contiguous()
|
||||
return image, mask
|
||||
|
||||
|
||||
__all__ = ["CROP_SIDES", "RATIOS", "SIZE_MODES", "apply_load_size", "frames_to_image_and_mask", "plan_load_size"]
|
||||
+19
-11
@@ -480,17 +480,25 @@ def transform_tensor_batch_chunked(
|
||||
return output, mask, geometry
|
||||
|
||||
|
||||
def stable_file_fingerprint(path: str | os.PathLike[str], inputs: dict[str, object]) -> str:
|
||||
normalized_path = str(Path(path).resolve()).casefold()
|
||||
try:
|
||||
stat = os.stat(path)
|
||||
file_state: dict[str, object] = {
|
||||
"path": normalized_path,
|
||||
"mtime_ns": stat.st_mtime_ns,
|
||||
"size": stat.st_size,
|
||||
}
|
||||
except OSError:
|
||||
file_state = {"path": normalized_path, "missing": True}
|
||||
def stable_file_fingerprint(path: Path | None, inputs: dict[str, object]) -> str:
|
||||
"""A key that changes when the inputs or the file do.
|
||||
|
||||
`path` is what resolve_input_path or resolve_video_path returned, or
|
||||
None when they refused the value. Only such a path is ever looked at on
|
||||
disk: a refused value is a string, and a string is only hashed, so a
|
||||
whole path or a network share typed into a widget is never opened."""
|
||||
if isinstance(path, Path):
|
||||
try:
|
||||
stat = os.stat(path)
|
||||
file_state: dict[str, object] = {
|
||||
"path": str(path).casefold(),
|
||||
"mtime_ns": stat.st_mtime_ns,
|
||||
"size": stat.st_size,
|
||||
}
|
||||
except OSError:
|
||||
file_state = {"path": str(path).casefold(), "missing": True}
|
||||
else:
|
||||
file_state = {"unresolved": True}
|
||||
payload = {"file": file_state, "inputs": inputs}
|
||||
encoded = json.dumps(payload, sort_keys=True, separators=(",", ":"), ensure_ascii=True)
|
||||
return hashlib.sha256(encoded.encode("utf-8")).hexdigest()
|
||||
|
||||
+34
-5
@@ -19,6 +19,7 @@ from ._edit_lock_helpers import (
|
||||
describe,
|
||||
restore_pixels,
|
||||
)
|
||||
from ._edit_tint_helpers import take_out_tint
|
||||
|
||||
|
||||
class AusBossEditLock:
|
||||
@@ -141,8 +142,10 @@ class AusBossEditLockRestore:
|
||||
"Puts your picture's own pixels back in every part the edit did not "
|
||||
"change. Use it right after the VAE decode, with the edit_lock "
|
||||
"output of Edit Lock 🆎. The untouched parts then match your "
|
||||
"original pixel for pixel; only the edit is new. When the lock "
|
||||
"stepped aside the picture passes through unchanged."
|
||||
"original pixel for pixel; only the edit is new. It also takes out "
|
||||
"the faint pink tint some edit models add to the whole picture, "
|
||||
"which matters most when the lock stepped aside (a new hair color, "
|
||||
"background or weather)."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"edit lock restore",
|
||||
@@ -178,6 +181,19 @@ class AusBossEditLockRestore:
|
||||
},
|
||||
),
|
||||
},
|
||||
"optional": {
|
||||
"remove_tint": (
|
||||
"BOOLEAN",
|
||||
{
|
||||
"default": True,
|
||||
"tooltip": (
|
||||
"Takes out the faint pink tint the edit model adds "
|
||||
"to the whole picture. Edits meant to recolor "
|
||||
"everything, like golden hour, are left alone."
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "MASK", "STRING")
|
||||
@@ -189,17 +205,30 @@ class AusBossEditLockRestore:
|
||||
)
|
||||
FUNCTION = "restore"
|
||||
|
||||
def restore(self, image, edit_lock, feather):
|
||||
def restore(self, image, edit_lock, feather, remove_tint=True):
|
||||
if image.ndim != 4:
|
||||
raise ValueError("Edit Lock Restore: image must be an IMAGE batch.")
|
||||
if not isinstance(edit_lock, EditLock):
|
||||
raise ValueError("Edit Lock Restore: edit_lock needs the output of Edit Lock.")
|
||||
height, width = int(image.shape[1]), int(image.shape[2])
|
||||
report = describe(edit_lock)
|
||||
if remove_tint and edit_lock.source is not None:
|
||||
# before the paste, so the edit itself loses the tint too and meets the original evenly
|
||||
image, taken = take_out_tint(image, edit_lock.source)
|
||||
if taken is not None:
|
||||
report += " " + tint_report(taken)
|
||||
mask = edit_lock.pixel_mask(height, width)
|
||||
if mask is None or edit_lock.source is None:
|
||||
return (image, torch.ones((int(image.shape[0]), height, width)), describe(edit_lock))
|
||||
return (image, torch.ones((int(image.shape[0]), height, width)), report)
|
||||
result, edit_mask = restore_pixels(image, edit_lock.source, mask, int(feather))
|
||||
return (result, edit_mask, describe(edit_lock))
|
||||
return (result, edit_mask, report)
|
||||
|
||||
|
||||
def tint_report(shift):
|
||||
"""One plain sentence; the numbers are Lab units, for anyone who wants them."""
|
||||
light, a, b = shift
|
||||
return (f"It also took out the faint pink tint the model added to the whole picture "
|
||||
f"(L {light:+.1f}, a {a:+.1f}, b {b:+.1f}).")
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
|
||||
@@ -168,7 +168,7 @@ class AusBossImageCropRotatePad:
|
||||
try:
|
||||
path = resolve_input_path(image)
|
||||
except Exception:
|
||||
path = image or ""
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
spec = spec_from_values(**values)
|
||||
# Every widget value is already part of ComfyUI's cache key, so a
|
||||
# changed transform or budget re-runs the node without this; the
|
||||
|
||||
@@ -15,9 +15,8 @@ class AusBossLoadAudio:
|
||||
"Loads a sound file and hands on only the part you pick. The node shows the "
|
||||
"sound as a wave, so you can see where the loud parts are. Drag the two "
|
||||
"handles to set where it starts and stops, and press play to hear just that "
|
||||
"part. Set Max length to the longest sound the next step takes: anything "
|
||||
"longer shows in red as cut off, so you see exactly what comes out before "
|
||||
"you run anything."
|
||||
"part. Type a Duration to get a sound of an exact length, such as the "
|
||||
"length of the video you are making."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"load audio",
|
||||
@@ -49,7 +48,7 @@ class AusBossLoadAudio:
|
||||
"min": 0.0,
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": "Where the sound starts. Drag the wave's IN handle or type a time.",
|
||||
"tooltip": "Where the sound starts. Drag the wave's left handle or type a Start.",
|
||||
},
|
||||
),
|
||||
"end_seconds": (
|
||||
@@ -59,7 +58,7 @@ class AusBossLoadAudio:
|
||||
"min": 0.0,
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": "Where the sound stops. 0 plays to the end. Drag the OUT handle or type a time.",
|
||||
"tooltip": "Where the sound stops. 0 plays to the end. The face sets a Duration instead.",
|
||||
},
|
||||
),
|
||||
},
|
||||
@@ -72,8 +71,7 @@ class AusBossLoadAudio:
|
||||
"max": 86400.0,
|
||||
"step": 0.1,
|
||||
"tooltip": (
|
||||
"The longest the sound may be. Anything past it is cut off and shows "
|
||||
"in red. 0 means no limit."
|
||||
"How long the sound is: the Duration box. 0 runs to the end of the file."
|
||||
),
|
||||
},
|
||||
),
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
"""Load Image 🆎."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from ._execution_helpers import ignore_extra_inputs
|
||||
from ._load_image_helpers import (
|
||||
CROP_SIDES,
|
||||
RATIOS,
|
||||
SIZE_MODES,
|
||||
apply_load_size,
|
||||
frames_to_image_and_mask,
|
||||
plan_load_size,
|
||||
)
|
||||
from ._media_helpers import list_input_images, load_image_frames, resolve_input_path
|
||||
from ._resize_helpers import INTERPOLATION_MODES
|
||||
from ._transform_engine import stable_file_fingerprint
|
||||
|
||||
|
||||
class AusBossLoadImage:
|
||||
CATEGORY = "🆎 AusBoss/Image"
|
||||
DESCRIPTION = (
|
||||
"Loads a picture and sets its size in the same node. Pick a file, "
|
||||
"upload one, or step through the input folder with the arrows. "
|
||||
"Size can stay off, or bring the picture to a megapixel count, a "
|
||||
"longest side, a scale, a box it must fit inside, or a box it fills "
|
||||
"by cropping. It can also cut a piece or a shape out of the picture "
|
||||
"without resizing, keeping the side you choose. The node shows the "
|
||||
"picture going in and coming out, with both sizes, before you run."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"load image",
|
||||
"load picture",
|
||||
"image loader",
|
||||
"resize on load",
|
||||
"megapixels",
|
||||
"longest side",
|
||||
"crop",
|
||||
"aspect ratio",
|
||||
"ausboss",
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"image": (
|
||||
list_input_images(),
|
||||
{
|
||||
"image_upload": True,
|
||||
"tooltip": "The picture to load. Pick one from ComfyUI's input folder or upload a new one.",
|
||||
},
|
||||
),
|
||||
"size": (
|
||||
list(SIZE_MODES),
|
||||
{
|
||||
"default": "off",
|
||||
"tooltip": (
|
||||
"How the picture is resized. off keeps it as it "
|
||||
"is. megapixels, longest side and scale keep its "
|
||||
"shape. fit inside shrinks or grows it to sit in "
|
||||
"a box. crop to fill covers the box and cuts off "
|
||||
"what sticks out. crop cuts a piece out without "
|
||||
"resizing. crop to ratio cuts the largest piece "
|
||||
"of a shape."
|
||||
),
|
||||
},
|
||||
),
|
||||
"megapixels": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": 1.0,
|
||||
"min": 0.01,
|
||||
"max": 64.0,
|
||||
"step": 0.01,
|
||||
"tooltip": "For megapixels: the picture's total size. 1.0 is about 1024 x 1024.",
|
||||
},
|
||||
),
|
||||
"longest_side": (
|
||||
"INT",
|
||||
{
|
||||
"default": 1024,
|
||||
"min": 16,
|
||||
"max": 16384,
|
||||
"step": 1,
|
||||
"tooltip": "For longest side: the length of the longer edge, in pixels. The other edge follows.",
|
||||
},
|
||||
),
|
||||
"scale": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": 1.0,
|
||||
"min": 0.05,
|
||||
"max": 8.0,
|
||||
"step": 0.01,
|
||||
"tooltip": "For scale: 0.5 is half the size, 2 is double.",
|
||||
},
|
||||
),
|
||||
"width": (
|
||||
"INT",
|
||||
{
|
||||
"default": 1024,
|
||||
"min": 16,
|
||||
"max": 16384,
|
||||
"step": 1,
|
||||
"tooltip": "For fit inside, crop to fill and crop: the box's width in pixels.",
|
||||
},
|
||||
),
|
||||
"height": (
|
||||
"INT",
|
||||
{
|
||||
"default": 1024,
|
||||
"min": 16,
|
||||
"max": 16384,
|
||||
"step": 1,
|
||||
"tooltip": "For fit inside, crop to fill and crop: the box's height in pixels.",
|
||||
},
|
||||
),
|
||||
"multiple": (
|
||||
"INT",
|
||||
{
|
||||
"default": 8,
|
||||
"min": 1,
|
||||
"max": 256,
|
||||
"step": 1,
|
||||
"tooltip": (
|
||||
"Rounds the new width and height to a multiple of "
|
||||
"this. Most models want 8 or 16. 1 leaves the "
|
||||
"numbers as they are. Not used while size is off."
|
||||
),
|
||||
},
|
||||
),
|
||||
"method": (
|
||||
list(INTERPOLATION_MODES),
|
||||
{
|
||||
"default": "lanczos",
|
||||
"tooltip": "How pixels are resampled. lanczos is the sharpest for photos; nearest keeps pixel art crisp.",
|
||||
},
|
||||
),
|
||||
"enlarge": (
|
||||
"BOOLEAN",
|
||||
{
|
||||
"default": True,
|
||||
"tooltip": (
|
||||
"On: a small picture is made bigger to reach the "
|
||||
"size you asked for. Off: a picture is only ever "
|
||||
"made smaller, and a small one comes out at its "
|
||||
"own size."
|
||||
),
|
||||
},
|
||||
),
|
||||
"crop_from": (
|
||||
list(CROP_SIDES),
|
||||
{
|
||||
"default": "center",
|
||||
"tooltip": (
|
||||
"For the three crop choices: the part of the "
|
||||
"picture that is kept. top keeps the top and cuts "
|
||||
"from the bottom."
|
||||
),
|
||||
},
|
||||
),
|
||||
"ratio": (
|
||||
list(RATIOS),
|
||||
{
|
||||
"default": "1:1",
|
||||
"tooltip": (
|
||||
"For crop to ratio: the shape to cut, width to "
|
||||
"height. width : height uses the numbers in the "
|
||||
"width and height boxes."
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE", "MASK", "INT", "INT", "STRING", "INT", "INT")
|
||||
RETURN_NAMES = (
|
||||
"image",
|
||||
"mask",
|
||||
"width",
|
||||
"height",
|
||||
"filename",
|
||||
"original_width",
|
||||
"original_height",
|
||||
)
|
||||
OUTPUT_TOOLTIPS = (
|
||||
"The picture, at its new size.",
|
||||
"White where the picture is see-through, black where it is solid. "
|
||||
"All black for a picture with no transparency. Same size as the picture.",
|
||||
"Width of the picture that comes out, in pixels.",
|
||||
"Height of the picture that comes out, in pixels.",
|
||||
"The file's name without its folder or its ending, ready for a save "
|
||||
"node's prefix.",
|
||||
"Width of the file before any resize.",
|
||||
"Height of the file before any resize.",
|
||||
)
|
||||
FUNCTION = "load"
|
||||
|
||||
def load(
|
||||
self,
|
||||
image,
|
||||
size="off",
|
||||
megapixels=1.0,
|
||||
longest_side=1024,
|
||||
scale=1.0,
|
||||
width=1024,
|
||||
height=1024,
|
||||
multiple=8,
|
||||
method="lanczos",
|
||||
enlarge=True,
|
||||
crop_from="center",
|
||||
ratio="1:1",
|
||||
):
|
||||
path = resolve_input_path(image)
|
||||
picture, mask = frames_to_image_and_mask(load_image_frames(path))
|
||||
source_w, source_h = int(picture.shape[2]), int(picture.shape[1])
|
||||
plan = plan_load_size(
|
||||
source_w,
|
||||
source_h,
|
||||
str(size),
|
||||
float(megapixels),
|
||||
int(longest_side),
|
||||
float(scale),
|
||||
int(width),
|
||||
int(height),
|
||||
int(multiple),
|
||||
bool(enlarge),
|
||||
str(crop_from),
|
||||
str(ratio),
|
||||
)
|
||||
picture, mask = apply_load_size(picture, mask, plan, str(method))
|
||||
return (
|
||||
picture,
|
||||
mask,
|
||||
int(plan["width"]),
|
||||
int(plan["height"]),
|
||||
path.stem,
|
||||
source_w,
|
||||
source_h,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@ignore_extra_inputs
|
||||
def VALIDATE_INPUTS(cls, image):
|
||||
try:
|
||||
resolve_input_path(image)
|
||||
except Exception as exc:
|
||||
return f"Load Image: {exc}"
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, image, **values):
|
||||
try:
|
||||
path = resolve_input_path(image)
|
||||
except Exception:
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
return stable_file_fingerprint(path, {"image": image, **values})
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {"AUSBOSS_NODES_LoadImage": AusBossLoadImage}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {"AUSBOSS_NODES_LoadImage": "Load Image 🆎"}
|
||||
|
||||
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
|
||||
@@ -403,7 +403,7 @@ class AusBossLoadImagePad:
|
||||
try:
|
||||
path = resolve_input_path(image)
|
||||
except Exception:
|
||||
path = image or ""
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
return stable_file_fingerprint(path, {"image": image, **values})
|
||||
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ class AusBossLoadVideo:
|
||||
CATEGORY = "🆎 AusBoss/Video"
|
||||
DESCRIPTION = (
|
||||
"Loads a video as a BHWC frame batch plus its audio, trimmed to an "
|
||||
"optional start/end window selected on the preview timeline, with frame count, "
|
||||
"optional window set with Start, Duration and Ends at under the player, with frame count, "
|
||||
"fps, size, and duration outputs ready for downstream wiring, plus a lazy "
|
||||
"core VIDEO output for nodes that consume whole videos. every_nth thins "
|
||||
"the batch and max_frames caps it, so long clips load without filling "
|
||||
"memory. single_frame flips the loader into a frame picker that "
|
||||
"returns just the frame at the IN time as a one-image batch."
|
||||
"returns just the frame at the start time as a one-image batch."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"load video",
|
||||
@@ -53,8 +53,7 @@ class AusBossLoadVideo:
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": (
|
||||
"Skip everything before this time. Drag the preview's IN "
|
||||
"handle or type an exact value below the player."
|
||||
"Skip everything before this time. It is the Start box under the player."
|
||||
),
|
||||
},
|
||||
),
|
||||
@@ -66,8 +65,7 @@ class AusBossLoadVideo:
|
||||
"max": 86400.0,
|
||||
"step": 0.01,
|
||||
"tooltip": (
|
||||
"Stop at this time; 0 plays to the end. Drag the preview's "
|
||||
"OUT handle or type an exact value below the player."
|
||||
"Stop at this time; 0 plays to the end. The face sets a Duration instead."
|
||||
),
|
||||
},
|
||||
),
|
||||
@@ -115,8 +113,8 @@ class AusBossLoadVideo:
|
||||
"max": 100000,
|
||||
"step": 1,
|
||||
"tooltip": (
|
||||
"Stop after this many kept frames; 0 loads the "
|
||||
"whole trim window. Caps memory on long clips — "
|
||||
"Stop after this many kept frames: the Duration box. 0 loads the "
|
||||
"whole window. Caps memory on long clips — "
|
||||
"the decode ends early instead of loading and "
|
||||
"discarding."
|
||||
),
|
||||
@@ -127,8 +125,8 @@ class AusBossLoadVideo:
|
||||
{
|
||||
"default": False,
|
||||
"tooltip": (
|
||||
"Load only the frame at the IN time as a "
|
||||
"one-image batch. The preview's trim strip "
|
||||
"Load only the frame at the start time as a "
|
||||
"one-image batch. The timing card "
|
||||
"becomes a frame picker (the FRAME button "
|
||||
"toggles this), and end_seconds, every_nth, "
|
||||
"and max_frames are ignored."
|
||||
|
||||
@@ -18,6 +18,7 @@ from ._image_save_helpers import (
|
||||
resolve_output_root,
|
||||
sanitize_exact_name,
|
||||
sidecar_path,
|
||||
write_light_previews,
|
||||
)
|
||||
from ._route_errors import safe_route_error
|
||||
from ._step_preview_helpers import STEP_PREVIEW_DEFAULT, register_step_preview_handler
|
||||
@@ -406,7 +407,10 @@ class AusBossSaveImage:
|
||||
lambda path, frame: encode_image(path, frame, format, metadata),
|
||||
)
|
||||
return {
|
||||
"ui": {"images": previews, "ausboss_saved_path": [], "ausboss_held": [token]},
|
||||
"ui": {
|
||||
"images": previews, "ausboss_saved_path": [], "ausboss_held": [token],
|
||||
"ausboss_preview": self._light_previews(images, preview),
|
||||
},
|
||||
"result": ("", images),
|
||||
}
|
||||
|
||||
@@ -418,6 +422,7 @@ class AusBossSaveImage:
|
||||
actions = settle_destinations(planned, has_caption, output_root)
|
||||
|
||||
saved: list[Path] = []
|
||||
saved_frames = []
|
||||
for (path, _policy), action, frame in zip(planned, actions, images):
|
||||
if action == "skip":
|
||||
continue
|
||||
@@ -426,11 +431,13 @@ class AusBossSaveImage:
|
||||
if has_caption:
|
||||
sidecar_path(path).write_text(caption_value, encoding="utf-8")
|
||||
saved.append(path)
|
||||
saved_frames.append(frame)
|
||||
|
||||
# Every destination was confined to the output folder above, so each
|
||||
# saved file previews from there and is shown relative to it. The
|
||||
# preview switch is display only: these entries are also how the
|
||||
# queue lists the save, and there is no temp file to skip.
|
||||
# saved file previews from there and is shown relative to it. These
|
||||
# entries are also how the queue lists the save, so the preview
|
||||
# switch leaves them alone; it only skips the small copies the node
|
||||
# shows on its face (ausboss_preview).
|
||||
previews: list[dict] = []
|
||||
resolved_root = output_root.resolve()
|
||||
shown_paths: list[str] = []
|
||||
@@ -444,10 +451,24 @@ class AusBossSaveImage:
|
||||
})
|
||||
shown_paths.append(resolved.relative_to(resolved_root).as_posix())
|
||||
return {
|
||||
"ui": {"images": previews, "ausboss_saved_path": shown_paths[:1]},
|
||||
"ui": {
|
||||
"images": previews, "ausboss_saved_path": shown_paths[:1],
|
||||
"ausboss_preview": self._light_previews(saved_frames, preview),
|
||||
},
|
||||
"result": (str(saved[0]) if saved else "", images),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def _light_previews(frames, preview) -> list[str]:
|
||||
# The node's face shows these instead of the full files. Preview
|
||||
# off: nothing is shown, so nothing is written.
|
||||
if not preview:
|
||||
return []
|
||||
try:
|
||||
return write_light_previews(folder_paths.get_temp_directory(), frames)
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, **_values):
|
||||
# A saver's job is the side effect: deleting the file and queueing
|
||||
|
||||
@@ -43,7 +43,7 @@ class AusBossVideoCropRotatePad:
|
||||
required = {
|
||||
"video": (
|
||||
list_input_videos(),
|
||||
{"tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
{"video_upload": True, "tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
),
|
||||
"source_mode": (
|
||||
["input folder", "local path"],
|
||||
@@ -152,7 +152,7 @@ class AusBossVideoCropRotatePad:
|
||||
try:
|
||||
path = resolve_video_path(source_mode, video, local_path)
|
||||
except Exception:
|
||||
path = local_path if source_mode == "local path" else video
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
spec = spec_from_values(**values)
|
||||
resize = {name: values.get(name) for name in resize_inputs()}
|
||||
return stable_file_fingerprint(
|
||||
@@ -160,6 +160,7 @@ class AusBossVideoCropRotatePad:
|
||||
{
|
||||
"video": video,
|
||||
"source_mode": source_mode,
|
||||
"local_path": local_path,
|
||||
"seek_mode": seek_mode,
|
||||
"frame_index": int(frame_index),
|
||||
"frame_time": round(float(frame_time), 6),
|
||||
|
||||
@@ -49,8 +49,8 @@ class AusBossVideoCropRotatePadClip:
|
||||
"mask of the generated area (rotation corners and padding), the audio "
|
||||
"for the same window, the frame count, fps, size, and duration, and a "
|
||||
"stitcher so Stitch Inpaint can paste the source frames back over the "
|
||||
"generated clip. Drag IN and OUT to trim, or turn Length on to set "
|
||||
"the clip by a number of output frames from IN."
|
||||
"generated clip. Set the clip with Start, Duration and Ends at, or drag "
|
||||
"its two handles on the timeline."
|
||||
)
|
||||
SEARCH_ALIASES = [
|
||||
"video crop",
|
||||
@@ -68,7 +68,7 @@ class AusBossVideoCropRotatePadClip:
|
||||
required = {
|
||||
"video": (
|
||||
list_input_videos(),
|
||||
{"tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
{"video_upload": True, "tooltip": "Choose a video in ComfyUI's input folder or use the upload button."},
|
||||
),
|
||||
"source_mode": (
|
||||
["input folder", "local path"],
|
||||
@@ -218,25 +218,25 @@ class AusBossVideoCropRotatePadClip:
|
||||
}),
|
||||
"start_frame": ("INT", {
|
||||
"forceInput": True, "min": 0,
|
||||
"tooltip": "Zero-based source start frame; overrides and locks timeline IN. "
|
||||
"tooltip": "Zero-based source start frame; overrides and locks Start. "
|
||||
"Uses the source frame-rate grid.",
|
||||
}),
|
||||
"end_frame": ("INT", {
|
||||
"forceInput": True, "min": 0,
|
||||
"tooltip": "Exclusive source end frame; 0 means source end. Overrides and "
|
||||
"locks timeline OUT. Uses the source frame-rate grid.",
|
||||
"locks Ends at. Uses the source frame-rate grid.",
|
||||
}),
|
||||
"frame_load_cap": ("INT", {
|
||||
"forceInput": True, "min": 0,
|
||||
"tooltip": "Maximum returned frames after rate conversion and Every nth, "
|
||||
"before Frames for. Overrides and locks Length; 0 means unlimited.",
|
||||
"before Frames for. Overrides and locks Duration; 0 means unlimited.",
|
||||
}),
|
||||
"fixed_frames": ("INT", {
|
||||
"default": 0, "min": 0, "max": 100000,
|
||||
"tooltip": "Exact output frames after rate conversion and Every nth; 0 = off. "
|
||||
"Connected, it sets the length from IN. Overrides OUT/end_frame, Length, "
|
||||
"Connected, it sets the length from Start. Overrides Ends at/end_frame, Duration, "
|
||||
"frame_load_cap and Frames for. Duration = frames / output fps; 120 frames at 24 fps = 5 seconds. "
|
||||
"The source must be long enough. A linked IN anchors the window.",
|
||||
"The source must be long enough. A linked Start anchors the window.",
|
||||
}),
|
||||
"last_seconds": ("FLOAT", {
|
||||
"forceInput": True, "min": 0,
|
||||
@@ -395,7 +395,7 @@ class AusBossVideoCropRotatePadClip:
|
||||
try:
|
||||
path = resolve_video_path(source_mode, video, local_path)
|
||||
except Exception:
|
||||
path = local_path if source_mode == "local path" else video
|
||||
path = None # refused: hashed by its text only, never opened
|
||||
spec = spec_from_values(**values)
|
||||
resize = {name: values.get(name) for name in resize_inputs()}
|
||||
return stable_file_fingerprint(
|
||||
@@ -403,6 +403,7 @@ class AusBossVideoCropRotatePadClip:
|
||||
{
|
||||
"video": video,
|
||||
"source_mode": source_mode,
|
||||
"local_path": local_path,
|
||||
"start_seconds": round(float(start_seconds), 6),
|
||||
"end_seconds": round(float(end_seconds), 6),
|
||||
"every_nth": max(1, int(every_nth)),
|
||||
|
||||
+3
-3
@@ -2,8 +2,8 @@
|
||||
name = "ausboss-nodes"
|
||||
# Manager/registry search matches against this text, so it names the actual
|
||||
# nodes instead of describing the collection abstractly.
|
||||
description = "ComfyUI-AusBoss (AusBoss nodes): image and video nodes with compact controls: Image and Video Crop + Rotate + Pad (frame or clip), Load Image + Pad, Image Folder, Image Resize, Align Image, Image Size, Color Match, Image Compare A/B, Realign to Source (experimental), Save Image (PNG, WebP/JXL, captions), Load Video, Load Audio, Save Video, Select Frame, Frame Interpolate, Mask Refine, Mask by Name and Mask by Touch (by name or click), LaMa Inpaint, Crop For Inpaint, Stitch Inpaint, Tiled Upscale and Tiled Upscale Stitch, FlashVSR Upscale, Edit Lock and Edit Lock Restore, LoRA Loader, Krea 2 Encode and Outpaint Model Patch, Latent Size, Layout Boxes, Seed, Select Every Nth, Split Batch, Merge Batches, Text, Text Lines, Prompt Variations, H3 Prompt Writer, Integer, Float, Math Expression, Show Text, Free Memory, Workflow Note, Workflow Note Tile, Callout, Callout Tile, Workflow Switches, Run Timer, and Step Preview. Example workflows for Qwen Image 2.1, Krea 2, Klein 9B and LTX 2.3."
|
||||
version = "2.24.0"
|
||||
description = "ComfyUI-AusBoss (AusBoss nodes): image and video nodes with compact controls: Image and Video Crop + Rotate + Pad (frame or clip), Load Image, Load Image + Pad, Image Folder, Image Resize, Align Image, Image Size, Color Match, Image Compare A/B, Realign to Source (experimental), Save Image (PNG, WebP/JXL, captions), Load Video, Load Audio, Save Video, Select Frame, Frame Interpolate, Mask Refine, Mask by Name and Mask by Touch, LaMa Inpaint, Crop For Inpaint, Stitch Inpaint, Tiled Upscale and Tiled Upscale Stitch, FlashVSR Upscale, Edit Lock and Edit Lock Restore, LoRA Loader, Krea 2 Encode and Outpaint Model Patch, Latent Size, Layout Boxes, Seed, Select Every Nth, Split Batch, Merge Batches, Text, Text Lines, Prompt Variations, H3 Prompt Writer, Integer, Float, Math Expression, Show Text, Free Memory, Workflow Note, Workflow Note Tile, Callout, Callout Tile, Workflow Switches, Run Timer, and Step Preview. Example workflows for Qwen Image 2.1, Krea 2, Klein 9B and LTX 2.3."
|
||||
version = "2.26.2"
|
||||
# comfy-cli serializes this to JSON verbatim, so `file` publishes the literal
|
||||
# string {"file": "LICENSE"} to the registry listing. `text` puts a readable
|
||||
# name there instead. Both forms are supported; the LICENSE file is unchanged.
|
||||
@@ -21,7 +21,7 @@ keywords = [
|
||||
"image folder", "batch folder", "callout", "sticky note", "arrows",
|
||||
"tiled upscale", "upscale", "tiles", "restore", "layout boxes", "bounding boxes", "moss image", "replace text", "rotate box",
|
||||
"step preview", "live preview", "stop run",
|
||||
"text lines", "prompt list", "prompt variations", "wildcards", "flashvsr", "video upscale", "edit lock",
|
||||
"text lines", "prompt list", "prompt variations", "wildcards", "flashvsr", "video upscale", "edit lock", "load image",
|
||||
]
|
||||
|
||||
# Read by comfy-cli into the registry's supported_os field. Nothing in the pack
|
||||
|
||||
@@ -73,6 +73,7 @@ PUBLIC_NODE_IDS = {
|
||||
"AUSBOSS_NODES_LaMaInpaint",
|
||||
"AUSBOSS_NODES_LayoutBoxes",
|
||||
"AUSBOSS_NODES_LoadAudio",
|
||||
"AUSBOSS_NODES_LoadImage",
|
||||
"AUSBOSS_NODES_LoadImagePad",
|
||||
"AUSBOSS_NODES_LoadVideo",
|
||||
"AUSBOSS_NODES_LoraLoader",
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { appFields, createAppModeSync, workflowMode } from "../js/shared/app_mode.mjs";
|
||||
import { hideWidget, isWidgetHidden } from "../js/shared/widget_visibility.mjs";
|
||||
|
||||
function graph() {
|
||||
const nodes = new Map();
|
||||
for (const [id, names] of [["256", ["image", "upload"]], ["160", ["script"]]]) {
|
||||
const node = { id, dirty: 0, widgets: names.map((name) => ({ name, value: "" })) };
|
||||
for (const widget of node.widgets) hideWidget(widget);
|
||||
nodes.set(id, node);
|
||||
}
|
||||
const find = (nodeId, name) => {
|
||||
const node = nodes.get(nodeId);
|
||||
const widget = node?.widgets.find((entry) => entry.name === name);
|
||||
return widget ? { node, widget } : null;
|
||||
};
|
||||
return { nodes, find, changed: (node) => { node.dirty += 1; } };
|
||||
}
|
||||
|
||||
const linearData = { inputs: [["256", "image", { description: "One clear photo." }], [160, "script"], ["999", "gone"]], outputs: ["145"] };
|
||||
|
||||
test("fields read both saved shapes and skip broken entries", () => {
|
||||
assert.deepEqual(appFields(linearData), [
|
||||
{ nodeId: "256", widget: "image" }, { nodeId: "160", widget: "script" }, { nodeId: "999", widget: "gone" },
|
||||
]);
|
||||
assert.deepEqual(appFields({ inputs: [null, ["1"], [{}, "x"]] }), []);
|
||||
assert.deepEqual(appFields(undefined), []);
|
||||
});
|
||||
|
||||
test("the mode falls back from the live mode to the saved one", () => {
|
||||
assert.equal(workflowMode({ activeMode: null, initialMode: "app" }), "app");
|
||||
assert.equal(workflowMode({ activeMode: "graph", initialMode: "app" }), "graph");
|
||||
assert.equal(workflowMode(undefined), "graph");
|
||||
});
|
||||
|
||||
test("App mode shows only the listed widgets, the graph hides them again", () => {
|
||||
const g = graph();
|
||||
const sync = createAppModeSync(g);
|
||||
const image = g.find("256", "image").widget;
|
||||
const upload = g.find("256", "upload").widget;
|
||||
assert.equal(sync("app", linearData), 2);
|
||||
assert.equal(isWidgetHidden(image), false);
|
||||
assert.equal(image.options.hidden, false); // written, so the frontend hears it
|
||||
assert.equal(isWidgetHidden(upload), true); // not on the form, left alone
|
||||
assert.equal(g.nodes.get("256").dirty, 1);
|
||||
sync("graph", linearData);
|
||||
assert.equal(isWidgetHidden(image), true);
|
||||
assert.equal(image.options.hidden, true);
|
||||
assert.equal(isWidgetHidden(g.find("160", "script").widget), true);
|
||||
});
|
||||
|
||||
test("a widget a card hides again while in App mode is shown again", () => {
|
||||
const g = graph();
|
||||
const sync = createAppModeSync(g);
|
||||
sync("app", linearData);
|
||||
const image = g.find("256", "image").widget;
|
||||
hideWidget(image); // the card's load-time re-hide
|
||||
sync("app", linearData);
|
||||
assert.equal(isWidgetHidden(image), false);
|
||||
});
|
||||
|
||||
test("builder mode and the graph leave card widgets hidden", () => {
|
||||
const g = graph();
|
||||
const sync = createAppModeSync(g);
|
||||
for (const mode of ["graph", "builder:inputs"]) {
|
||||
assert.equal(sync(mode, linearData), 0);
|
||||
assert.equal(isWidgetHidden(g.find("256", "image").widget), true);
|
||||
}
|
||||
});
|
||||
+89
-1
@@ -5,7 +5,7 @@ import test from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import {
|
||||
ARROW_ANGLE, ARROW_CHOICES, SMALL_MARK, arrowText, fitFontSize, linkTarget, parseBlocks, pastedLink, repointLinks, targetId,
|
||||
ARROW_ANGLE, ARROW_CHOICES, CARD_TEMPLATE, SMALL_MARK, arrowText, cardCells, parseCard, fitFontSize, linkTarget, parseBlocks, pastedLink, repointLinks, targetId,
|
||||
toggleSmall, urlLabel, wrapLink, tileLinkFields, tileLinkText,
|
||||
} from "../js/shared/callout.mjs";
|
||||
|
||||
@@ -322,3 +322,91 @@ test("a note pasted with what its links name follows the copies", () => {
|
||||
assert.equal(repointLinks("[elsewhere](#40) ⬆️ plain", nodes, groups), null);
|
||||
assert.equal(repointLinks(undefined, nodes, groups), null);
|
||||
});
|
||||
|
||||
// Info card. The words of a piece list, so a test reads like the card.
|
||||
const words = (pieces) => pieces.map((piece) => piece.text ?? "").join("");
|
||||
|
||||
test("an Info card reads a title, rows and small print from plain text", () => {
|
||||
const blocks = parseCard([
|
||||
"⏱ Too slow?",
|
||||
"###### Redraw time on an RTX 5090. Smaller cards take longer.",
|
||||
"",
|
||||
"2x, 18 steps | ~4 min",
|
||||
"2x, 10 steps | ~3 min",
|
||||
"1.5x, 18 steps | ~2.5 min",
|
||||
"**1.5x, 10 steps (default) | ~2 min**",
|
||||
"",
|
||||
"###### 1.5x is a 4608-wide sheet, 2x is 6144.",
|
||||
].join("\n"));
|
||||
assert.equal(blocks.length, 3);
|
||||
const [head, rows, foot] = blocks;
|
||||
assert.deepEqual(head.map((line) => line.kind), ["title", "text"]);
|
||||
assert.equal(head[0].icon, "clock");
|
||||
assert.equal(words(head[0].pieces), "Too slow?");
|
||||
assert.equal(head[1].small, true);
|
||||
assert.deepEqual(
|
||||
rows.map((row) => [row.kind, words(row.cells[0]), words(row.cells[1]), row.highlight]),
|
||||
[
|
||||
["row", "2x, 18 steps", "~4 min", false],
|
||||
["row", "2x, 10 steps", "~3 min", false],
|
||||
["row", "1.5x, 18 steps", "~2.5 min", false],
|
||||
["row", "1.5x, 10 steps (default)", "~2 min", true],
|
||||
],
|
||||
);
|
||||
assert.equal(foot[0].kind, "text");
|
||||
assert.equal(foot[0].small, true);
|
||||
});
|
||||
|
||||
test("a row is marked by bold on the whole row, written either way", () => {
|
||||
assert.equal(parseCard("T\n**a | b**")[0][1].highlight, true);
|
||||
assert.equal(parseCard("T\n**a** | **b**")[0][1].highlight, true);
|
||||
// Bold on one word stresses the word; the row is not marked.
|
||||
assert.equal(parseCard("T\n**a** b | c")[0][1].highlight, false);
|
||||
assert.equal(parseCard("T\na | **b**")[0][1].highlight, false);
|
||||
});
|
||||
|
||||
test("a row splits at the first | outside a link", () => {
|
||||
assert.deepEqual(cardCells("Size (1.5x | 2x)"), ["Size (1.5x", "2x)"]);
|
||||
assert.deepEqual(cardCells("[a|b](https://example.com/a|b) | v"), ["[a|b](https://example.com/a|b)", "v"]);
|
||||
assert.deepEqual(cardCells("a | b | c"), ["a", "b | c"]);
|
||||
// A pasted Markdown table row loses its outer pipes; its --- line is dropped.
|
||||
assert.deepEqual(cardCells("| 2x | ~4 min |"), ["2x", "~4 min"]);
|
||||
assert.deepEqual(parseCard("T\n| a | b |\n|---|:--:|\n| c | d |")[0].map((line) => line.kind), ["title", "row", "row"]);
|
||||
// One side empty is not a row.
|
||||
for (const line of ["a |", "| b", "|", "no pipe"]) assert.equal(cardCells(line), null, line);
|
||||
});
|
||||
|
||||
test("only the card's first line is its title, and only a known emoji is an icon", () => {
|
||||
assert.equal(parseCard("a | b\nT")[0][0].kind, "row");
|
||||
assert.equal(parseCard("###### small\nT")[0][0].kind, "text");
|
||||
assert.deepEqual(parseCard("T\nU")[0].map((line) => line.kind), ["title", "text"]);
|
||||
for (const [title, icon] of [["ℹ️ Note", "info"], ["⚠️ Careful", "warning"], ["💡 Tip", "tip"], ["✅ Done", "check"], ["⏱️Fast", "clock"], ["🙂 Hi", null], ["Plain", null]]) {
|
||||
const line = parseCard(title)[0][0];
|
||||
assert.equal(line.icon, icon, title);
|
||||
if (icon) assert.ok(!/^\s/.test(words(line.pieces)), title);
|
||||
}
|
||||
assert.equal(words(parseCard("🙂 Hi")[0][0].pieces), "🙂 Hi");
|
||||
});
|
||||
|
||||
test("the card's starter text shows every part of a card", () => {
|
||||
const [head, rows, foot] = parseCard(CARD_TEMPLATE);
|
||||
assert.equal(head[0].icon, "info");
|
||||
assert.equal(head[1].small, true);
|
||||
assert.deepEqual(rows.map((row) => row.highlight), [false, true]);
|
||||
assert.equal(foot[0].small, true);
|
||||
});
|
||||
|
||||
test("a plain callout reads a | as text, so no note written before changes", () => {
|
||||
const [[line]] = parseBlocks("2x, 18 steps | ~4 min");
|
||||
assert.deepEqual(line, [{ text: "2x, 18 steps | ~4 min", bold: false }]);
|
||||
});
|
||||
|
||||
test("an Info card saves as a plain Callout, so an older pack shows its text", () => {
|
||||
// Tiles save as Callout Tile and an older pack reports that node missing.
|
||||
// A card is readable as a plain note there, so it keeps the plain type.
|
||||
const source = readFileSync(join(ROOT, "js", "callout", "index.js"), "utf-8");
|
||||
const saved = /serializeNoteIdentity\(saved, (\[[^\]]*\])\.includes/.exec(source);
|
||||
assert.ok(saved, "the tile list in onSerialize moved");
|
||||
assert.ok(!saved[1].includes("card"), "an Info card would save as a Callout Tile");
|
||||
assert.match(source, /\["card","Info card"\]/, "the Info card is gone from the note's menu");
|
||||
});
|
||||
|
||||
@@ -27,12 +27,19 @@ test("the graph gets the wheel unless the panel has a use for it", () => {
|
||||
const list = { tagName: "DIV", parentElement: root, ...box() };
|
||||
const field = { tagName: "INPUT", parentElement: root };
|
||||
const styleOf = (el) => ({ overflowY: el === list ? "auto" : "visible" });
|
||||
const ctx = (extra = {}) => ({ root, styleOf, activeElement: null, ...extra });
|
||||
const ctx = (extra = {}) => ({ root, styleOf, ...extra });
|
||||
assert.equal(panelKeepsWheel(stage, { deltaY: -100 }, ctx()), false, "plain picture stage");
|
||||
assert.equal(panelKeepsWheel(list, { deltaY: 100 }, ctx()), true, "list with room to scroll");
|
||||
assert.equal(panelKeepsWheel(list, { deltaY: -100 }, ctx()), false, "list at its top, wheel up zooms");
|
||||
assert.equal(panelKeepsWheel(field, { deltaY: 100 }, ctx()), false, "idle field");
|
||||
assert.equal(panelKeepsWheel(field, { deltaY: 100 }, ctx({ activeElement: field })), true, "field being typed in");
|
||||
// A text box with the cursor in it and nothing to scroll: the graph zooms
|
||||
// (issue #115, the prompt box in a workflow).
|
||||
assert.equal(panelKeepsWheel(field, { deltaY: 100 }, ctx({ activeElement: field })), false, "field being typed in, nothing to scroll");
|
||||
const prompt = { tagName: "TEXTAREA", parentElement: root, ...box() };
|
||||
const scrolls = (el) => ({ overflowY: el === prompt || el === list ? "auto" : "visible" });
|
||||
assert.equal(panelKeepsWheel(prompt, { deltaY: 100 }, ctx({ styleOf: scrolls })), true, "long text still scrolls");
|
||||
assert.equal(panelKeepsWheel(prompt, { deltaY: -100 }, ctx({ styleOf: scrolls })), false, "long text at its top, wheel up zooms");
|
||||
assert.equal(panelKeepsWheel(list, { deltaY: 100, ctrlKey: true }, ctx()), false, "Ctrl + wheel and pinch always zoom the graph");
|
||||
});
|
||||
|
||||
test("middle button and Ctrl+Shift drag go to the graph; ordinary clicks do not", () => {
|
||||
@@ -131,7 +138,6 @@ test("only the listed parts of the pack listen for the wheel", () => {
|
||||
// face of the node.
|
||||
const js = join(dirname(fileURLToPath(import.meta.url)), "..", "js");
|
||||
const listed = [
|
||||
"callout/index.js wrap", // the text box while a note is being edited
|
||||
"canvas_passthrough/index.js window", // hands the wheel to the graph
|
||||
"image_folder/index.js root", // the copy question, a window over the page
|
||||
"image_folder/index.js root", // the folder list, a window over the page
|
||||
@@ -256,7 +262,8 @@ test("the fields on a node face pass app shortcuts on", () => {
|
||||
// cursor was in a Text node, a number box or the Seed box (reported on the
|
||||
// Text node). A new field on a node face uses keepKeyInField too.
|
||||
const js = join(dirname(fileURLToPath(import.meta.url)), "..", "js");
|
||||
const fields = ["shared/widget_card.mjs", "shared/scrub_input.mjs", "seed/index.js", "save_image/index.js", "load_video/index.js", "lora_loader/index.js"];
|
||||
// Load Video's typed IN/OUT went; its timing boxes are scrub inputs now.
|
||||
const fields = ["shared/widget_card.mjs", "shared/scrub_input.mjs", "seed/index.js", "save_image/index.js", "lora_loader/index.js"];
|
||||
for (const file of fields) {
|
||||
const source = readFileSync(join(js, file), "utf-8");
|
||||
assert.match(source, /keepKeyInField\(event\)/, `${file}: its field stops every key again`);
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { readFileSync } from "node:fs";
|
||||
import vm from "node:vm";
|
||||
|
||||
// Run the real extension entry with a fake page in place of ComfyUI.
|
||||
function page({ settings = {}, answer = { ok: true, status: 200 } } = {}) {
|
||||
const requests = [];
|
||||
const toasts = [];
|
||||
const app = {
|
||||
ui: { settings: { getSettingValue: (id) => settings[id] } },
|
||||
registerExtension(extension) { this.extension = extension; },
|
||||
};
|
||||
const api = {
|
||||
async fetchApi(path, options) {
|
||||
requests.push({ path, ...options });
|
||||
if (answer instanceof Error) throw answer;
|
||||
return answer;
|
||||
},
|
||||
};
|
||||
const context = vm.createContext({ app, api, showToast: (toast) => toasts.push(toast), JSON });
|
||||
const source = readFileSync(new URL("../js/clear_vram/index.js", import.meta.url), "utf8")
|
||||
.replace(/^import[\s\S]*?;\s*/gm, "");
|
||||
vm.runInContext(source, context);
|
||||
return { extension: app.extension, requests, toasts };
|
||||
}
|
||||
|
||||
async function click(p) {
|
||||
const [item] = p.extension.getCanvasMenuItems();
|
||||
await item.callback();
|
||||
}
|
||||
|
||||
test("the setting follows the pack's id and category rule and is on by default", () => {
|
||||
const [setting] = page().extension.settings;
|
||||
assert.equal(setting.id, "AusBoss.Memory.ClearVramMenu");
|
||||
assert.equal(setting.type, "boolean");
|
||||
assert.equal(setting.defaultValue, true);
|
||||
assert.deepEqual([...setting.category], ["🆎 AusBoss", "Memory", "Clear VRAM menu"]);
|
||||
});
|
||||
|
||||
test("the canvas menu shows Clear VRAM unless the setting is off", () => {
|
||||
assert.deepEqual([...page().extension.getCanvasMenuItems().map((item) => item.content)], ["Clear VRAM 🆎"]);
|
||||
const off = page({ settings: { "AusBoss.Memory.ClearVramMenu": false } });
|
||||
assert.equal(off.extension.getCanvasMenuItems().length, 0);
|
||||
});
|
||||
|
||||
test("a ComfyUI that forbids manual unloading gets no entry", () => {
|
||||
const p = page({ settings: { "Comfy.Memory.AllowManualUnload": false } });
|
||||
assert.equal(p.extension.getCanvasMenuItems().length, 0);
|
||||
});
|
||||
|
||||
test("a click sends ComfyUI's own free request and confirms it", async () => {
|
||||
const p = page();
|
||||
await click(p);
|
||||
assert.equal(p.requests.length, 1);
|
||||
assert.equal(p.requests[0].path, "/free");
|
||||
assert.equal(p.requests[0].method, "POST");
|
||||
assert.deepEqual(JSON.parse(p.requests[0].body), { unload_models: true, free_memory: true });
|
||||
assert.equal(p.toasts.length, 1);
|
||||
assert.equal(p.toasts[0].severity, "success");
|
||||
});
|
||||
|
||||
test("a refused or failed request shows the error", async () => {
|
||||
for (const answer of [{ ok: false, status: 500 }, new Error("Failed to fetch")]) {
|
||||
const p = page({ answer });
|
||||
await click(p);
|
||||
assert.equal(p.toasts.length, 1);
|
||||
assert.equal(p.toasts[0].severity, "error");
|
||||
assert.match(p.toasts[0].detail, answer instanceof Error ? /Failed to fetch/ : /500/);
|
||||
}
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { clipOutputRate, inputNumber } from '../js/shared/clip_rate.mjs';
|
||||
import { clipOutputRate, inputNumber, linkOrigin } from '../js/shared/clip_rate.mjs';
|
||||
function linked(type='PrimitiveFloat', value=24) {
|
||||
const source={type,widgets:[{name:'value',value}]};
|
||||
return {inputs:[{name:'force_rate',link:1}],graph:{links:{1:{origin_id:2,origin_slot:0}},getNodeById:()=>source}};
|
||||
@@ -38,3 +38,38 @@ test('reads linked fixed frames from AusBoss numeric cards without evaluating ca
|
||||
node.inputs[0].link=null;
|
||||
assert.equal(inputNumber(node,'fixed_frames',0),0);
|
||||
});
|
||||
|
||||
test('a rate typed inside a subgraph counts as typed (Person Swap: Pick the model files -> video fps 24)', () => {
|
||||
const literal = { id: 222, type: 'AUSBOSS_NODES_Integer', mode: 0, inputs: [{ name: 'value', link: null }], widgets: [{ name: 'value', value: 24 }] };
|
||||
const inner = { links: new Map([[391, { origin_id: 222, origin_slot: 0 }]]), outputs: [{}, {}, { linkIds: [391] }], getNodeById: (id) => (id === 222 ? literal : null) };
|
||||
const box = { id: 146, mode: 0, type: 'subgraph-id', subgraph: inner, isSubgraphNode: () => true };
|
||||
const clip = { inputs: [{ name: 'force_rate', link: 7 }], graph: { links: { 7: { origin_id: 146, origin_slot: 2 } }, getNodeById: (id) => (id === 146 ? box : null) } };
|
||||
assert.equal(inputNumber(clip, 'force_rate', 0), 24);
|
||||
assert.equal(clipOutputRate(clip, 60, 1), 24);
|
||||
// A calculation inside the subgraph stays unknown.
|
||||
literal.type = 'AUSBOSS_NODES_MathExpression';
|
||||
assert.equal(inputNumber(clip, 'force_rate', 0), null);
|
||||
});
|
||||
|
||||
test('an older Primitive node and a Reroute both carry a typed number', () => {
|
||||
const primitive = { id: 5, type: 'PrimitiveNode', mode: 0, widgets: [{ name: 'max_seconds', value: 7.5 }] };
|
||||
const reroute = { id: 6, type: 'Reroute', mode: 0, inputs: [{ link: 2 }] };
|
||||
const graph = { links: { 1: { origin_id: 6, origin_slot: 0 }, 2: { origin_id: 5, origin_slot: 0 } }, getNodeById: (id) => ({ 5: primitive, 6: reroute })[id] ?? null };
|
||||
const audio = { inputs: [{ name: 'max_seconds', widget: { name: 'max_seconds' }, link: 1 }], graph };
|
||||
assert.equal(inputNumber(audio, 'max_seconds', 0), 7.5);
|
||||
assert.deepEqual(linkOrigin(audio, 'max_seconds'), { node: primitive, slot: 0 });
|
||||
// Not linked: the caller's own value. Bypassed: unknown.
|
||||
assert.equal(linkOrigin({ inputs: [{ name: 'max_seconds', link: null }] }, 'max_seconds'), undefined);
|
||||
primitive.mode = 4;
|
||||
assert.equal(inputNumber(audio, 'max_seconds', 0), null);
|
||||
});
|
||||
|
||||
test('Layout Boxes reads a size from inside a subgraph', async () => {
|
||||
const { wiredNumber } = await import('../js/shared/layout_boxes.mjs');
|
||||
const latent = { id: 9, type: 'EmptyLatentImage', mode: 0, outputs: [{ name: 'LATENT' }], widgets: [{ name: 'width', value: 1024 }] };
|
||||
const sizes = { id: 8, type: 'AUSBOSS_NODES_Integer', mode: 0, outputs: [{ name: 'int' }], inputs: [{ name: 'value', link: null }], widgets: [{ name: 'value', value: 832 }] };
|
||||
const inner = { links: new Map([[50, { origin_id: 8, origin_slot: 0 }]]), outputs: [{ linkIds: [50] }], getNodeById: (id) => ({ 8: sizes, 9: latent })[id] ?? null };
|
||||
const box = { id: 3, mode: 0, type: 'subgraph-id', subgraph: inner, isSubgraphNode: () => true };
|
||||
const node = { inputs: [{ name: 'width', link: 4 }], graph: { links: { 4: { origin_id: 3, origin_slot: 0 } }, getNodeById: (id) => (id === 3 ? box : null) } };
|
||||
assert.equal(wiredNumber(node, 'width'), 832);
|
||||
});
|
||||
|
||||
Vendored
+473
@@ -0,0 +1,473 @@
|
||||
{"about":"Load Image size plans. nodes/_load_image_helpers.py made these; js/shared/load_size.mjs must give the same.",
|
||||
"columns":["source_width", "source_height", "size", "megapixels", "longest_side", "scale", "width", "height", "multiple", "enlarge", "crop_from", "ratio", "resize_width", "resize_height", "crop_x", "crop_y", "out_width", "out_height"],
|
||||
"rows":[
|
||||
[912,1632,"off",1.0,1024,1.0,1024,1024,1,true,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"off",1.0,1024,1.0,1024,1024,16,true,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"megapixels",0.25,1024,1.0,1024,1024,1,true,"center","1:1",374,669,0,0,374,669],
|
||||
[912,1632,"megapixels",2.0,1024,1.0,1024,1024,1,true,"center","1:1",1057,1892,0,0,1057,1892],
|
||||
[912,1632,"longest side",1.0,1000,1.0,1024,1024,1,true,"center","1:1",559,1000,0,0,559,1000],
|
||||
[912,1632,"longest side",1.0,2048,1.0,1024,1024,1,true,"center","1:1",1144,2048,0,0,1144,2048],
|
||||
[912,1632,"scale",1.0,1024,0.33,1024,1024,1,true,"center","1:1",301,539,0,0,301,539],
|
||||
[912,1632,"scale",1.0,1024,1.5,1024,1024,1,true,"center","1:1",1368,2448,0,0,1368,2448],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1024,1024,1,true,"center","1:1",572,1024,0,0,572,1024],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1024,1833,0,404,1024,1024],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1280,720,1,true,"center","1:1",402,720,0,0,402,720],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1280,720,1,true,"center","1:1",1280,2291,0,785,1280,720],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1000,600,1,true,"center","1:1",335,600,0,0,335,600],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1000,600,1,true,"center","1:1",1000,1790,0,595,1000,600],
|
||||
[912,1632,"megapixels",0.25,1024,1.0,1024,1024,1,false,"center","1:1",374,669,0,0,374,669],
|
||||
[912,1632,"megapixels",2.0,1024,1.0,1024,1024,1,false,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"longest side",1.0,1000,1.0,1024,1024,1,false,"center","1:1",559,1000,0,0,559,1000],
|
||||
[912,1632,"longest side",1.0,2048,1.0,1024,1024,1,false,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"scale",1.0,1024,0.33,1024,1024,1,false,"center","1:1",301,539,0,0,301,539],
|
||||
[912,1632,"scale",1.0,1024,1.5,1024,1024,1,false,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1024,1024,1,false,"center","1:1",572,1024,0,0,572,1024],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"center","1:1",912,1632,0,360,912,912],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1280,720,1,false,"center","1:1",402,720,0,0,402,720],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1280,720,1,false,"center","1:1",912,1632,0,559,912,513],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1000,600,1,false,"center","1:1",335,600,0,0,335,600],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1000,600,1,false,"center","1:1",912,1632,0,542,912,547],
|
||||
[912,1632,"megapixels",0.25,1024,1.0,1024,1024,16,true,"center","1:1",368,672,0,0,368,672],
|
||||
[912,1632,"megapixels",2.0,1024,1.0,1024,1024,16,true,"center","1:1",1056,1888,0,0,1056,1888],
|
||||
[912,1632,"longest side",1.0,1000,1.0,1024,1024,16,true,"center","1:1",560,1008,0,0,560,1008],
|
||||
[912,1632,"longest side",1.0,2048,1.0,1024,1024,16,true,"center","1:1",1152,2048,0,0,1152,2048],
|
||||
[912,1632,"scale",1.0,1024,0.33,1024,1024,16,true,"center","1:1",304,544,0,0,304,544],
|
||||
[912,1632,"scale",1.0,1024,1.5,1024,1024,16,true,"center","1:1",1376,2448,0,0,1376,2448],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1024,1024,16,true,"center","1:1",576,1024,0,0,576,1024],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1024,1833,0,404,1024,1024],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1280,720,16,true,"center","1:1",400,720,0,0,400,720],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1280,720,16,true,"center","1:1",1280,2291,0,785,1280,720],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1000,600,16,true,"center","1:1",336,592,0,0,336,592],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1000,600,16,true,"center","1:1",1008,1804,0,598,1008,608],
|
||||
[912,1632,"megapixels",0.25,1024,1.0,1024,1024,16,false,"center","1:1",368,672,0,0,368,672],
|
||||
[912,1632,"megapixels",2.0,1024,1.0,1024,1024,16,false,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"longest side",1.0,1000,1.0,1024,1024,16,false,"center","1:1",560,1008,0,0,560,1008],
|
||||
[912,1632,"longest side",1.0,2048,1.0,1024,1024,16,false,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"scale",1.0,1024,0.33,1024,1024,16,false,"center","1:1",304,544,0,0,304,544],
|
||||
[912,1632,"scale",1.0,1024,1.5,1024,1024,16,false,"center","1:1",912,1632,0,0,912,1632],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1024,1024,16,false,"center","1:1",576,1024,0,0,576,1024],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"center","1:1",912,1632,0,360,912,912],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1280,720,16,false,"center","1:1",400,720,0,0,400,720],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1280,720,16,false,"center","1:1",912,1632,0,560,912,512],
|
||||
[912,1632,"fit inside",1.0,1024,1.0,1000,600,16,false,"center","1:1",336,592,0,0,336,592],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1000,600,16,false,"center","1:1",912,1632,0,544,912,544],
|
||||
[1920,1080,"off",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1920,1080,0,0,1920,1080],
|
||||
[1920,1080,"off",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1920,1080,0,0,1920,1080],
|
||||
[1920,1080,"megapixels",0.25,1024,1.0,1024,1024,1,true,"center","1:1",667,375,0,0,667,375],
|
||||
[1920,1080,"megapixels",2.0,1024,1.0,1024,1024,1,true,"center","1:1",1886,1061,0,0,1886,1061],
|
||||
[1920,1080,"longest side",1.0,1000,1.0,1024,1024,1,true,"center","1:1",1000,563,0,0,1000,563],
|
||||
[1920,1080,"longest side",1.0,2048,1.0,1024,1024,1,true,"center","1:1",2048,1152,0,0,2048,1152],
|
||||
[1920,1080,"scale",1.0,1024,0.33,1024,1024,1,true,"center","1:1",634,356,0,0,634,356],
|
||||
[1920,1080,"scale",1.0,1024,1.5,1024,1024,1,true,"center","1:1",2880,1620,0,0,2880,1620],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1024,576,0,0,1024,576],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1821,1024,398,0,1024,1024],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1280,720,1,true,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1280,720,1,true,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1000,600,1,true,"center","1:1",1000,563,0,0,1000,563],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1000,600,1,true,"center","1:1",1067,600,33,0,1000,600],
|
||||
[1920,1080,"megapixels",0.25,1024,1.0,1024,1024,1,false,"center","1:1",667,375,0,0,667,375],
|
||||
[1920,1080,"megapixels",2.0,1024,1.0,1024,1024,1,false,"center","1:1",1886,1061,0,0,1886,1061],
|
||||
[1920,1080,"longest side",1.0,1000,1.0,1024,1024,1,false,"center","1:1",1000,563,0,0,1000,563],
|
||||
[1920,1080,"longest side",1.0,2048,1.0,1024,1024,1,false,"center","1:1",1920,1080,0,0,1920,1080],
|
||||
[1920,1080,"scale",1.0,1024,0.33,1024,1024,1,false,"center","1:1",634,356,0,0,634,356],
|
||||
[1920,1080,"scale",1.0,1024,1.5,1024,1024,1,false,"center","1:1",1920,1080,0,0,1920,1080],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1024,1024,1,false,"center","1:1",1024,576,0,0,1024,576],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"center","1:1",1821,1024,398,0,1024,1024],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1280,720,1,false,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1280,720,1,false,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1000,600,1,false,"center","1:1",1000,563,0,0,1000,563],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1000,600,1,false,"center","1:1",1067,600,33,0,1000,600],
|
||||
[1920,1080,"megapixels",0.25,1024,1.0,1024,1024,16,true,"center","1:1",672,368,0,0,672,368],
|
||||
[1920,1080,"megapixels",2.0,1024,1.0,1024,1024,16,true,"center","1:1",1888,1056,0,0,1888,1056],
|
||||
[1920,1080,"longest side",1.0,1000,1.0,1024,1024,16,true,"center","1:1",1008,560,0,0,1008,560],
|
||||
[1920,1080,"longest side",1.0,2048,1.0,1024,1024,16,true,"center","1:1",2048,1152,0,0,2048,1152],
|
||||
[1920,1080,"scale",1.0,1024,0.33,1024,1024,16,true,"center","1:1",640,352,0,0,640,352],
|
||||
[1920,1080,"scale",1.0,1024,1.5,1024,1024,16,true,"center","1:1",2880,1616,0,0,2880,1616],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1024,576,0,0,1024,576],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1821,1024,398,0,1024,1024],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1280,720,16,true,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1280,720,16,true,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1000,600,16,true,"center","1:1",992,560,0,0,992,560],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1000,600,16,true,"center","1:1",1081,608,36,0,1008,608],
|
||||
[1920,1080,"megapixels",0.25,1024,1.0,1024,1024,16,false,"center","1:1",672,368,0,0,672,368],
|
||||
[1920,1080,"megapixels",2.0,1024,1.0,1024,1024,16,false,"center","1:1",1888,1056,0,0,1888,1056],
|
||||
[1920,1080,"longest side",1.0,1000,1.0,1024,1024,16,false,"center","1:1",1008,560,0,0,1008,560],
|
||||
[1920,1080,"longest side",1.0,2048,1.0,1024,1024,16,false,"center","1:1",1920,1072,0,0,1920,1072],
|
||||
[1920,1080,"scale",1.0,1024,0.33,1024,1024,16,false,"center","1:1",640,352,0,0,640,352],
|
||||
[1920,1080,"scale",1.0,1024,1.5,1024,1024,16,false,"center","1:1",1920,1072,0,0,1920,1072],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1024,1024,16,false,"center","1:1",1024,576,0,0,1024,576],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"center","1:1",1821,1024,398,0,1024,1024],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1280,720,16,false,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1280,720,16,false,"center","1:1",1280,720,0,0,1280,720],
|
||||
[1920,1080,"fit inside",1.0,1024,1.0,1000,600,16,false,"center","1:1",992,560,0,0,992,560],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1000,600,16,false,"center","1:1",1053,592,30,0,992,592],
|
||||
[640,480,"off",1.0,1024,1.0,1024,1024,1,true,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"off",1.0,1024,1.0,1024,1024,16,true,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"megapixels",0.25,1024,1.0,1024,1024,1,true,"center","1:1",577,433,0,0,577,433],
|
||||
[640,480,"megapixels",2.0,1024,1.0,1024,1024,1,true,"center","1:1",1633,1225,0,0,1633,1225],
|
||||
[640,480,"longest side",1.0,1000,1.0,1024,1024,1,true,"center","1:1",1000,750,0,0,1000,750],
|
||||
[640,480,"longest side",1.0,2048,1.0,1024,1024,1,true,"center","1:1",2048,1536,0,0,2048,1536],
|
||||
[640,480,"scale",1.0,1024,0.33,1024,1024,1,true,"center","1:1",211,158,0,0,211,158],
|
||||
[640,480,"scale",1.0,1024,1.5,1024,1024,1,true,"center","1:1",960,720,0,0,960,720],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1024,768,0,0,1024,768],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1366,1024,171,0,1024,1024],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1280,720,1,true,"center","1:1",960,720,0,0,960,720],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1280,720,1,true,"center","1:1",1280,960,0,120,1280,720],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1000,600,1,true,"center","1:1",800,600,0,0,800,600],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1000,600,1,true,"center","1:1",1000,750,0,75,1000,600],
|
||||
[640,480,"megapixels",0.25,1024,1.0,1024,1024,1,false,"center","1:1",577,433,0,0,577,433],
|
||||
[640,480,"megapixels",2.0,1024,1.0,1024,1024,1,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"longest side",1.0,1000,1.0,1024,1024,1,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"longest side",1.0,2048,1.0,1024,1024,1,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"scale",1.0,1024,0.33,1024,1024,1,false,"center","1:1",211,158,0,0,211,158],
|
||||
[640,480,"scale",1.0,1024,1.5,1024,1024,1,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1024,1024,1,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"center","1:1",640,480,80,0,480,480],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1280,720,1,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1280,720,1,false,"center","1:1",640,480,0,60,640,360],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1000,600,1,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1000,600,1,false,"center","1:1",640,480,0,48,640,384],
|
||||
[640,480,"megapixels",0.25,1024,1.0,1024,1024,16,true,"center","1:1",576,432,0,0,576,432],
|
||||
[640,480,"megapixels",2.0,1024,1.0,1024,1024,16,true,"center","1:1",1632,1232,0,0,1632,1232],
|
||||
[640,480,"longest side",1.0,1000,1.0,1024,1024,16,true,"center","1:1",1008,752,0,0,1008,752],
|
||||
[640,480,"longest side",1.0,2048,1.0,1024,1024,16,true,"center","1:1",2048,1536,0,0,2048,1536],
|
||||
[640,480,"scale",1.0,1024,0.33,1024,1024,16,true,"center","1:1",208,160,0,0,208,160],
|
||||
[640,480,"scale",1.0,1024,1.5,1024,1024,16,true,"center","1:1",960,720,0,0,960,720],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1024,768,0,0,1024,768],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1366,1024,171,0,1024,1024],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1280,720,16,true,"center","1:1",960,720,0,0,960,720],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1280,720,16,true,"center","1:1",1280,960,0,120,1280,720],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1000,600,16,true,"center","1:1",800,592,0,0,800,592],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1000,600,16,true,"center","1:1",1008,756,0,74,1008,608],
|
||||
[640,480,"megapixels",0.25,1024,1.0,1024,1024,16,false,"center","1:1",576,432,0,0,576,432],
|
||||
[640,480,"megapixels",2.0,1024,1.0,1024,1024,16,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"longest side",1.0,1000,1.0,1024,1024,16,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"longest side",1.0,2048,1.0,1024,1024,16,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"scale",1.0,1024,0.33,1024,1024,16,false,"center","1:1",208,160,0,0,208,160],
|
||||
[640,480,"scale",1.0,1024,1.5,1024,1024,16,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1024,1024,16,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"center","1:1",640,480,80,0,480,480],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1280,720,16,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1280,720,16,false,"center","1:1",640,480,0,64,640,352],
|
||||
[640,480,"fit inside",1.0,1024,1.0,1000,600,16,false,"center","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1000,600,16,false,"center","1:1",640,480,0,48,640,384],
|
||||
[333,777,"off",1.0,1024,1.0,1024,1024,1,true,"center","1:1",333,777,0,0,333,777],
|
||||
[333,777,"off",1.0,1024,1.0,1024,1024,16,true,"center","1:1",333,777,0,0,333,777],
|
||||
[333,777,"megapixels",0.25,1024,1.0,1024,1024,1,true,"center","1:1",327,764,0,0,327,764],
|
||||
[333,777,"megapixels",2.0,1024,1.0,1024,1024,1,true,"center","1:1",926,2160,0,0,926,2160],
|
||||
[333,777,"longest side",1.0,1000,1.0,1024,1024,1,true,"center","1:1",429,1000,0,0,429,1000],
|
||||
[333,777,"longest side",1.0,2048,1.0,1024,1024,1,true,"center","1:1",878,2048,0,0,878,2048],
|
||||
[333,777,"scale",1.0,1024,0.33,1024,1024,1,true,"center","1:1",110,256,0,0,110,256],
|
||||
[333,777,"scale",1.0,1024,1.5,1024,1024,1,true,"center","1:1",500,1166,0,0,500,1166],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1024,1024,1,true,"center","1:1",439,1024,0,0,439,1024],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1024,2390,0,683,1024,1024],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1280,720,1,true,"center","1:1",309,720,0,0,309,720],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1280,720,1,true,"center","1:1",1280,2987,0,1133,1280,720],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1000,600,1,true,"center","1:1",257,600,0,0,257,600],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1000,600,1,true,"center","1:1",1000,2334,0,867,1000,600],
|
||||
[333,777,"megapixels",0.25,1024,1.0,1024,1024,1,false,"center","1:1",327,764,0,0,327,764],
|
||||
[333,777,"megapixels",2.0,1024,1.0,1024,1024,1,false,"center","1:1",333,777,0,0,333,777],
|
||||
[333,777,"longest side",1.0,1000,1.0,1024,1024,1,false,"center","1:1",333,777,0,0,333,777],
|
||||
[333,777,"longest side",1.0,2048,1.0,1024,1024,1,false,"center","1:1",333,777,0,0,333,777],
|
||||
[333,777,"scale",1.0,1024,0.33,1024,1024,1,false,"center","1:1",110,256,0,0,110,256],
|
||||
[333,777,"scale",1.0,1024,1.5,1024,1024,1,false,"center","1:1",333,777,0,0,333,777],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1024,1024,1,false,"center","1:1",333,777,0,0,333,777],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"center","1:1",333,777,0,222,333,333],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1280,720,1,false,"center","1:1",309,720,0,0,309,720],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1280,720,1,false,"center","1:1",333,777,0,295,333,187],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1000,600,1,false,"center","1:1",257,600,0,0,257,600],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1000,600,1,false,"center","1:1",333,777,0,289,333,199],
|
||||
[333,777,"megapixels",0.25,1024,1.0,1024,1024,16,true,"center","1:1",320,768,0,0,320,768],
|
||||
[333,777,"megapixels",2.0,1024,1.0,1024,1024,16,true,"center","1:1",928,2160,0,0,928,2160],
|
||||
[333,777,"longest side",1.0,1000,1.0,1024,1024,16,true,"center","1:1",432,1008,0,0,432,1008],
|
||||
[333,777,"longest side",1.0,2048,1.0,1024,1024,16,true,"center","1:1",880,2048,0,0,880,2048],
|
||||
[333,777,"scale",1.0,1024,0.33,1024,1024,16,true,"center","1:1",112,256,0,0,112,256],
|
||||
[333,777,"scale",1.0,1024,1.5,1024,1024,16,true,"center","1:1",496,1168,0,0,496,1168],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1024,1024,16,true,"center","1:1",432,1024,0,0,432,1024],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1024,2390,0,683,1024,1024],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1280,720,16,true,"center","1:1",304,720,0,0,304,720],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1280,720,16,true,"center","1:1",1280,2987,0,1133,1280,720],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1000,600,16,true,"center","1:1",256,592,0,0,256,592],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1000,600,16,true,"center","1:1",1008,2352,0,872,1008,608],
|
||||
[333,777,"megapixels",0.25,1024,1.0,1024,1024,16,false,"center","1:1",320,768,0,0,320,768],
|
||||
[333,777,"megapixels",2.0,1024,1.0,1024,1024,16,false,"center","1:1",320,768,0,0,320,768],
|
||||
[333,777,"longest side",1.0,1000,1.0,1024,1024,16,false,"center","1:1",320,768,0,0,320,768],
|
||||
[333,777,"longest side",1.0,2048,1.0,1024,1024,16,false,"center","1:1",320,768,0,0,320,768],
|
||||
[333,777,"scale",1.0,1024,0.33,1024,1024,16,false,"center","1:1",112,256,0,0,112,256],
|
||||
[333,777,"scale",1.0,1024,1.5,1024,1024,16,false,"center","1:1",320,768,0,0,320,768],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1024,1024,16,false,"center","1:1",320,768,0,0,320,768],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"center","1:1",320,747,0,213,320,320],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1280,720,16,false,"center","1:1",304,720,0,0,304,720],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1280,720,16,false,"center","1:1",320,747,0,285,320,176],
|
||||
[333,777,"fit inside",1.0,1024,1.0,1000,600,16,false,"center","1:1",256,592,0,0,256,592],
|
||||
[333,777,"crop to fill",1.0,1024,1.0,1000,600,16,false,"center","1:1",320,747,0,277,320,192],
|
||||
[8192,5464,"off",1.0,1024,1.0,1024,1024,1,true,"center","1:1",8192,5464,0,0,8192,5464],
|
||||
[8192,5464,"off",1.0,1024,1.0,1024,1024,16,true,"center","1:1",8192,5464,0,0,8192,5464],
|
||||
[8192,5464,"megapixels",0.25,1024,1.0,1024,1024,1,true,"center","1:1",612,408,0,0,612,408],
|
||||
[8192,5464,"megapixels",2.0,1024,1.0,1024,1024,1,true,"center","1:1",1732,1155,0,0,1732,1155],
|
||||
[8192,5464,"longest side",1.0,1000,1.0,1024,1024,1,true,"center","1:1",1000,667,0,0,1000,667],
|
||||
[8192,5464,"longest side",1.0,2048,1.0,1024,1024,1,true,"center","1:1",2048,1366,0,0,2048,1366],
|
||||
[8192,5464,"scale",1.0,1024,0.33,1024,1024,1,true,"center","1:1",2703,1803,0,0,2703,1803],
|
||||
[8192,5464,"scale",1.0,1024,1.5,1024,1024,1,true,"center","1:1",12288,8196,0,0,12288,8196],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1024,683,0,0,1024,683],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"center","1:1",1536,1024,256,0,1024,1024],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1280,720,1,true,"center","1:1",1079,720,0,0,1079,720],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1280,720,1,true,"center","1:1",1280,854,0,67,1280,720],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1000,600,1,true,"center","1:1",900,600,0,0,900,600],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1000,600,1,true,"center","1:1",1000,667,0,33,1000,600],
|
||||
[8192,5464,"megapixels",0.25,1024,1.0,1024,1024,1,false,"center","1:1",612,408,0,0,612,408],
|
||||
[8192,5464,"megapixels",2.0,1024,1.0,1024,1024,1,false,"center","1:1",1732,1155,0,0,1732,1155],
|
||||
[8192,5464,"longest side",1.0,1000,1.0,1024,1024,1,false,"center","1:1",1000,667,0,0,1000,667],
|
||||
[8192,5464,"longest side",1.0,2048,1.0,1024,1024,1,false,"center","1:1",2048,1366,0,0,2048,1366],
|
||||
[8192,5464,"scale",1.0,1024,0.33,1024,1024,1,false,"center","1:1",2703,1803,0,0,2703,1803],
|
||||
[8192,5464,"scale",1.0,1024,1.5,1024,1024,1,false,"center","1:1",8192,5464,0,0,8192,5464],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1024,1024,1,false,"center","1:1",1024,683,0,0,1024,683],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"center","1:1",1536,1024,256,0,1024,1024],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1280,720,1,false,"center","1:1",1079,720,0,0,1079,720],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1280,720,1,false,"center","1:1",1280,854,0,67,1280,720],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1000,600,1,false,"center","1:1",900,600,0,0,900,600],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1000,600,1,false,"center","1:1",1000,667,0,33,1000,600],
|
||||
[8192,5464,"megapixels",0.25,1024,1.0,1024,1024,16,true,"center","1:1",608,416,0,0,608,416],
|
||||
[8192,5464,"megapixels",2.0,1024,1.0,1024,1024,16,true,"center","1:1",1728,1152,0,0,1728,1152],
|
||||
[8192,5464,"longest side",1.0,1000,1.0,1024,1024,16,true,"center","1:1",1008,672,0,0,1008,672],
|
||||
[8192,5464,"longest side",1.0,2048,1.0,1024,1024,16,true,"center","1:1",2048,1360,0,0,2048,1360],
|
||||
[8192,5464,"scale",1.0,1024,0.33,1024,1024,16,true,"center","1:1",2704,1808,0,0,2704,1808],
|
||||
[8192,5464,"scale",1.0,1024,1.5,1024,1024,16,true,"center","1:1",12288,8192,0,0,12288,8192],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1024,688,0,0,1024,688],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"center","1:1",1536,1024,256,0,1024,1024],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1280,720,16,true,"center","1:1",1072,720,0,0,1072,720],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1280,720,16,true,"center","1:1",1280,854,0,67,1280,720],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1000,600,16,true,"center","1:1",896,592,0,0,896,592],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1000,600,16,true,"center","1:1",1008,673,0,32,1008,608],
|
||||
[8192,5464,"megapixels",0.25,1024,1.0,1024,1024,16,false,"center","1:1",608,416,0,0,608,416],
|
||||
[8192,5464,"megapixels",2.0,1024,1.0,1024,1024,16,false,"center","1:1",1728,1152,0,0,1728,1152],
|
||||
[8192,5464,"longest side",1.0,1000,1.0,1024,1024,16,false,"center","1:1",1008,672,0,0,1008,672],
|
||||
[8192,5464,"longest side",1.0,2048,1.0,1024,1024,16,false,"center","1:1",2048,1360,0,0,2048,1360],
|
||||
[8192,5464,"scale",1.0,1024,0.33,1024,1024,16,false,"center","1:1",2704,1808,0,0,2704,1808],
|
||||
[8192,5464,"scale",1.0,1024,1.5,1024,1024,16,false,"center","1:1",8192,5456,0,0,8192,5456],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1024,1024,16,false,"center","1:1",1024,688,0,0,1024,688],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"center","1:1",1536,1024,256,0,1024,1024],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1280,720,16,false,"center","1:1",1072,720,0,0,1072,720],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1280,720,16,false,"center","1:1",1280,854,0,67,1280,720],
|
||||
[8192,5464,"fit inside",1.0,1024,1.0,1000,600,16,false,"center","1:1",896,592,0,0,896,592],
|
||||
[8192,5464,"crop to fill",1.0,1024,1.0,1000,600,16,false,"center","1:1",992,662,0,35,992,592],
|
||||
[1000,1000,"longest side",1.0,1000,1.0,1024,1024,64,true,"center","1:1",1024,1024,0,0,1024,1024],
|
||||
[30,20,"megapixels",1.0,1024,1.0,1024,1024,64,false,"center","1:1",64,64,0,0,64,64],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,768,8,true,"center","1:1",1024,1833,0,532,1024,768],
|
||||
[912,1632,"crop",1.0,1024,1.0,513,300,8,true,"center","1:1",912,1632,200,668,512,296],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"center","4:3",912,1632,0,476,912,680],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"top","1:1",1024,1833,0,0,1024,1024],
|
||||
[912,1632,"crop",1.0,1024,1.0,4096,512,64,true,"top","1:1",912,1632,8,0,896,512],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"top","3:4",912,1632,0,0,912,1216],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom","1:1",1024,1833,0,1065,1024,768],
|
||||
[912,1632,"crop",1.0,1024,1.0,768,768,1,true,"bottom","1:1",912,1632,72,864,768,768],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom","3:2",912,1632,0,1024,912,608],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,8,false,"left","1:1",912,1632,0,360,912,912],
|
||||
[912,1632,"crop",1.0,1024,1.0,513,300,8,true,"left","1:1",912,1632,0,668,512,296],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"left","2:3",912,1632,0,132,912,1368],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,768,16,true,"right","1:1",1024,1833,0,532,1024,768],
|
||||
[912,1632,"crop",1.0,1024,1.0,4096,512,64,true,"right","1:1",912,1632,16,560,896,512],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"right","16:9",912,1632,0,560,912,512],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"top left","1:1",1024,1833,0,0,1024,1024],
|
||||
[912,1632,"crop",1.0,1024,1.0,768,768,1,true,"top left","1:1",912,1632,0,0,768,768],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"top left","9:16",912,1632,0,0,912,1621],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,768,8,true,"top right","1:1",1024,1833,0,0,1024,768],
|
||||
[912,1632,"crop",1.0,1024,1.0,513,300,8,true,"top right","1:1",912,1632,400,0,512,296],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"top right","5:4",912,1632,0,0,912,728],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"bottom left","1:1",912,1632,0,720,912,912],
|
||||
[912,1632,"crop",1.0,1024,1.0,4096,512,64,true,"bottom left","1:1",912,1632,0,1120,896,512],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"bottom left","4:5",912,1632,0,496,912,1136],
|
||||
[912,1632,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom right","1:1",1024,1833,0,1065,1024,768],
|
||||
[912,1632,"crop",1.0,1024,1.0,768,768,1,true,"bottom right","1:1",912,1632,144,864,768,768],
|
||||
[912,1632,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom right","21:9",912,1632,0,1241,912,391],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,8,true,"center","1:1",1821,1024,398,0,1024,1024],
|
||||
[1920,1080,"crop",1.0,1024,1.0,513,300,8,true,"center","1:1",1920,1080,704,392,512,296],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"center","9:21",1920,1080,732,0,456,1080],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,768,16,true,"top","1:1",1366,768,171,0,1024,768],
|
||||
[1920,1080,"crop",1.0,1024,1.0,4096,512,64,true,"top","1:1",1920,1080,0,0,1920,512],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"top","2:1",1920,1080,0,0,1920,960],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"bottom","1:1",1821,1024,398,0,1024,1024],
|
||||
[1920,1080,"crop",1.0,1024,1.0,768,768,1,true,"bottom","1:1",1920,1080,576,312,768,768],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom","1:2",1920,1080,690,0,540,1080],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,768,8,true,"left","1:1",1366,768,0,0,1024,768],
|
||||
[1920,1080,"crop",1.0,1024,1.0,513,300,8,true,"left","1:1",1920,1080,0,392,512,296],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"left","width : height",1920,1080,0,0,1920,1080],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"right","1:1",1821,1024,797,0,1024,1024],
|
||||
[1920,1080,"crop",1.0,1024,1.0,4096,512,64,true,"right","1:1",1920,1080,0,284,1920,512],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"right","1:1",1920,1080,848,4,1072,1072],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,768,1,true,"top left","1:1",1366,768,0,0,1024,768],
|
||||
[1920,1080,"crop",1.0,1024,1.0,768,768,1,true,"top left","1:1",1920,1080,0,0,768,768],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"top left","4:3",1920,1080,0,0,1440,1080],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,8,false,"top right","1:1",1821,1024,797,0,1024,1024],
|
||||
[1920,1080,"crop",1.0,1024,1.0,513,300,8,true,"top right","1:1",1920,1080,1408,0,512,296],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"top right","3:4",1920,1080,1112,0,808,1080],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,768,16,true,"bottom left","1:1",1366,768,0,0,1024,768],
|
||||
[1920,1080,"crop",1.0,1024,1.0,4096,512,64,true,"bottom left","1:1",1920,1080,0,568,1920,512],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"bottom left","3:2",1920,1080,0,8,1616,1072],
|
||||
[1920,1080,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"bottom right","1:1",1821,1024,797,0,1024,1024],
|
||||
[1920,1080,"crop",1.0,1024,1.0,768,768,1,true,"bottom right","1:1",1920,1080,1152,312,768,768],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom right","2:3",1920,1080,1200,0,720,1080],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,768,8,true,"center","1:1",1024,1368,0,300,1024,768],
|
||||
[1336,1784,"crop",1.0,1024,1.0,513,300,8,true,"center","1:1",1336,1784,412,744,512,296],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"center","16:9",1336,1784,0,516,1336,752],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"top","1:1",1024,1368,0,0,1024,1024],
|
||||
[1336,1784,"crop",1.0,1024,1.0,4096,512,64,true,"top","1:1",1336,1784,28,0,1280,512],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"top","9:16",1336,1784,172,0,992,1776],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom","1:1",1024,1368,0,600,1024,768],
|
||||
[1336,1784,"crop",1.0,1024,1.0,768,768,1,true,"bottom","1:1",1336,1784,284,1016,768,768],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom","5:4",1336,1784,0,715,1336,1069],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,1024,8,true,"left","1:1",1024,1368,0,172,1024,1024],
|
||||
[1336,1784,"crop",1.0,1024,1.0,513,300,8,true,"left","1:1",1336,1784,0,744,512,296],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"left","4:5",1336,1784,0,60,1336,1664],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,768,16,true,"right","1:1",1024,1368,0,300,1024,768],
|
||||
[1336,1784,"crop",1.0,1024,1.0,4096,512,64,true,"right","1:1",1336,1784,56,636,1280,512],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"right","21:9",1336,1784,8,612,1328,560],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"top left","1:1",1024,1368,0,0,1024,1024],
|
||||
[1336,1784,"crop",1.0,1024,1.0,768,768,1,true,"top left","1:1",1336,1784,0,0,768,768],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"top left","9:21",1336,1784,0,0,765,1784],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,768,8,true,"top right","1:1",1024,1368,0,0,1024,768],
|
||||
[1336,1784,"crop",1.0,1024,1.0,513,300,8,true,"top right","1:1",1336,1784,824,0,512,296],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"top right","2:1",1336,1784,0,0,1336,664],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"bottom left","1:1",1024,1368,0,344,1024,1024],
|
||||
[1336,1784,"crop",1.0,1024,1.0,4096,512,64,true,"bottom left","1:1",1336,1784,0,1272,1280,512],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"bottom left","1:2",1336,1784,0,8,880,1776],
|
||||
[1336,1784,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom right","1:1",1024,1368,0,600,1024,768],
|
||||
[1336,1784,"crop",1.0,1024,1.0,768,768,1,true,"bottom right","1:1",1336,1784,568,1016,768,768],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom right","width : height",1336,1784,0,1032,1336,752],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,8,false,"center","1:1",640,480,80,0,480,480],
|
||||
[640,480,"crop",1.0,1024,1.0,513,300,8,true,"center","1:1",640,480,64,92,512,296],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"center","1:1",640,480,80,0,480,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,768,16,true,"top","1:1",1024,768,0,0,1024,768],
|
||||
[640,480,"crop",1.0,1024,1.0,4096,512,64,true,"top","1:1",640,480,0,0,640,448],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"top","4:3",640,480,0,0,640,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"bottom","1:1",1366,1024,171,0,1024,1024],
|
||||
[640,480,"crop",1.0,1024,1.0,768,768,1,true,"bottom","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom","3:4",640,480,140,0,360,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,768,8,true,"left","1:1",1024,768,0,0,1024,768],
|
||||
[640,480,"crop",1.0,1024,1.0,513,300,8,true,"left","1:1",640,480,0,92,512,296],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"left","3:2",640,480,0,28,640,424],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"right","1:1",640,480,160,0,480,480],
|
||||
[640,480,"crop",1.0,1024,1.0,4096,512,64,true,"right","1:1",640,480,0,16,640,448],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"right","2:3",640,480,320,0,320,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,768,1,true,"top left","1:1",1024,768,0,0,1024,768],
|
||||
[640,480,"crop",1.0,1024,1.0,768,768,1,true,"top left","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"top left","16:9",640,480,0,0,640,360],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,8,true,"top right","1:1",1366,1024,342,0,1024,1024],
|
||||
[640,480,"crop",1.0,1024,1.0,513,300,8,true,"top right","1:1",640,480,128,0,512,296],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"top right","9:16",640,480,376,0,264,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,768,16,true,"bottom left","1:1",1024,768,0,0,1024,768],
|
||||
[640,480,"crop",1.0,1024,1.0,4096,512,64,true,"bottom left","1:1",640,480,0,32,640,448],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"bottom left","5:4",640,480,0,0,592,480],
|
||||
[640,480,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"bottom right","1:1",640,480,160,0,480,480],
|
||||
[640,480,"crop",1.0,1024,1.0,768,768,1,true,"bottom right","1:1",640,480,0,0,640,480],
|
||||
[640,480,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom right","4:5",640,480,256,0,384,480],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,768,8,true,"center","1:1",1024,796,0,14,1024,768],
|
||||
[1000,777,"crop",1.0,1024,1.0,513,300,8,true,"center","1:1",1000,777,244,240,512,296],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"center","21:9",1000,777,0,176,1000,424],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"top","1:1",1318,1024,147,0,1024,1024],
|
||||
[1000,777,"crop",1.0,1024,1.0,4096,512,64,true,"top","1:1",1000,777,20,0,960,512],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"top","9:21",1000,777,340,0,320,768],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom","1:1",1024,796,0,28,1024,768],
|
||||
[1000,777,"crop",1.0,1024,1.0,768,768,1,true,"bottom","1:1",1000,777,116,9,768,768],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom","2:1",1000,777,0,277,1000,500],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,1024,8,false,"left","1:1",999,776,0,0,776,776],
|
||||
[1000,777,"crop",1.0,1024,1.0,513,300,8,true,"left","1:1",1000,777,0,240,512,296],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"left","1:2",1000,777,0,0,384,776],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,768,16,true,"right","1:1",1024,796,0,14,1024,768],
|
||||
[1000,777,"crop",1.0,1024,1.0,4096,512,64,true,"right","1:1",1000,777,40,132,960,512],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"right","width : height",1000,777,8,108,992,560],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"top left","1:1",1318,1024,0,0,1024,1024],
|
||||
[1000,777,"crop",1.0,1024,1.0,768,768,1,true,"top left","1:1",1000,777,0,0,768,768],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"top left","1:1",1000,777,0,0,777,777],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,768,8,true,"top right","1:1",1024,796,0,0,1024,768],
|
||||
[1000,777,"crop",1.0,1024,1.0,513,300,8,true,"top right","1:1",1000,777,488,0,512,296],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"top right","4:3",1000,777,0,0,1000,744],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"bottom left","1:1",989,768,0,0,768,768],
|
||||
[1000,777,"crop",1.0,1024,1.0,4096,512,64,true,"bottom left","1:1",1000,777,0,265,960,512],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"bottom left","3:4",1000,777,0,9,576,768],
|
||||
[1000,777,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom right","1:1",1024,796,0,28,1024,768],
|
||||
[1000,777,"crop",1.0,1024,1.0,768,768,1,true,"bottom right","1:1",1000,777,232,9,768,768],
|
||||
[1000,777,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom right","3:2",1000,777,0,110,1000,667],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,1024,8,true,"center","1:1",1024,68267,0,33621,1024,1024],
|
||||
[30,2000,"crop",1.0,1024,1.0,513,300,8,true,"center","1:1",30,2000,3,852,24,296],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"center","2:3",30,2000,3,980,24,40],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,768,16,true,"top","1:1",1024,68267,0,0,1024,768],
|
||||
[30,2000,"crop",1.0,1024,1.0,4096,512,64,true,"top","1:1",30,2000,0,0,30,512],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"top","16:9",30,2000,7,0,16,16],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"bottom","1:1",30,2000,0,1970,30,30],
|
||||
[30,2000,"crop",1.0,1024,1.0,768,768,1,true,"bottom","1:1",30,2000,0,1232,30,768],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom","9:16",30,2000,0,1947,30,53],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,768,8,true,"left","1:1",1024,68267,0,33749,1024,768],
|
||||
[30,2000,"crop",1.0,1024,1.0,513,300,8,true,"left","1:1",30,2000,0,852,24,296],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"left","5:4",30,2000,0,988,24,24],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"right","1:1",1024,68267,0,33621,1024,1024],
|
||||
[30,2000,"crop",1.0,1024,1.0,4096,512,64,true,"right","1:1",30,2000,0,744,30,512],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"right","4:5",30,2000,14,984,16,32],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,768,1,true,"top left","1:1",1024,68267,0,0,1024,768],
|
||||
[30,2000,"crop",1.0,1024,1.0,768,768,1,true,"top left","1:1",30,2000,0,0,30,768],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"top left","21:9",30,2000,0,0,30,13],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,1024,8,false,"top right","1:1",24,1600,0,0,24,24],
|
||||
[30,2000,"crop",1.0,1024,1.0,513,300,8,true,"top right","1:1",30,2000,6,0,24,296],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"top right","9:21",30,2000,6,0,24,64],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,768,16,true,"bottom left","1:1",1024,68267,0,67499,1024,768],
|
||||
[30,2000,"crop",1.0,1024,1.0,4096,512,64,true,"bottom left","1:1",30,2000,0,1488,30,512],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"bottom left","2:1",30,2000,0,1985,16,15],
|
||||
[30,2000,"crop to fill",1.0,1024,1.0,1024,1024,1,true,"bottom right","1:1",1024,68267,0,67243,1024,1024],
|
||||
[30,2000,"crop",1.0,1024,1.0,768,768,1,true,"bottom right","1:1",30,2000,0,1232,30,768],
|
||||
[30,2000,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom right","1:2",30,2000,0,1940,30,60],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,768,8,true,"center","1:1",1024,1024,0,128,1024,768],
|
||||
[10,10,"crop",1.0,1024,1.0,513,300,8,true,"center","1:1",10,10,1,1,8,8],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"center","width : height",10,10,1,2,8,6],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,1024,16,false,"top","1:1",16,16,0,0,16,16],
|
||||
[10,10,"crop",1.0,1024,1.0,4096,512,64,true,"top","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"top","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom","1:1",1024,1024,0,256,1024,768],
|
||||
[10,10,"crop",1.0,1024,1.0,768,768,1,true,"bottom","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom","4:3",10,10,0,2,10,8],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,1024,8,true,"left","1:1",1024,1024,0,0,1024,1024],
|
||||
[10,10,"crop",1.0,1024,1.0,513,300,8,true,"left","1:1",10,10,0,1,8,8],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"left","3:4",10,10,0,1,8,8],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,768,16,true,"right","1:1",1024,1024,0,128,1024,768],
|
||||
[10,10,"crop",1.0,1024,1.0,4096,512,64,true,"right","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"right","3:2",10,10,0,1,10,7],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,1024,1,false,"top left","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop",1.0,1024,1.0,768,768,1,true,"top left","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"top left","2:3",10,10,0,0,7,10],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,768,8,true,"top right","1:1",1024,1024,0,0,1024,768],
|
||||
[10,10,"crop",1.0,1024,1.0,513,300,8,true,"top right","1:1",10,10,2,0,8,8],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,8,true,"top right","16:9",10,10,2,0,8,6],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,1024,16,true,"bottom left","1:1",1024,1024,0,0,1024,1024],
|
||||
[10,10,"crop",1.0,1024,1.0,4096,512,64,true,"bottom left","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,16,true,"bottom left","9:16",10,10,0,0,6,10],
|
||||
[10,10,"crop to fill",1.0,1024,1.0,1024,768,1,true,"bottom right","1:1",1024,1024,0,256,1024,768],
|
||||
[10,10,"crop",1.0,1024,1.0,768,768,1,true,"bottom right","1:1",10,10,0,0,10,10],
|
||||
[10,10,"crop to ratio",1.0,1024,1.0,1600,900,1,true,"bottom right","5:4",10,10,0,2,10,8],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","1:1",1336,1784,0,0,1336,1336],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","1:1",1920,1080,840,0,1080,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","4:3",1336,1784,0,0,1336,1002],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","4:3",1920,1080,480,0,1440,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","3:4",1336,1784,0,0,1336,1781],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","3:4",1920,1080,1112,0,808,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","3:2",1336,1784,0,0,1336,891],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","3:2",1920,1080,304,0,1616,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","2:3",1336,1784,73,0,1189,1784],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","2:3",1920,1080,1200,0,720,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","16:9",1336,1784,0,0,1336,752],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","16:9",1920,1080,0,0,1920,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","9:16",1336,1784,166,0,1004,1784],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","9:16",1920,1080,1312,0,608,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","5:4",1336,1784,0,0,1336,1069],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","5:4",1920,1080,576,0,1344,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","4:5",1336,1784,0,0,1336,1670],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","4:5",1920,1080,1056,0,864,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","21:9",1336,1784,0,0,1336,573],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","21:9",1920,1080,0,264,1920,816],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","9:21",1336,1784,285,0,765,1784],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","9:21",1920,1080,1464,0,456,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","2:1",1336,1784,0,0,1336,668],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","2:1",1920,1080,0,120,1920,960],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","1:2",1336,1784,222,0,892,1784],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","1:2",1920,1080,1384,0,536,1080],
|
||||
[1336,1784,"crop to ratio",1.0,1024,1.0,1280,544,1,true,"top","width : height",1336,1784,0,0,1336,568],
|
||||
[1920,1080,"crop to ratio",1.0,1024,1.0,1280,544,8,true,"bottom right","width : height",1920,1080,0,264,1920,816]
|
||||
]}
|
||||
Vendored
+50
-1
@@ -144,7 +144,9 @@
|
||||
"edit_lock",
|
||||
"feather"
|
||||
],
|
||||
"optional": [],
|
||||
"optional": [
|
||||
"remove_tint"
|
||||
],
|
||||
"outputs": [
|
||||
[
|
||||
"IMAGE",
|
||||
@@ -583,6 +585,53 @@
|
||||
]
|
||||
]
|
||||
},
|
||||
"AUSBOSS_NODES_LoadImage": {
|
||||
"required": [
|
||||
"image",
|
||||
"size",
|
||||
"megapixels",
|
||||
"longest_side",
|
||||
"scale",
|
||||
"width",
|
||||
"height",
|
||||
"multiple",
|
||||
"method",
|
||||
"enlarge",
|
||||
"crop_from",
|
||||
"ratio"
|
||||
],
|
||||
"optional": [],
|
||||
"outputs": [
|
||||
[
|
||||
"IMAGE",
|
||||
"image"
|
||||
],
|
||||
[
|
||||
"MASK",
|
||||
"mask"
|
||||
],
|
||||
[
|
||||
"INT",
|
||||
"width"
|
||||
],
|
||||
[
|
||||
"INT",
|
||||
"height"
|
||||
],
|
||||
[
|
||||
"STRING",
|
||||
"filename"
|
||||
],
|
||||
[
|
||||
"INT",
|
||||
"original_width"
|
||||
],
|
||||
[
|
||||
"INT",
|
||||
"original_height"
|
||||
]
|
||||
]
|
||||
},
|
||||
"AUSBOSS_NODES_LoadImagePad": {
|
||||
"required": [
|
||||
"image",
|
||||
|
||||
@@ -114,3 +114,17 @@ test('Length row replaces the whole number+unit, preserves its value, and restor
|
||||
source.mode=0;sync({...values,video_job:'keep going'});assert.equal(scrub.root.style.display,'');
|
||||
assert.equal(node.widgets[0].value,12);assert.equal(node.inputs[0].link,8);
|
||||
});
|
||||
|
||||
test('H3 makes 5 + 17n frames, rounding a clip down (Python video_frames)', async () => {
|
||||
const { h3VideoFrames, clipLengthWords } = await import('../js/shared/h3_duration.mjs');
|
||||
assert.equal(h3VideoFrames(48), 39);
|
||||
assert.equal(h3VideoFrames(39), 39);
|
||||
assert.equal(h3VideoFrames(56), 56);
|
||||
assert.equal(h3VideoFrames(10), 22);
|
||||
assert.equal(h3VideoFrames(1000), 360 - ((360 - 5) % 17));
|
||||
const words = clipLengthWords({ frames: 48, startSeconds: 1, endSeconds: 3, roomFrames: 74 });
|
||||
assert.equal(words.title, "H3 makes 39 of the clip's 48 frames · 1.63 s");
|
||||
assert.match(words.note, /Stops at 2\.63 s.*1\.63 s or 2\.33 s/);
|
||||
assert.equal(clipLengthWords({ frames: 39, startSeconds: 0, endSeconds: 1.625 }).warn, false);
|
||||
assert.equal(clipLengthWords(null), null);
|
||||
});
|
||||
|
||||
@@ -4,6 +4,8 @@ import test from "node:test";
|
||||
import {
|
||||
describeNodePreview,
|
||||
describeOwnResult,
|
||||
lightPreviewQuery,
|
||||
ownResultIsCurrent,
|
||||
describeSourcePreview,
|
||||
linkById,
|
||||
outputLocatorId,
|
||||
@@ -192,3 +194,64 @@ test("without node.imgs the stored output is the result, ahead of the input", ()
|
||||
node.imgs = [{ src: "own-result" }];
|
||||
assert.deepEqual(describeNodePreview(node, "images", "/view?stored"), { kind: "url", url: "own-result" });
|
||||
});
|
||||
|
||||
test("a picture the frontend gave up loading does not hide the newer result", () => {
|
||||
// The frontend loads a result into node.imgs with a time limit. A 31 MB
|
||||
// sheet over a slow link ran past it, node.imgs kept the run before, and
|
||||
// the panel went on showing that older picture.
|
||||
const view = (name, folder = "", type = "output") =>
|
||||
`http://host/api/view?filename=${name}&subfolder=${folder}&type=${type}&rand=0.5`;
|
||||
const before = { images: [{ filename: "sheet_00009.png", subfolder: "", type: "output" }] };
|
||||
const after = { images: [{ filename: "75dc_000.png", subfolder: "ausboss_held", type: "temp" }] };
|
||||
const node = { inputs: [], imgs: [{ src: view("sheet_00009.png") }] };
|
||||
|
||||
// Loaded for the record on the node: node.imgs is the result.
|
||||
assert.equal(ownResultIsCurrent(node, before, before), true);
|
||||
// A newer run, and node.imgs was never set again: it is the run before.
|
||||
assert.equal(ownResultIsCurrent(node, after, before), false);
|
||||
assert.deepEqual(
|
||||
describeNodePreview(node, "images", "/view?stored", ownResultIsCurrent(node, after, before)),
|
||||
{ kind: "url", url: "/view?stored" },
|
||||
);
|
||||
// The same name written over (exact name, overwrite) is still a newer run.
|
||||
const again = { images: [{ filename: "sheet_00009.png", subfolder: "", type: "output" }] };
|
||||
assert.equal(ownResultIsCurrent(node, again, before), false);
|
||||
// Set while a still newer run came in: the names tell them apart.
|
||||
assert.equal(ownResultIsCurrent(node, after, after), false);
|
||||
// Once the frontend does load it, node.imgs is the result again.
|
||||
node.imgs = [{ src: view("75dc_000.png", "ausboss_held", "temp") }];
|
||||
assert.equal(ownResultIsCurrent(node, after, after), true);
|
||||
assert.deepEqual(
|
||||
describeNodePreview(node, "images", "/view?stored", ownResultIsCurrent(node, after, after)),
|
||||
{ kind: "url", url: node.imgs[0].src },
|
||||
);
|
||||
|
||||
// A frame streamed during a run is not a stored file: it stays the result.
|
||||
assert.equal(ownResultIsCurrent({ imgs: [{ src: "blob:http://host/1" }] }, after, before), true);
|
||||
// No stored picture to compare with: node.imgs is all there is.
|
||||
assert.equal(ownResultIsCurrent(node, null, undefined), true);
|
||||
assert.equal(ownResultIsCurrent(node, { images: [] }, before), true);
|
||||
// Nothing in node.imgs is never current.
|
||||
assert.equal(ownResultIsCurrent({ imgs: [] }, after, after), false);
|
||||
assert.equal(ownResultIsCurrent(null, after, after), false);
|
||||
});
|
||||
|
||||
test("Save Image's small copy is what the panel asks for", () => {
|
||||
const record = {
|
||||
images: [
|
||||
{ filename: "sheet_00001.png", subfolder: "", type: "output" },
|
||||
{ filename: "sheet_00002.png", subfolder: "", type: "output" },
|
||||
],
|
||||
ausboss_preview: ["ausboss_preview/ab12_000.webp", "ausboss_preview/ab12_001.webp"],
|
||||
};
|
||||
// The newest by default, or the one the arrows picked.
|
||||
assert.equal(lightPreviewQuery(record), "filename=ab12_001.webp&subfolder=ausboss_preview&type=temp");
|
||||
assert.equal(lightPreviewQuery(record, 0), "filename=ab12_000.webp&subfolder=ausboss_preview&type=temp");
|
||||
// No copies (an older run, another node, the preview off): the file itself.
|
||||
assert.equal(lightPreviewQuery({ images: record.images }), null);
|
||||
assert.equal(lightPreviewQuery({ images: record.images, ausboss_preview: [] }), null);
|
||||
// A list that does not match the pictures is not trusted.
|
||||
assert.equal(lightPreviewQuery({ images: record.images, ausboss_preview: ["ausboss_preview/x.webp"] }), null);
|
||||
assert.equal(lightPreviewQuery({ images: record.images, ausboss_preview: ["", 5] }), null);
|
||||
assert.equal(lightPreviewQuery(null), null);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { grabZone, outputSummary, outputWindow, wavePeaks } from "../js/load_audio/audio_window.mjs";
|
||||
import { grabZone, outputWindow, pickWrites, typedPick, wavePeaks } from "../js/load_audio/audio_window.mjs";
|
||||
|
||||
test("the face shows what the node hands on", () => {
|
||||
// Mirrors audio_window in nodes/_audio_trim_helpers.py.
|
||||
@@ -13,11 +13,34 @@ test("the face shows what the node hands on", () => {
|
||||
assert.equal(outputWindow(10, "x", null, NaN).length, 10);
|
||||
});
|
||||
|
||||
test("the line between IN and OUT says how long and what is cut", () => {
|
||||
assert.equal(outputSummary(outputWindow(40, 8, 30, 15)), "15.0 s · cut 7.0 s");
|
||||
assert.equal(outputSummary(outputWindow(200, 0, 0, 0)), "3:20.0");
|
||||
assert.equal(outputSummary(outputWindow(40, 8, 30, 0), { maxFromLink: true }), "22.0 s · max wired");
|
||||
assert.equal(outputSummary(outputWindow(0, 0, 0)), "");
|
||||
test("a pick is stored as a Start and a Duration", () => {
|
||||
// 2 s to 5 s of a 12 s file: Start 2, Duration 3, no end.
|
||||
assert.deepEqual(pickWrites(12, 2, 5), { start: 2, end: 0, max: 3 });
|
||||
// To the end of the file: no Duration, so a longer file later still runs to its end.
|
||||
assert.deepEqual(pickWrites(12, 2, 12), { start: 2, end: 0, max: 0 });
|
||||
// Hundredths, as the boxes show them; the Duration is the difference of the two.
|
||||
assert.deepEqual(pickWrites(12, 1.234, 3.606), { start: 1.23, end: 0, max: 2.38 });
|
||||
// A linked Duration cannot be written: the pick is a start and an end.
|
||||
assert.deepEqual(pickWrites(12, 2, 5, { maxLinked: true }), { start: 2, end: 5 });
|
||||
// A linked end leaves only the start to write.
|
||||
assert.deepEqual(pickWrites(12, 2, 5, { endLinked: true }), { start: 2 });
|
||||
// What it stores comes out as the same pick.
|
||||
const stored = pickWrites(12, 2, 5);
|
||||
assert.equal(outputWindow(12, stored.start, stored.end, stored.max).keepEnd, 5);
|
||||
});
|
||||
|
||||
test("typing in a box: Start keeps the Duration, the other two keep the start", () => {
|
||||
const window = outputWindow(12, 2, 0, 3); // 2 s to 5 s
|
||||
assert.deepEqual(typedPick("start", 4, window, 12), { start: 4, end: 7 });
|
||||
assert.deepEqual(typedPick("start", 11, window, 12), { start: 11, end: 12 }, "less of it is left near the end");
|
||||
assert.deepEqual(typedPick("duration", 6, window, 12), { start: 2, end: 8 });
|
||||
assert.deepEqual(typedPick("end", 9, window, 12), { start: 2, end: 9 });
|
||||
assert.deepEqual(typedPick("end", 1, window, 12), { start: 2, end: 2.1 }, "an end before the start is held just after it");
|
||||
// 0 or an empty Duration, and an empty Ends at, run to the end of the file.
|
||||
assert.deepEqual(typedPick("duration", 0, window, 12), { start: 2, end: 12 });
|
||||
assert.deepEqual(typedPick("duration", null, window, 12), { start: 2, end: 12 });
|
||||
assert.deepEqual(typedPick("end", null, window, 12), { start: 2, end: 12 });
|
||||
assert.deepEqual(typedPick("start", null, window, 12), { start: 0, end: 3 }, "an empty Start is the beginning");
|
||||
});
|
||||
|
||||
test("a press grabs the nearest handle, the middle, or jumps", () => {
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
CROP_GRID, CROP_MODES, SIZE_MODES, changeText, cropSideAt, keptPart, placeText, planLoadSize, shapeText, sizeText, stepFile, thumbSizes,
|
||||
} from "../js/shared/load_size.mjs";
|
||||
|
||||
const table = JSON.parse(readFileSync(new URL("./fixtures/load_size_cases.json", import.meta.url), "utf8"));
|
||||
|
||||
test("the size the node shows is the size the run gives, case by case", () => {
|
||||
assert.ok(table.rows.length > 200);
|
||||
const seen = new Set();
|
||||
for (const row of table.rows) {
|
||||
const [sourceWidth, sourceHeight, size, megapixels, longest_side, scale, width, height, multiple, enlarge, crop_from, ratio, ...wanted] = row;
|
||||
seen.add(size);
|
||||
const plan = planLoadSize(sourceWidth, sourceHeight, { size, megapixels, longest_side, scale, width, height, multiple, enlarge, crop_from, ratio });
|
||||
assert.deepEqual(
|
||||
[plan.resizeWidth, plan.resizeHeight, plan.cropX, plan.cropY, plan.width, plan.height],
|
||||
wanted,
|
||||
JSON.stringify(row.slice(0, 12)),
|
||||
);
|
||||
}
|
||||
assert.deepEqual([...seen].sort(), [...SIZE_MODES].sort(), "every size choice is in the table");
|
||||
});
|
||||
|
||||
test("off gives the picture back whatever the other settings say", () => {
|
||||
const plan = planLoadSize(913, 1631, { size: "off", multiple: 64, megapixels: 4, enlarge: false });
|
||||
assert.deepEqual([plan.width, plan.height, plan.cropX, plan.cropY], [913, 1631, 0, 0]);
|
||||
});
|
||||
|
||||
test("longest side lands on the number asked for, and round to moves it to a multiple", () => {
|
||||
assert.deepEqual(planLoadSize(912, 1632, { size: "longest side", longest_side: 2048, multiple: 1 }).height, 2048);
|
||||
const rounded = planLoadSize(912, 1632, { size: "longest side", longest_side: 2000, multiple: 16 });
|
||||
assert.equal(rounded.height, 2000);
|
||||
assert.equal(rounded.width % 16, 0);
|
||||
});
|
||||
|
||||
test("with enlarge off a small picture keeps its size, and crop to fill only cuts", () => {
|
||||
const kept = planLoadSize(640, 480, { size: "megapixels", megapixels: 4, multiple: 1, enlarge: false });
|
||||
assert.deepEqual([kept.width, kept.height], [640, 480]);
|
||||
const cut = planLoadSize(800, 600, { size: "crop to fill", width: 1024, height: 1024, multiple: 1, enlarge: false });
|
||||
assert.deepEqual([cut.width, cut.height, cut.resizeWidth, cut.resizeHeight, cut.cropX, cut.cropY], [600, 600, 800, 600, 100, 0]);
|
||||
});
|
||||
|
||||
test("fit inside never leaves its box, rounding included", () => {
|
||||
const plan = planLoadSize(1920, 1080, { size: "fit inside", width: 1000, height: 1000, multiple: 64 });
|
||||
assert.ok(plan.width <= 1000 && plan.height <= 1000);
|
||||
assert.equal(plan.width % 64, 0);
|
||||
});
|
||||
|
||||
test("a picture with no size yet, or a choice the node does not know, has no plan", () => {
|
||||
assert.equal(planLoadSize(0, 0, { size: "scale" }), null);
|
||||
assert.equal(planLoadSize(100, 100, { size: "" }), null);
|
||||
assert.equal(planLoadSize(100, 100, { size: "stretch" }), null);
|
||||
});
|
||||
|
||||
test("the size line shows one size when nothing changes and both when it does", () => {
|
||||
assert.equal(sizeText(912, 1632, planLoadSize(912, 1632, { size: "off" })), "912 × 1632");
|
||||
assert.equal(
|
||||
sizeText(912, 1632, planLoadSize(912, 1632, { size: "longest side", longest_side: 2048, multiple: 8 })),
|
||||
"912 × 1632 → 1144 × 2048",
|
||||
);
|
||||
assert.equal(sizeText(0, 0, null), "");
|
||||
assert.equal(sizeText(912, 1632, null), "912 × 1632");
|
||||
});
|
||||
|
||||
test("a crop keeps the side that is asked for", () => {
|
||||
const cut = (crop_from, size = "crop to fill") => planLoadSize(200, 100, { size, width: 100, height: 100, multiple: 1, crop_from, ratio: "1:1" });
|
||||
for (const size of CROP_MODES) {
|
||||
assert.equal(cut("left", size).cropX, 0, size);
|
||||
assert.equal(cut("center", size).cropX, 50, size);
|
||||
assert.equal(cut("top right", size).cropX, 100, size);
|
||||
}
|
||||
assert.equal(cut("sideways").cropX, 50, "a side the node does not know is the middle");
|
||||
const tall = planLoadSize(100, 300, { size: "crop", width: 100, height: 100, multiple: 1, crop_from: "bottom" });
|
||||
assert.deepEqual([tall.resizeWidth, tall.resizeHeight, tall.cropY, tall.height], [100, 300, 200, 100], "crop does not resize");
|
||||
assert.equal(CROP_GRID.length, 9);
|
||||
assert.equal(new Set(CROP_GRID).size, 9);
|
||||
});
|
||||
|
||||
test("a click on the small picture picks the part under it", () => {
|
||||
assert.equal(cropSideAt(0.1, 0.1), "top left");
|
||||
assert.equal(cropSideAt(0.5, 0.05), "top");
|
||||
assert.equal(cropSideAt(0.5, 0.5), "center");
|
||||
assert.equal(cropSideAt(0.95, 0.5), "right");
|
||||
assert.equal(cropSideAt(0.99, 0.99), "bottom right");
|
||||
});
|
||||
|
||||
test("the preview lights the part that is kept and words what changes", () => {
|
||||
const top = planLoadSize(1336, 1784, { size: "crop to fill", width: 1024, height: 1024, multiple: 1, crop_from: "top" });
|
||||
const part = keptPart(top);
|
||||
assert.deepEqual([part.x, part.y, part.width], [0, 0, 1]);
|
||||
assert.ok(Math.abs(part.height - 1024 / 1368) < 1e-9);
|
||||
assert.equal(changeText(1336, 1784, top), "77% size · cuts 449 px of height");
|
||||
const piece = planLoadSize(1336, 1784, { size: "crop", width: 768, height: 768, multiple: 1 });
|
||||
assert.equal(changeText(1336, 1784, piece), "cuts 568 × 1016 px");
|
||||
assert.equal(changeText(1336, 1784, planLoadSize(1336, 1784, { size: "off" })), "");
|
||||
assert.equal(changeText(1336, 1784, planLoadSize(1336, 1784, { size: "scale", scale: 0.5, multiple: 1 })), "50% size");
|
||||
assert.deepEqual(keptPart(null), { x: 0, y: 0, width: 1, height: 1 });
|
||||
});
|
||||
|
||||
test("the two small pictures share one scale and stay in their box", () => {
|
||||
const half = planLoadSize(1336, 1784, { size: "scale", scale: 0.5, multiple: 1 });
|
||||
const sizes = thumbSizes(1336, 1784, half, 76, 68);
|
||||
assert.deepEqual(sizes.input, [51, 68]);
|
||||
assert.deepEqual(sizes.output, [25, 34], "half the size is drawn half as large");
|
||||
const grown = thumbSizes(100, 100, planLoadSize(100, 100, { size: "scale", scale: 8, multiple: 1 }), 76, 68);
|
||||
assert.deepEqual(grown.output, [68, 68]);
|
||||
assert.deepEqual(grown.input, [10, 10], "never too small to see");
|
||||
const wide = thumbSizes(4000, 500, null, 76, 68);
|
||||
assert.ok(wide.input[0] <= 76 && wide.input[1] >= 10);
|
||||
});
|
||||
|
||||
test("a shape is named the way people say it", () => {
|
||||
assert.equal(shapeText(1024, 1024), "1:1");
|
||||
assert.equal(shapeText(1336, 1784), "3:4");
|
||||
assert.equal(shapeText(1336, 752), "16:9", "rounded to a multiple of 8, still 16:9");
|
||||
assert.equal(shapeText(1080, 1920), "9:16");
|
||||
assert.equal(shapeText(1000, 777), "~1.29:1");
|
||||
assert.equal(shapeText(777, 1000), "~1:1.29");
|
||||
assert.equal(shapeText(0, 10), "");
|
||||
});
|
||||
|
||||
test("the arrows go round the list, and a file that is not listed steps onto it", () => {
|
||||
const files = ["a.png", "b.png", "sub/c.png"];
|
||||
assert.equal(stepFile(files, "a.png", 1), "b.png");
|
||||
assert.equal(stepFile(files, "sub/c.png", 1), "a.png");
|
||||
assert.equal(stepFile(files, "a.png", -1), "sub/c.png");
|
||||
assert.equal(stepFile(files, "gone.png", 1), "a.png");
|
||||
assert.equal(stepFile(files, "gone.png", -1), "sub/c.png");
|
||||
assert.equal(stepFile(["only.png"], "only.png", 1), null);
|
||||
assert.equal(stepFile([""], "", 1), null, "an empty input folder lists one blank");
|
||||
assert.equal(stepFile(undefined, "a.png", 1), null);
|
||||
});
|
||||
|
||||
test("the place in the list counts from one", () => {
|
||||
const files = ["a.png", "b.png", "sub/c.png"];
|
||||
assert.equal(placeText(files, "b.png"), "2 / 3");
|
||||
assert.equal(placeText(files, "gone.png"), "– / 3");
|
||||
assert.equal(placeText([""], ""), "");
|
||||
});
|
||||
|
||||
test("Load Image is one of the loaders checked for a picked file before a run", async () => {
|
||||
const { SOURCE_LOADERS } = await import("../js/shared/run_check.mjs");
|
||||
assert.equal(typeof SOURCE_LOADERS.AUSBOSS_NODES_LoadImage, "function");
|
||||
assert.ok(SOURCE_LOADERS.AUSBOSS_NODES_LoadImage({ image: "" }));
|
||||
assert.equal(SOURCE_LOADERS.AUSBOSS_NODES_LoadImage({ image: "pic.png" }), null);
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
FILE_WIDGET_PREFIX,
|
||||
coreLoraList,
|
||||
fileChoices,
|
||||
isFileWidget,
|
||||
rowsNeedingFiles,
|
||||
syncFileWidgets,
|
||||
} from "../js/shared/lora_file_widgets.mjs";
|
||||
|
||||
// A node the way LiteGraph hands it over: addWidget appends and returns.
|
||||
function fakeNode() {
|
||||
return {
|
||||
widgets: [{ name: "loras", type: "customtext", value: "[]" }],
|
||||
addWidget(type, name, value, callback, options) {
|
||||
const widget = { type, name, value, callback, options };
|
||||
this.widgets.push(widget);
|
||||
return widget;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const row = (id, name, extra = {}) => ({ id, name, strength: 1, strength_clip: 1, enabled: true, ...extra });
|
||||
const choices = (widget) => widget.options.values(widget);
|
||||
|
||||
test("only rows the server would load need a file", () => {
|
||||
const rows = [
|
||||
row("a", "pika.safetensors"),
|
||||
row("b", ""),
|
||||
row("c", "off.safetensors", { enabled: false }),
|
||||
row("d", "group_off.safetensors", { group: "g", group_off: true }),
|
||||
row("e", "zero.safetensors", { strength: 0, strength_clip: 0 }),
|
||||
row("f", "clip_only.safetensors", { strength: 0, strength_clip: 0.5 }),
|
||||
];
|
||||
assert.deepEqual(rowsNeedingFiles(rows).map((item) => item.id), ["a", "f"]);
|
||||
});
|
||||
|
||||
test("a file the loader would find anyway is not missing", () => {
|
||||
const installed = ["minimax-h3/pika.safetensors", "style.safetensors"];
|
||||
assert.ok(fileChoices("minimax-h3/pika.safetensors", installed).includes("minimax-h3/pika.safetensors"));
|
||||
// saved as a bare name, installed in a subfolder: the loader finds it
|
||||
assert.ok(fileChoices("pika.safetensors", installed).includes("pika.safetensors"));
|
||||
assert.ok(fileChoices("STYLE.safetensors", installed).includes("STYLE.safetensors"));
|
||||
assert.ok(!fileChoices("gone.safetensors", installed).includes("gone.safetensors"));
|
||||
// no list to ask: never a false alarm
|
||||
assert.deepEqual(fileChoices("gone.safetensors", null), ["gone.safetensors"]);
|
||||
});
|
||||
|
||||
test("the install's list comes from ComfyUI's own LoRA loader", () => {
|
||||
assert.deepEqual(coreLoraList({ input: { required: { lora_name: [["a.safetensors"], { tooltip: "x" }] } } }), ["a.safetensors"]);
|
||||
assert.deepEqual(coreLoraList({ input: { required: { lora_name: ["COMBO", { options: ["b.safetensors"] }] } } }), ["b.safetensors"]);
|
||||
assert.equal(coreLoraList(undefined), null);
|
||||
assert.equal(coreLoraList({ input: { required: {} } }), null);
|
||||
});
|
||||
|
||||
test("one hidden list per needed row, out of the save and the prompt", () => {
|
||||
const node = fakeNode();
|
||||
const hidden = [];
|
||||
const changed = syncFileWidgets(node, [row("a", "pika.safetensors"), row("b", "")], {
|
||||
installed: () => [],
|
||||
hide: (widget) => hidden.push(widget),
|
||||
});
|
||||
assert.equal(changed, true);
|
||||
const files = node.widgets.filter(isFileWidget);
|
||||
assert.equal(files.length, 1);
|
||||
const [widget] = files;
|
||||
assert.equal(widget.type, "combo");
|
||||
assert.equal(widget.name, `${FILE_WIDGET_PREFIX}1`);
|
||||
assert.equal(widget.value, "pika.safetensors");
|
||||
assert.equal(widget.serialize, false);
|
||||
assert.equal(widget.options.serialize, false);
|
||||
assert.deepEqual(hidden, [widget]);
|
||||
// ComfyUI's check: a value that is not among the choices is a missing model
|
||||
assert.ok(!choices(widget).includes(widget.value));
|
||||
// the loras text keeps its place in front
|
||||
assert.equal(node.widgets[0].name, "loras");
|
||||
});
|
||||
|
||||
test("the lists follow the rows: renamed, added, removed", () => {
|
||||
const node = fakeNode();
|
||||
const options = { installed: () => ["here.safetensors"], hide: () => {} };
|
||||
syncFileWidgets(node, [row("a", "one.safetensors"), row("b", "two.safetensors")], options);
|
||||
const first = node.widgets.filter(isFileWidget)[0];
|
||||
assert.equal(syncFileWidgets(node, [row("a", "here.safetensors"), row("b", "two.safetensors")], options), false);
|
||||
assert.equal(node.widgets.filter(isFileWidget)[0], first, "the same widget is reused");
|
||||
assert.equal(first.value, "here.safetensors");
|
||||
assert.ok(choices(first).includes("here.safetensors"));
|
||||
assert.equal(syncFileWidgets(node, [row("b", "two.safetensors")], options), true);
|
||||
assert.deepEqual(node.widgets.filter(isFileWidget).map((widget) => [widget.value, widget.ausbossRowId]), [["two.safetensors", "b"]]);
|
||||
syncFileWidgets(node, [], options);
|
||||
assert.equal(node.widgets.filter(isFileWidget).length, 0);
|
||||
assert.deepEqual(node.widgets.map((widget) => widget.name), ["loras"]);
|
||||
});
|
||||
|
||||
test("a replacement put in the list goes to its row", () => {
|
||||
const node = fakeNode();
|
||||
const picks = [];
|
||||
syncFileWidgets(node, [row("a", "one.safetensors"), row("b", "gone.safetensors")], {
|
||||
installed: () => ["new.safetensors"],
|
||||
hide: () => {},
|
||||
onPick: (rowId, name) => picks.push([rowId, name]),
|
||||
});
|
||||
const widget = node.widgets.filter(isFileWidget)[1];
|
||||
// what ComfyUI's Issues panel does: set the value, then call back
|
||||
widget.value = "new.safetensors";
|
||||
widget.callback("new.safetensors");
|
||||
// a call back with the row's own file is no change
|
||||
node.widgets.filter(isFileWidget)[0].callback("one.safetensors");
|
||||
assert.deepEqual(picks, [["b", "new.safetensors"]]);
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { outlineOf } from "../js/shared/outline.mjs";
|
||||
|
||||
// A frameless tile draws a card inside a transparent node. Snap into line and
|
||||
// Line up must use the card people see, not the node's wider bounds.
|
||||
const canvas = {
|
||||
canvas: { getBoundingClientRect: () => ({ left: 10, top: 20 }) },
|
||||
ds: { scale: 2, offset: [5, 5] },
|
||||
};
|
||||
const card = (rect) => ({ isConnected: true, getBoundingClientRect: () => rect });
|
||||
|
||||
test("a tile's outline is its visible card", () => {
|
||||
const node = {
|
||||
boundingRect: [100, 100, 380, 80],
|
||||
ausbossOutlineElement: card({ left: 10 + 2 * (114 + 5), top: 20 + 2 * (114 + 5), width: 704, height: 100 }),
|
||||
};
|
||||
assert.deepEqual(outlineOf(node, canvas), { x: 114, y: 114, w: 352, h: 50 });
|
||||
});
|
||||
|
||||
test("a collapsed or unshown tile falls back to the node's bounds", () => {
|
||||
const bounds = { x: 100, y: 100, w: 380, h: 80 };
|
||||
const shown = card({ left: 0, top: 0, width: 50, height: 50 });
|
||||
assert.deepEqual(outlineOf({ boundingRect: [100, 100, 380, 80], flags: { collapsed: true }, ausbossOutlineElement: shown }, canvas), bounds);
|
||||
const hidden = card({ left: 0, top: 0, width: 0, height: 0 });
|
||||
assert.deepEqual(outlineOf({ boundingRect: [100, 100, 380, 80], ausbossOutlineElement: hidden }, canvas), bounds);
|
||||
assert.deepEqual(outlineOf({ boundingRect: [100, 100, 380, 80] }, canvas), bounds);
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { keepIndex, stepIndex, stepperLabel } from "../js/shared/picture_steps.mjs";
|
||||
import { keepIndex, keepWords, stepIndex, stepperLabel } from "../js/shared/picture_steps.mjs";
|
||||
|
||||
test("a new run keeps the picture that was showing, if it still has one", () => {
|
||||
assert.equal(keepIndex(1, 3), 1);
|
||||
@@ -74,3 +74,21 @@ test("held pictures map to their run and their place in it", async () => {
|
||||
assert.deepEqual(heldPlaces({ images: [name(a, 0), name(b, 0)], ausboss_held: [a] }), []);
|
||||
assert.deepEqual(heldPlaces(undefined), []);
|
||||
});
|
||||
|
||||
test("the row over held pictures says what is saved and what a click does", () => {
|
||||
// One picture: not saved, then saved under its name.
|
||||
assert.deepEqual(keepWords({ held: 1 }), { note: "Not saved yet", button: "Save picture", quiet: false });
|
||||
assert.deepEqual(keepWords({ held: 1, saving: true }), { note: "Not saved yet", button: "Saving...", quiet: false });
|
||||
assert.deepEqual(
|
||||
keepWords({ held: 1, kept: 1, done: true, name: "sheet_00001.png" }),
|
||||
{ note: "Saved as sheet_00001.png", button: "Saved", quiet: true },
|
||||
);
|
||||
assert.equal(keepWords({ held: 1, kept: 1, done: true }).note, "Saved");
|
||||
// Several, all showing: every one, then only the ones left.
|
||||
assert.deepEqual(keepWords({ held: 4 }), { note: "Not saved yet", button: "Save all 4", quiet: false });
|
||||
assert.deepEqual(keepWords({ held: 4, kept: 1 }), { note: "1 of 4 saved", button: "Save the rest", quiet: false });
|
||||
assert.deepEqual(keepWords({ held: 4, kept: 4, done: true }), { note: "All 4 saved", button: "Saved", quiet: true });
|
||||
// The arrows on one picture: that one alone.
|
||||
assert.deepEqual(keepWords({ held: 4, kept: 1, all: false }), { note: "1 of 4 saved", button: "Save this one", quiet: false });
|
||||
assert.deepEqual(keepWords({ held: 4, kept: 1, all: false, done: true }), { note: "1 of 4 saved", button: "Saved", quiet: true });
|
||||
});
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
"""A loader's change check never opens a value it refused.
|
||||
|
||||
ComfyUI calls a node's IS_CHANGED with the prompt's widget values before it
|
||||
runs anything, and /prompt needs no login. The picture and video loaders
|
||||
first hand the value to their resolver, which takes only a file named below
|
||||
ComfyUI's input, output or temp folder. When the resolver refuses it, the
|
||||
value is hashed as text and nothing else: on Windows, merely looking up a
|
||||
network path ("//host/share/x.png") contacts that host and hands it the
|
||||
server's login.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
|
||||
del sys.modules["nodes"]
|
||||
|
||||
from nodes._transform_engine import stable_file_fingerprint # noqa: E402
|
||||
from nodes.node_image_crop_rotate_pad import AusBossImageCropRotatePad # noqa: E402
|
||||
from nodes.node_load_image import AusBossLoadImage # noqa: E402
|
||||
from nodes.node_load_image_pad import AusBossLoadImagePad # noqa: E402
|
||||
from nodes.node_video_crop_rotate_pad import AusBossVideoCropRotatePad # noqa: E402
|
||||
from nodes.node_video_crop_rotate_pad_clip import AusBossVideoCropRotatePadClip # noqa: E402
|
||||
|
||||
REFUSED = [
|
||||
"//evil-host/share/photo.png",
|
||||
"\\\\evil-host\\share\\photo.png",
|
||||
"/evil-host/etc/photo.png",
|
||||
"../../evil-host/photo.png",
|
||||
]
|
||||
|
||||
|
||||
class DiskWatch:
|
||||
"""Records every stat and resolve of a path that names the evil host."""
|
||||
|
||||
def __init__(self):
|
||||
self.touched = []
|
||||
|
||||
def __enter__(self):
|
||||
real_stat, real_resolve = os.stat, Path.resolve
|
||||
watch = self
|
||||
|
||||
def stat(path, *args, **kwargs):
|
||||
if "evil-host" in str(path):
|
||||
watch.touched.append(("stat", str(path)))
|
||||
return real_stat(path, *args, **kwargs)
|
||||
|
||||
def resolve(self, *args, **kwargs):
|
||||
if "evil-host" in str(self):
|
||||
watch.touched.append(("resolve", str(self)))
|
||||
return real_resolve(self, *args, **kwargs)
|
||||
|
||||
self._patches = [patch("os.stat", stat), patch.object(Path, "resolve", resolve)]
|
||||
for item in self._patches:
|
||||
item.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc):
|
||||
for item in reversed(self._patches):
|
||||
item.stop()
|
||||
|
||||
|
||||
class ChangeCheckTests(unittest.TestCase):
|
||||
def assert_off_disk(self, call):
|
||||
for value in REFUSED:
|
||||
with self.subTest(value=value), DiskWatch() as watch:
|
||||
first = call(value)
|
||||
self.assertEqual(watch.touched, [])
|
||||
# The text still counts: another refused value is another key.
|
||||
self.assertNotEqual(first, call(value + "x"))
|
||||
|
||||
def test_picture_loaders(self):
|
||||
for node in (AusBossLoadImage, AusBossLoadImagePad, AusBossImageCropRotatePad):
|
||||
with self.subTest(node=node.__name__):
|
||||
self.assert_off_disk(lambda value, node=node: node.IS_CHANGED(image=value))
|
||||
|
||||
def test_video_crop_nodes(self):
|
||||
for node in (AusBossVideoCropRotatePad, AusBossVideoCropRotatePadClip):
|
||||
for mode in ("input folder", "local path"):
|
||||
with self.subTest(node=node.__name__, mode=mode):
|
||||
self.assert_off_disk(
|
||||
lambda value, node=node, mode=mode: node.IS_CHANGED(
|
||||
video=value if mode == "input folder" else "",
|
||||
source_mode=mode,
|
||||
local_path=value if mode == "local path" else "",
|
||||
seek_mode="frame index",
|
||||
frame_index=0,
|
||||
frame_time=0.0,
|
||||
**({"start_seconds": 0.0, "end_seconds": 0.0} if node is AusBossVideoCropRotatePadClip else {}),
|
||||
)
|
||||
)
|
||||
|
||||
def test_the_fingerprint_opens_only_a_resolved_path(self):
|
||||
with DiskWatch() as watch:
|
||||
stable_file_fingerprint("//evil-host/share/photo.png", {})
|
||||
stable_file_fingerprint(None, {})
|
||||
self.assertEqual(watch.touched, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,118 @@
|
||||
"""Edit Lock Restore's tint fix: the model's pink tint goes, an intended recolor stays."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
|
||||
del sys.modules["nodes"]
|
||||
|
||||
from nodes._edit_lock_helpers import EditLock # noqa: E402
|
||||
from nodes._edit_tint_helpers import ( # noqa: E402
|
||||
lab_to_rgb,
|
||||
looks_like_tint,
|
||||
measure_tint,
|
||||
remove_tint,
|
||||
rgb_to_lab,
|
||||
take_out_tint,
|
||||
)
|
||||
from nodes.node_edit_lock import AusBossEditLockRestore # noqa: E402
|
||||
|
||||
TINT = [2.0, 5.0, -3.0] # what MiniMax H3 Image adds: lighter, pinker, bluer
|
||||
|
||||
|
||||
def picture(seed: int = 0, size: int = 384) -> torch.Tensor:
|
||||
"""A textured photo stand-in, [1, H, W, 3], mid tones so a shift never clips."""
|
||||
gen = torch.Generator().manual_seed(seed)
|
||||
coarse = torch.rand(1, 3, size // 16, size // 16, generator=gen)
|
||||
fine = torch.rand(1, 3, size // 4, size // 4, generator=gen)
|
||||
img = 0.6 * F.interpolate(coarse, size=(size, size), mode="bicubic", align_corners=False)
|
||||
img = img + 0.4 * F.interpolate(fine, size=(size, size), mode="bilinear", align_corners=False)
|
||||
return (0.2 + 0.6 * img).clamp(0.0, 1.0).movedim(1, -1)
|
||||
|
||||
|
||||
def shifted(image: torch.Tensor, shift) -> torch.Tensor:
|
||||
return lab_to_rgb(rgb_to_lab(image) + torch.tensor(shift, dtype=torch.float64)).float()
|
||||
|
||||
|
||||
def edited(source: torch.Tensor, shift) -> torch.Tensor:
|
||||
"""A local edit (a new patch) on top of an even shift of the whole picture."""
|
||||
out = shifted(source, shift)
|
||||
out[:, 120:260, 140:280] = torch.tensor([0.85, 0.85, 0.88])
|
||||
return out
|
||||
|
||||
|
||||
class TintTests(unittest.TestCase):
|
||||
def test_lab_round_trip(self):
|
||||
img = picture(1)
|
||||
self.assertLess(float((lab_to_rgb(rgb_to_lab(img)).float() - img).abs().max()), 1e-4)
|
||||
|
||||
def test_reads_the_tint_on_the_untouched_part(self):
|
||||
source = picture(2)
|
||||
shift, share = measure_tint(edited(source, TINT)[0], source[0])
|
||||
self.assertIsNotNone(shift)
|
||||
for got, want in zip(shift, TINT):
|
||||
self.assertAlmostEqual(got, want, delta=0.4)
|
||||
self.assertGreater(share, 0.5)
|
||||
|
||||
def test_takes_the_tint_out(self):
|
||||
source = picture(3)
|
||||
out, taken = take_out_tint(edited(source, TINT), source)
|
||||
self.assertIsNotNone(taken)
|
||||
outside = (slice(0, 100), slice(0, 384))
|
||||
self.assertLess(float((out[0][outside] - source[0][outside]).abs().mean()), 0.004)
|
||||
|
||||
def test_leaves_an_intended_recolor(self):
|
||||
source = picture(4)
|
||||
golden = [6.0, 20.0, 30.0] # golden hour: warmer and much yellower
|
||||
image = edited(source, golden)
|
||||
out, taken = take_out_tint(image, source)
|
||||
self.assertIsNone(taken)
|
||||
self.assertTrue(torch.equal(out, image))
|
||||
|
||||
def test_the_tint_rule(self):
|
||||
self.assertTrue(looks_like_tint([2.6, 6.3, -3.4], 0.49)) # silver hair
|
||||
self.assertTrue(looks_like_tint([1.8, 3.5, -1.8], 0.62)) # rain
|
||||
self.assertFalse(looks_like_tint([-2.0, 29.4, 2.9], 0.05)) # red light
|
||||
self.assertFalse(looks_like_tint([19.5, 2.5, -5.5], 0.07)) # anime restyle
|
||||
self.assertFalse(looks_like_tint([7.8, 23.9, 31.3], 1.0)) # golden hour
|
||||
self.assertFalse(looks_like_tint([0.0, 0.1, -0.1], 0.9)) # already clean
|
||||
self.assertFalse(looks_like_tint(None, 0.0))
|
||||
|
||||
def test_noise_is_left_alone(self):
|
||||
gen = torch.Generator().manual_seed(5)
|
||||
image = torch.rand(1, 64, 64, 3, generator=gen)
|
||||
out, taken = take_out_tint(image, torch.rand(1, 64, 64, 3, generator=gen))
|
||||
self.assertIsNone(taken)
|
||||
self.assertTrue(torch.equal(out, image))
|
||||
|
||||
def test_restore_node_takes_it_out_when_the_lock_stepped_aside(self):
|
||||
source = picture(6)
|
||||
lock = EditLock()
|
||||
lock.status = "whole picture"
|
||||
lock.source = source
|
||||
image = edited(source, TINT)
|
||||
out, mask, report = AusBossEditLockRestore().restore(image, lock, 16)
|
||||
self.assertLess(float((out[0, :100] - source[0, :100]).abs().mean()), 0.004)
|
||||
self.assertIn("tint", report)
|
||||
self.assertTrue(torch.all(mask == 1.0))
|
||||
# switched off, it passes through as before
|
||||
out, _, report = AusBossEditLockRestore().restore(image, lock, 16, remove_tint=False)
|
||||
self.assertTrue(torch.equal(out, image))
|
||||
self.assertNotIn("tint", report)
|
||||
|
||||
def test_remove_tint_keeps_alpha(self):
|
||||
image = torch.cat([picture(7), torch.ones(1, 384, 384, 1)], -1)
|
||||
out = remove_tint(image, TINT)
|
||||
self.assertTrue(torch.equal(out[..., 3], image[..., 3]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -7,6 +7,7 @@ import re
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
@@ -244,6 +245,45 @@ class VersionedServingTests(unittest.TestCase):
|
||||
for path, (_status, body, _headers) in self.fetch(paths).items():
|
||||
self.assertNotIn("?v=tok", body, path)
|
||||
|
||||
def test_an_address_never_reaches_the_disk(self):
|
||||
# The request is unauthenticated: its address is only looked up in
|
||||
# the list of scripts made at startup, never joined to a folder and
|
||||
# resolved. On Windows, resolving "//host/share" contacts that host.
|
||||
web = self.web
|
||||
touched = []
|
||||
|
||||
async def handled(request):
|
||||
return web.Response(text="from the handler", content_type="text/javascript")
|
||||
|
||||
async def run():
|
||||
middleware = make_revalidate_middleware("ausboss-nodes", self.js, "tok")
|
||||
real_resolve, real_stat = Path.resolve, os.stat
|
||||
|
||||
def resolve(path, *args, **kwargs):
|
||||
if "evil-host" in str(path):
|
||||
touched.append(str(path))
|
||||
return real_resolve(path, *args, **kwargs)
|
||||
|
||||
def stat(path, *args, **kwargs):
|
||||
if "evil-host" in str(path):
|
||||
touched.append(str(path))
|
||||
return real_stat(path, *args, **kwargs)
|
||||
|
||||
with patch.object(Path, "resolve", resolve), patch("os.stat", stat):
|
||||
for path in [
|
||||
"/extensions/ausboss-nodes//evil-host/share/x.mjs",
|
||||
"/extensions/ausboss-nodes/%2F%2Fevil-host/share/x.mjs",
|
||||
"/extensions/ausboss-nodes/%5C%5Cevil-host%5Cshare%5Cx.mjs",
|
||||
"/extensions/ausboss-nodes/../../evil-host/x.mjs",
|
||||
"/extensions/ausboss-nodes/%2e%2e/%2e%2e/evil-host/x.js",
|
||||
"/extensions/ausboss-nodes/C:/evil-host/x.mjs",
|
||||
]:
|
||||
response = await middleware(self.make_request("GET", path), handled)
|
||||
self.assertEqual(response.text, "from the handler", path)
|
||||
|
||||
asyncio.run(run())
|
||||
self.assertEqual(touched, [])
|
||||
|
||||
def test_without_a_tag_the_files_are_served_as_before(self):
|
||||
path = "/extensions/ausboss-nodes/shared/b.mjs"
|
||||
status, body, headers = self.fetch([path], token=None)[path]
|
||||
|
||||
@@ -149,6 +149,11 @@ class ListingTests(FolderCase):
|
||||
self.assertEqual(place_inside(str(self.root) + "/", roots), ("input", ""))
|
||||
self.assertEqual(place_inside(str(roots["output"] / "set"), roots), ("output", "set"))
|
||||
self.assertEqual(place_inside(f'"{self.root / "people"}"', roots), ("input", "people"), "quotes from a copied path")
|
||||
# A "~" path is never expanded into a real one, and no node code does that.
|
||||
self.assertIsNone(place_inside("~/ComfyUI/input/people", roots))
|
||||
nodes_dir = Path(__file__).resolve().parents[1] / "nodes"
|
||||
for source in nodes_dir.glob("*.py"):
|
||||
self.assertNotIn("expanduser", source.read_text(encoding="utf-8"), source.name)
|
||||
|
||||
def test_a_whole_path_anywhere_else_is_not_a_place(self):
|
||||
roots = {"input": self.root, "output": Path(self.temp.name) / "output"}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
|
||||
del sys.modules["nodes"]
|
||||
|
||||
from nodes._image_hold_helpers import GONE, HELD_FOLDER, hold_pictures, keep_pictures
|
||||
from nodes import _image_hold_helpers # noqa: E402
|
||||
from nodes._image_hold_helpers import GONE, HELD_FOLDER, hold_pictures, keep_pictures # noqa: E402
|
||||
|
||||
NOW = datetime(2026, 11, 10, 9, 30, 0)
|
||||
|
||||
@@ -99,12 +102,70 @@ class HoldTests(unittest.TestCase):
|
||||
|
||||
def test_a_folder_outside_the_output_folder_is_refused_at_the_click_too(self):
|
||||
token, _ = self.hold(count=1)
|
||||
manifest = self.temp / HELD_FOLDER / f"{token}.json"
|
||||
manifest.write_text(manifest.read_text().replace('"output_dir": ""', '"output_dir": "../elsewhere"'))
|
||||
_image_hold_helpers._RUNS[token]["output_dir"] = "../elsewhere"
|
||||
with self.assertRaises(ValueError):
|
||||
self.keep(token)
|
||||
self.assertFalse((Path(self.box.name) / "elsewhere").exists())
|
||||
|
||||
def test_a_run_planted_in_the_temp_folder_is_not_a_run(self):
|
||||
# ComfyUI's temp folder takes uploads, so a file there can be
|
||||
# anyone's. A planted list naming a server file must copy nothing.
|
||||
secret = Path(self.box.name) / "secret.txt"
|
||||
secret.write_text("server secret")
|
||||
held = self.temp / HELD_FOLDER
|
||||
held.mkdir(exist_ok=True)
|
||||
token = "a" * 16
|
||||
planted = dict(
|
||||
settings(extension="png/../../../secret.txt", output_dir="x/y"), count=1, kept={},
|
||||
)
|
||||
(held / f"{token}.json").write_text(json.dumps(planted))
|
||||
(held / f"{token}_000.png").mkdir() # an upload's subfolder makes the ".." walk work
|
||||
with self.assertRaises(LookupError):
|
||||
self.keep(token)
|
||||
self.assertEqual(list(self.output.rglob("*")), [])
|
||||
|
||||
def test_a_held_picture_is_named_only_from_the_token_number_and_format(self):
|
||||
token, previews = self.hold(count=1)
|
||||
for extension in ["png/../../x", "txt", "", "PNG"]:
|
||||
with self.assertRaises(ValueError):
|
||||
_image_hold_helpers._held_name(token, 0, extension)
|
||||
_image_hold_helpers._RUNS[token]["extension"] = "png/../../../secret.txt"
|
||||
with self.assertRaises(ValueError):
|
||||
self.keep(token)
|
||||
self.assertEqual(list(self.output.iterdir()), [])
|
||||
|
||||
def test_a_picture_swapped_for_a_link_is_not_copied(self):
|
||||
token, previews = self.hold(count=1)
|
||||
secret = Path(self.box.name) / "secret.txt"
|
||||
secret.write_text("server secret")
|
||||
picture = self.temp / HELD_FOLDER / previews[0]["filename"]
|
||||
picture.unlink()
|
||||
try:
|
||||
picture.symlink_to(secret)
|
||||
except (OSError, NotImplementedError):
|
||||
self.skipTest("no symlinks here")
|
||||
with self.assertRaises(LookupError):
|
||||
self.keep(token)
|
||||
self.assertEqual(list(self.output.iterdir()), [])
|
||||
|
||||
def test_counts_are_capped(self):
|
||||
with patch.object(_image_hold_helpers, "MAX_HELD_PICTURES", 4):
|
||||
with self.assertRaises(ValueError):
|
||||
self.hold(count=5)
|
||||
token, _ = self.hold(count=2)
|
||||
with self.assertRaises(ValueError):
|
||||
self.keep(token, [0] * 5)
|
||||
self.assertEqual(list(self.output.iterdir()), [])
|
||||
|
||||
def test_old_runs_are_forgotten_first(self):
|
||||
with patch.object(_image_hold_helpers, "MAX_HELD_RUNS", 2):
|
||||
oldest, _ = self.hold(count=1)
|
||||
self.hold(count=1)
|
||||
newest, _ = self.hold(count=1)
|
||||
with self.assertRaises(LookupError):
|
||||
self.keep(oldest)
|
||||
self.assertEqual(len(self.keep(newest)["saved"]), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -508,3 +508,80 @@ class SaveImageLocalModeTests(SaveImageNodeTests):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class SaveImageLightPreviewTests(unittest.TestCase):
|
||||
"""The small copy the node shows on its face instead of the full file."""
|
||||
|
||||
def run_node(self, output_root, temp_root, **overrides):
|
||||
class FakeFolderPaths:
|
||||
@staticmethod
|
||||
def get_output_directory():
|
||||
return str(output_root)
|
||||
|
||||
@staticmethod
|
||||
def get_temp_directory():
|
||||
return str(temp_root)
|
||||
|
||||
values = {
|
||||
"images": gradient_batch(1, 64, 4096),
|
||||
"filename_prefix": "sheet",
|
||||
"format": "png",
|
||||
"save_metadata": False,
|
||||
}
|
||||
values.update(overrides)
|
||||
with patch.object(node_save_image, "folder_paths", FakeFolderPaths):
|
||||
return node_save_image.AusBossSaveImage().save(**values)
|
||||
|
||||
def test_a_big_picture_gets_a_small_copy_and_the_file_stays_full_size(self):
|
||||
from nodes._image_save_helpers import PREVIEW_EDGE
|
||||
with tempfile.TemporaryDirectory() as out, tempfile.TemporaryDirectory() as temp:
|
||||
result = self.run_node(out, temp)
|
||||
(place,) = result["ui"]["ausboss_preview"]
|
||||
self.assertRegex(place, r"^ausboss_preview/[0-9a-f]{16}_000\.webp$")
|
||||
with Image.open(Path(temp) / place) as small:
|
||||
self.assertEqual(small.format, "WEBP")
|
||||
self.assertEqual(small.size, (PREVIEW_EDGE, 32))
|
||||
with Image.open(result["result"][0]) as saved:
|
||||
self.assertEqual(saved.size, (4096, 64))
|
||||
# The queue still lists the saved file, not the copy.
|
||||
self.assertEqual(result["ui"]["images"], [{"filename": "sheet_00001.png", "subfolder": "", "type": "output"}])
|
||||
|
||||
def test_every_saved_picture_has_its_copy_in_order(self):
|
||||
with tempfile.TemporaryDirectory() as out, tempfile.TemporaryDirectory() as temp:
|
||||
result = self.run_node(out, temp, images=gradient_batch(3, 8, 16))
|
||||
places = result["ui"]["ausboss_preview"]
|
||||
self.assertEqual(len(places), len(result["ui"]["images"]))
|
||||
self.assertEqual([place[-8:] for place in places], ["000.webp", "001.webp", "002.webp"])
|
||||
for place in places:
|
||||
with Image.open(Path(temp) / place) as small:
|
||||
self.assertEqual(small.size, (16, 8))
|
||||
|
||||
def test_held_pictures_get_copies_too(self):
|
||||
with tempfile.TemporaryDirectory() as out, tempfile.TemporaryDirectory() as temp:
|
||||
result = self.run_node(out, temp, autosave=False)
|
||||
(place,) = result["ui"]["ausboss_preview"]
|
||||
self.assertTrue((Path(temp) / place).is_file())
|
||||
self.assertEqual(len(result["ui"]["ausboss_held"]), 1)
|
||||
|
||||
def test_preview_off_writes_no_copy(self):
|
||||
with tempfile.TemporaryDirectory() as out, tempfile.TemporaryDirectory() as temp:
|
||||
result = self.run_node(out, temp, preview=False)
|
||||
self.assertEqual(result["ui"]["ausboss_preview"], [])
|
||||
self.assertFalse((Path(temp) / "ausboss_preview").exists())
|
||||
self.assertTrue(Path(result["result"][0]).is_file())
|
||||
|
||||
def test_a_skipped_file_has_no_copy(self):
|
||||
with tempfile.TemporaryDirectory() as out, tempfile.TemporaryDirectory() as temp:
|
||||
(Path(out) / "photo.png").write_bytes(b"original")
|
||||
result = self.run_node(out, temp, exact_name="photo", on_existing="skip")
|
||||
self.assertEqual(result["ui"]["images"], [])
|
||||
self.assertEqual(result["ui"]["ausboss_preview"], [])
|
||||
|
||||
def test_a_copy_that_cannot_be_written_never_stops_the_save(self):
|
||||
with tempfile.TemporaryDirectory() as out, tempfile.TemporaryDirectory() as temp:
|
||||
blocked = Path(temp) / "not_a_folder"
|
||||
blocked.write_text("x", encoding="utf-8")
|
||||
result = self.run_node(out, blocked)
|
||||
self.assertEqual(result["ui"]["ausboss_preview"], [])
|
||||
self.assertTrue(Path(result["result"][0]).is_file())
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
"""Load Image: the size plan as numbers, and the node on real files."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
from types import SimpleNamespace
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
if "nodes" in sys.modules and not hasattr(sys.modules["nodes"], "__path__"):
|
||||
del sys.modules["nodes"]
|
||||
|
||||
from nodes import _media_helpers # noqa: E402
|
||||
from nodes._load_image_helpers import ( # noqa: E402
|
||||
CROP_SIDES,
|
||||
RATIOS,
|
||||
SIZE_MODES,
|
||||
apply_load_size,
|
||||
plan_load_size,
|
||||
)
|
||||
from nodes.node_load_image import ( # noqa: E402
|
||||
NODE_CLASS_MAPPINGS,
|
||||
NODE_DISPLAY_NAME_MAPPINGS,
|
||||
AusBossLoadImage,
|
||||
)
|
||||
|
||||
TABLE = ROOT / "tests" / "fixtures" / "load_size_cases.json"
|
||||
|
||||
|
||||
class PlanTests(unittest.TestCase):
|
||||
def test_the_table_the_browser_is_held_to_is_what_the_planner_gives(self):
|
||||
table = json.loads(TABLE.read_text(encoding="utf-8"))
|
||||
self.assertGreater(len(table["rows"]), 200)
|
||||
for row in table["rows"]:
|
||||
plan = plan_load_size(*row[:12])
|
||||
got = [plan["resize_width"], plan["resize_height"], plan["crop_x"], plan["crop_y"], plan["width"], plan["height"]]
|
||||
self.assertEqual(got, row[12:], row[:12])
|
||||
|
||||
def test_a_crop_keeps_the_side_that_is_asked_for(self):
|
||||
# 200 x 100 into a 100 x 100 box: 100 pixels of width to lose.
|
||||
starts = {"left": 0, "top left": 0, "bottom left": 0, "center": 50, "top": 50, "bottom": 50, "right": 100, "top right": 100, "bottom right": 100}
|
||||
self.assertEqual(set(starts), set(CROP_SIDES))
|
||||
for side, start in starts.items():
|
||||
for size in ("crop to fill", "crop", "crop to ratio"):
|
||||
plan = plan_load_size(200, 100, size, width=100, height=100, multiple=1, crop_from=side, ratio="1:1")
|
||||
self.assertEqual((plan["crop_x"], plan["crop_y"], plan["width"], plan["height"]), (start, 0, 100, 100), (side, size))
|
||||
tall = plan_load_size(100, 300, "crop to fill", width=100, height=100, multiple=1, crop_from="bottom left")
|
||||
self.assertEqual((tall["crop_x"], tall["crop_y"]), (0, 200))
|
||||
|
||||
def test_crop_and_crop_to_ratio_never_resize_and_never_leave_the_picture(self):
|
||||
for source in ((1336, 1784), (1920, 1080), (30, 2000), (10, 10)):
|
||||
for multiple in (1, 8, 64):
|
||||
for size, ratio in (("crop", "1:1"), *(("crop to ratio", ratio) for ratio in RATIOS)):
|
||||
plan = plan_load_size(*source, size, width=1000, height=700, multiple=multiple, crop_from="bottom right", ratio=ratio)
|
||||
self.assertEqual((plan["resize_width"], plan["resize_height"]), source, (source, size, ratio))
|
||||
self.assertGreaterEqual(plan["width"], 1)
|
||||
self.assertGreaterEqual(plan["height"], 1)
|
||||
self.assertLessEqual(plan["crop_x"] + plan["width"], source[0])
|
||||
self.assertLessEqual(plan["crop_y"] + plan["height"], source[1])
|
||||
plan = plan_load_size(1920, 1080, "crop", width=1000, height=700, multiple=64)
|
||||
self.assertEqual((plan["width"], plan["height"]), (960, 640), "rounded down, inside the box")
|
||||
plan = plan_load_size(1336, 1784, "crop to ratio", multiple=1, ratio="16:9")
|
||||
self.assertEqual((plan["width"], plan["height"]), (1336, 752), "the widest 16:9 piece the picture holds")
|
||||
plan = plan_load_size(1336, 1784, "crop to ratio", width=1600, height=900, multiple=1, ratio="width : height")
|
||||
self.assertEqual((plan["width"], plan["height"]), (1336, 752), "the boxes give the shape")
|
||||
|
||||
def test_off_gives_the_picture_back_whatever_else_is_set(self):
|
||||
plan = plan_load_size(913, 1631, "off", megapixels=4.0, multiple=64, enlarge=False)
|
||||
self.assertEqual((plan["width"], plan["height"], plan["crop_x"], plan["crop_y"]), (913, 1631, 0, 0))
|
||||
|
||||
def test_each_choice_keeps_its_promise(self):
|
||||
plan = plan_load_size(912, 1632, "megapixels", megapixels=2.0, multiple=1)
|
||||
self.assertAlmostEqual(plan["width"] * plan["height"] / 1e6, 2.0, delta=0.01)
|
||||
self.assertAlmostEqual(plan["width"] / plan["height"], 912 / 1632, delta=0.002)
|
||||
plan = plan_load_size(912, 1632, "longest side", longest_side=2048, multiple=1)
|
||||
self.assertEqual((plan["width"], plan["height"]), (1144, 2048))
|
||||
plan = plan_load_size(1920, 1080, "longest side", longest_side=1280, multiple=1)
|
||||
self.assertEqual((plan["width"], plan["height"]), (1280, 720))
|
||||
plan = plan_load_size(1920, 1080, "scale", scale=0.5, multiple=1)
|
||||
self.assertEqual((plan["width"], plan["height"]), (960, 540))
|
||||
plan = plan_load_size(1920, 1080, "fit inside", width=1024, height=1024, multiple=1)
|
||||
self.assertEqual((plan["width"], plan["height"]), (1024, 576))
|
||||
plan = plan_load_size(1920, 1080, "crop to fill", width=1024, height=1024, multiple=1)
|
||||
self.assertEqual((plan["width"], plan["height"]), (1024, 1024))
|
||||
self.assertEqual((plan["resize_width"], plan["resize_height"]), (1821, 1024))
|
||||
self.assertEqual((plan["crop_x"], plan["crop_y"]), (398, 0))
|
||||
|
||||
def test_round_to_gives_multiples_and_fit_inside_stays_in_its_box(self):
|
||||
for size in SIZE_MODES[1:]:
|
||||
plan = plan_load_size(1000, 777, size, megapixels=1.3, longest_side=1111, scale=1.37, width=900, height=700, multiple=64)
|
||||
self.assertEqual((plan["width"] % 64, plan["height"] % 64), (0, 0), size)
|
||||
plan = plan_load_size(1920, 1080, "fit inside", width=1000, height=1000, multiple=64)
|
||||
self.assertLessEqual(plan["width"], 1000)
|
||||
self.assertLessEqual(plan["height"], 1000)
|
||||
|
||||
def test_with_enlarge_off_nothing_comes_out_bigger_than_the_file(self):
|
||||
for size in SIZE_MODES[1:]:
|
||||
for multiple in (1, 8, 16):
|
||||
plan = plan_load_size(640, 480, size, megapixels=4.0, longest_side=4096, scale=3.0, width=2048, height=2048, multiple=multiple, enlarge=False)
|
||||
self.assertLessEqual(plan["width"], 640, (size, multiple))
|
||||
self.assertLessEqual(plan["height"], 480, (size, multiple))
|
||||
self.assertLessEqual(plan["resize_width"], 640, (size, multiple))
|
||||
# Crop to fill still gives the box's shape, cut from the file as it is.
|
||||
plan = plan_load_size(800, 600, "crop to fill", width=1024, height=1024, multiple=1, enlarge=False)
|
||||
self.assertEqual((plan["width"], plan["height"], plan["resize_width"], plan["resize_height"], plan["crop_x"]), (600, 600, 800, 600, 100))
|
||||
# A picture that is big enough is resized as usual.
|
||||
plan = plan_load_size(4000, 3000, "longest side", longest_side=1024, multiple=1, enlarge=False)
|
||||
self.assertEqual((plan["width"], plan["height"]), (1024, 768))
|
||||
|
||||
def test_bad_input_is_named(self):
|
||||
with self.assertRaisesRegex(ValueError, "size must be one of"):
|
||||
plan_load_size(100, 100, "stretch")
|
||||
with self.assertRaisesRegex(ValueError, "larger than 0x0"):
|
||||
plan_load_size(0, 100, "off")
|
||||
with self.assertRaises(ValueError):
|
||||
plan_load_size(100, 100, "crop", crop_from="middle")
|
||||
with self.assertRaises(ValueError):
|
||||
plan_load_size(100, 100, "crop to ratio", ratio="7:5")
|
||||
|
||||
def test_a_plan_that_changes_nothing_hands_the_same_tensors_back(self):
|
||||
image, mask = torch.rand(1, 20, 30, 3), torch.zeros(1, 20, 30)
|
||||
out_image, out_mask = apply_load_size(image, mask, plan_load_size(30, 20, "off"), "lanczos")
|
||||
self.assertIs(out_image, image)
|
||||
self.assertIs(out_mask, mask)
|
||||
|
||||
|
||||
class NodeTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# The temp folder stands in for ComfyUI's input folder.
|
||||
self.folder = tempfile.mkdtemp(prefix="ausboss_load_image_")
|
||||
self.addCleanup(shutil.rmtree, self.folder, True)
|
||||
stand_in = SimpleNamespace(
|
||||
get_input_directory=lambda: self.folder,
|
||||
get_annotated_filepath=lambda name: os.path.join(self.folder, name),
|
||||
)
|
||||
patcher = patch.object(_media_helpers, "folder_paths", stand_in)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
def write(self, name="pic.png", width=96, height=64, mode="RGB"):
|
||||
path = Path(self.folder) / name
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
values = np.zeros((height, width, 4), dtype=np.uint8)
|
||||
values[..., 0] = np.linspace(0, 255, width, dtype=np.uint8)[None, :]
|
||||
values[..., 1] = np.linspace(0, 255, height, dtype=np.uint8)[:, None]
|
||||
values[..., 2] = 90
|
||||
values[..., 3] = 255
|
||||
values[: height // 2, : width // 2, 3] = 0 # the top left quarter is see-through
|
||||
Image.fromarray(values).convert(mode).save(path)
|
||||
return name
|
||||
|
||||
def run_node(self, name, **values):
|
||||
return AusBossLoadImage().load(name, **values)
|
||||
|
||||
def test_the_node_is_registered_under_its_permanent_key(self):
|
||||
self.assertIs(NODE_CLASS_MAPPINGS["AUSBOSS_NODES_LoadImage"], AusBossLoadImage)
|
||||
self.assertEqual(NODE_DISPLAY_NAME_MAPPINGS["AUSBOSS_NODES_LoadImage"], "Load Image \U0001f18e")
|
||||
spec = AusBossLoadImage.INPUT_TYPES()
|
||||
self.assertEqual(
|
||||
list(spec["required"]),
|
||||
["image", "size", "megapixels", "longest_side", "scale", "width", "height", "multiple", "method", "enlarge", "crop_from", "ratio"],
|
||||
)
|
||||
self.assertEqual(spec["required"]["size"][0], list(SIZE_MODES))
|
||||
self.assertEqual(spec["required"]["size"][1]["default"], "off")
|
||||
self.assertEqual(len(AusBossLoadImage.RETURN_TYPES), len(AusBossLoadImage.RETURN_NAMES))
|
||||
self.assertEqual(len(AusBossLoadImage.RETURN_TYPES), len(AusBossLoadImage.OUTPUT_TOOLTIPS))
|
||||
for name, (_, options) in spec["required"].items():
|
||||
self.assertTrue(options.get("tooltip"), name)
|
||||
|
||||
def test_with_size_off_the_file_comes_out_as_it_is(self):
|
||||
name = self.write()
|
||||
image, mask, width, height, filename, original_w, original_h = self.run_node(name)
|
||||
self.assertEqual(tuple(image.shape), (1, 64, 96, 3))
|
||||
self.assertEqual(tuple(mask.shape), (1, 64, 96))
|
||||
self.assertEqual((width, height, original_w, original_h), (96, 64, 96, 64))
|
||||
self.assertEqual(filename, "pic")
|
||||
wanted = np.asarray(Image.open(Path(self.folder) / name).convert("RGB"), dtype=np.float32) / 255.0
|
||||
self.assertTrue(np.array_equal(image[0].numpy(), wanted), "every pixel as the file has it")
|
||||
self.assertEqual(float(mask.max()), 0.0, "no transparency: an all black mask")
|
||||
|
||||
def test_a_see_through_picture_gives_its_mask_the_way_the_stock_loader_does(self):
|
||||
name = self.write("cut.png", mode="RGBA")
|
||||
_, mask, *_ = self.run_node(name)
|
||||
self.assertEqual(float(mask[0, 5, 5]), 1.0, "see-through is white")
|
||||
self.assertEqual(float(mask[0, 60, 90]), 0.0, "solid is black")
|
||||
|
||||
def test_every_size_choice_gives_the_planned_size_for_picture_and_mask(self):
|
||||
name = self.write("cut.png", mode="RGBA")
|
||||
for size in SIZE_MODES[1:]:
|
||||
with self.subTest(size=size):
|
||||
values = {"megapixels": 0.02, "longest_side": 160, "scale": 1.5, "width": 80, "height": 80, "multiple": 8}
|
||||
image, mask, width, height, _, original_w, original_h = self.run_node(name, size=size, **values)
|
||||
plan = plan_load_size(96, 64, size, **values)
|
||||
self.assertEqual((width, height), (plan["width"], plan["height"]))
|
||||
self.assertEqual(tuple(image.shape), (1, height, width, 3))
|
||||
self.assertEqual(tuple(mask.shape), (1, height, width))
|
||||
self.assertEqual((original_w, original_h), (96, 64))
|
||||
self.assertGreaterEqual(float(image.min()), 0.0)
|
||||
self.assertLessEqual(float(image.max()), 1.0)
|
||||
self.assertGreaterEqual(float(mask.min()), 0.0)
|
||||
self.assertLessEqual(float(mask.max()), 1.0)
|
||||
|
||||
def test_crop_to_fill_cuts_the_middle(self):
|
||||
name = self.write("wide.png", width=200, height=100)
|
||||
image, _, width, height, *_ = self.run_node(name, size="crop to fill", width=100, height=100, multiple=1, method="nearest")
|
||||
self.assertEqual((width, height), (100, 100))
|
||||
whole, *_ = self.run_node(name)
|
||||
self.assertTrue(torch.equal(image, whole[:, :, 50:150, :]), "the middle of the file, untouched")
|
||||
|
||||
def test_a_crop_takes_the_side_that_is_asked_for_out_of_the_file(self):
|
||||
name = self.write("wide.png", width=200, height=100)
|
||||
whole, *_ = self.run_node(name)
|
||||
left, *_ = self.run_node(name, size="crop to fill", width=100, height=100, multiple=1, method="nearest", crop_from="left")
|
||||
self.assertTrue(torch.equal(left, whole[:, :, 0:100, :]))
|
||||
right, mask, width, height, *_ = self.run_node(name, size="crop", width=60, height=40, multiple=1, crop_from="bottom right")
|
||||
self.assertEqual((width, height), (60, 40))
|
||||
self.assertTrue(torch.equal(right, whole[:, 60:100, 140:200, :]), "a piece of the file, not resized")
|
||||
self.assertEqual(tuple(mask.shape), (1, 40, 60))
|
||||
shaped, _, width, height, *_ = self.run_node(name, size="crop to ratio", ratio="1:1", multiple=1, crop_from="top")
|
||||
self.assertEqual((width, height), (100, 100))
|
||||
self.assertTrue(torch.equal(shaped, whole[:, :, 50:150, :]))
|
||||
|
||||
def test_enlarge_off_leaves_a_small_file_alone(self):
|
||||
name = self.write()
|
||||
image, _, width, height, *_ = self.run_node(name, size="longest side", longest_side=1024, multiple=1, enlarge=False)
|
||||
self.assertEqual((width, height), (96, 64))
|
||||
whole, *_ = self.run_node(name)
|
||||
self.assertTrue(torch.equal(image, whole))
|
||||
|
||||
def test_a_file_in_a_subfolder_gives_its_bare_name(self):
|
||||
name = self.write("shots/day one/hero.final.png")
|
||||
*_, filename, _, _ = self.run_node(name)
|
||||
self.assertEqual(filename, "hero.final")
|
||||
|
||||
def test_every_frame_of_an_animation_comes_through(self):
|
||||
frames = [Image.new("RGB", (40, 30), (index * 60, 20, 20)) for index in range(3)]
|
||||
path = Path(self.folder) / "turn.gif"
|
||||
frames[0].save(path, save_all=True, append_images=frames[1:], duration=80, loop=0)
|
||||
image, mask, width, height, *_ = self.run_node("turn.gif", size="scale", scale=2.0, multiple=1)
|
||||
self.assertEqual(tuple(image.shape), (3, 60, 80, 3))
|
||||
self.assertEqual(tuple(mask.shape), (3, 60, 80))
|
||||
self.assertEqual((width, height), (80, 60))
|
||||
|
||||
def test_a_missing_or_outside_file_stops_before_the_run_with_the_nodes_name(self):
|
||||
self.assertIs(AusBossLoadImage.VALIDATE_INPUTS(image=self.write()), True)
|
||||
for name in ("", "gone.png", "../secret.png", "//fileserver/share/pic.png"):
|
||||
verdict = AusBossLoadImage.VALIDATE_INPUTS(image=name)
|
||||
self.assertIsInstance(verdict, str, name)
|
||||
self.assertTrue(verdict.startswith("Load Image: "), verdict)
|
||||
|
||||
def test_a_changed_file_or_setting_runs_the_node_again(self):
|
||||
name = self.write()
|
||||
first = AusBossLoadImage.IS_CHANGED(name, size="off")
|
||||
self.assertEqual(first, AusBossLoadImage.IS_CHANGED(name, size="off"))
|
||||
self.assertNotEqual(first, AusBossLoadImage.IS_CHANGED(name, size="scale"))
|
||||
path = Path(self.folder) / name
|
||||
Image.new("RGB", (10, 10), (1, 2, 3)).save(path)
|
||||
os.utime(path, ns=(1, 1))
|
||||
self.assertNotEqual(first, AusBossLoadImage.IS_CHANGED(name, size="off"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -436,10 +436,11 @@ class LoaderValidationTests(TempFolders):
|
||||
"""The loaders refuse the same paths before a run, with one message each."""
|
||||
|
||||
def test_image_loaders_take_what_core_load_image_takes_and_nothing_else(self):
|
||||
from nodes import node_image_crop_rotate_pad, node_load_image_pad
|
||||
from nodes import node_image_crop_rotate_pad, node_load_image, node_load_image_pad
|
||||
|
||||
for module, cls, label in (
|
||||
(node_image_crop_rotate_pad, node_image_crop_rotate_pad.AusBossImageCropRotatePad, "Image Crop + Rotate + Pad"),
|
||||
(node_load_image, node_load_image.AusBossLoadImage, "Load Image"),
|
||||
(node_load_image_pad, node_load_image_pad.AusBossLoadImagePad, "Load Image + Pad"),
|
||||
):
|
||||
with self.subTest(node=label):
|
||||
|
||||
@@ -44,6 +44,7 @@ NAMED = {
|
||||
"AusBossImageFolder": ["source", "folder"],
|
||||
"AusBossLaMaInpaint": ["model"],
|
||||
"AusBossLoadAudio": ["audio"],
|
||||
"AusBossLoadImage": ["image"],
|
||||
"AusBossLoadImagePad": ["image", "source_image"],
|
||||
"AusBossLoadVideo": ["video"],
|
||||
"AusBossLoraLoader": ["loras", "on_missing"],
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
"""Every video list a node offers from the input folder takes uploads.
|
||||
|
||||
The flag (`video_upload`) is what gives the field an Upload button in
|
||||
ComfyUI's App mode and in Nodes 2.0. Without it the clip field in an App
|
||||
mode form was a bare list with nothing to upload a clip with. Read from the
|
||||
source, so ComfyUI does not have to be importable.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
NODES = Path(__file__).resolve().parent.parent / "nodes"
|
||||
|
||||
|
||||
def video_lists():
|
||||
for path in sorted(NODES.glob("node_*.py")):
|
||||
tree = ast.parse(path.read_text(encoding="utf-8"))
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.Tuple) or not node.elts:
|
||||
continue
|
||||
first = node.elts[0]
|
||||
if isinstance(first, ast.Call) and getattr(first.func, "id", "") == "list_input_videos":
|
||||
options = node.elts[1] if len(node.elts) > 1 and isinstance(node.elts[1], ast.Dict) else None
|
||||
flags = {}
|
||||
if options is not None:
|
||||
for key, value in zip(options.keys, options.values):
|
||||
if isinstance(key, ast.Constant) and isinstance(value, ast.Constant):
|
||||
flags[key.value] = value.value
|
||||
yield path.name, node.lineno, flags
|
||||
|
||||
|
||||
class VideoUploadFlag(unittest.TestCase):
|
||||
def test_every_input_video_list_takes_uploads(self):
|
||||
found = list(video_lists())
|
||||
self.assertGreaterEqual(len(found), 3, "expected Load Video and both video crop nodes")
|
||||
missing = [f"{name}:{line}" for name, line, flags in found if flags.get("video_upload") is not True]
|
||||
self.assertEqual(missing, [], "video lists without video_upload: True")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -43,6 +43,7 @@ function fixture({ size = [300, 80], floor = [210, 94], scale = 1 } = {}) {
|
||||
querySelector() { return this; }
|
||||
setAttribute() {}
|
||||
setPointerCapture() {}
|
||||
closest() { return null; }
|
||||
remove() { this.removed = true; }
|
||||
}
|
||||
const root = new Element();
|
||||
@@ -56,7 +57,7 @@ function fixture({ size = [300, 80], floor = [210, 94], scale = 1 } = {}) {
|
||||
};
|
||||
const source = readFileSync(new URL("../js/shared/tile_face.mjs", import.meta.url), "utf8")
|
||||
.replace(/^import .*;\n/, "").replaceAll("export ", "");
|
||||
const context = vm.createContext({ app, AbortController, document: { createElement: () => new Element() } });
|
||||
const context = vm.createContext({ app, AbortController, CustomEvent, document: { createElement: () => new Element() } });
|
||||
vm.runInContext(source, context);
|
||||
context.setTileFace(node, root, true);
|
||||
const grip = root.children[0];
|
||||
@@ -103,3 +104,25 @@ test("keyboard resize supports fine steps, respects pinning and removes its hand
|
||||
f.disable();
|
||||
assert.equal(f.grip.removed, true);
|
||||
});
|
||||
|
||||
test("a tile drag names its card for snapping and reports each move once placed", () => {
|
||||
const f = fixture();
|
||||
assert.equal(f.node.ausbossOutlineElement, f.root, "Snap into line measures the card, not the transparent node");
|
||||
let stopped = 0;
|
||||
const reports = [];
|
||||
f.root.addEventListener("ausboss-tile-move", (event) => reports.push([...f.node.pos, event.detail.clientX]));
|
||||
const send = (type, values = {}) => {
|
||||
const event = new Event(type, { cancelable: true });
|
||||
Object.assign(event, { button: 0, pointerId: 1, isPrimary: true, clientX: 0, clientY: 0, ...values });
|
||||
if (type === "pointermove") event.stopPropagation = () => stopped++;
|
||||
f.root.dispatchEvent(event);
|
||||
};
|
||||
send("pointerdown", { clientX: 10, clientY: 10 });
|
||||
send("pointermove", { clientX: 60, clientY: 30 });
|
||||
assert.deepEqual([...f.node.pos], [70, 50]);
|
||||
assert.equal(stopped, 1, "the move stays with the tile, or Nodes 2.0 pans the canvas with it");
|
||||
assert.deepEqual(reports, [[70, 50, 60]], "Snap into line hears the move after the tile is placed");
|
||||
send("pointerup");
|
||||
f.disable();
|
||||
assert.equal(f.node.ausbossOutlineElement, undefined);
|
||||
});
|
||||
|
||||
@@ -181,7 +181,7 @@ test("fixed frame duration follows output fps while position follows source fps"
|
||||
});
|
||||
|
||||
// --- One way to set the length -------------------------------------------------
|
||||
import { clipLengthPlan, framesThrough, lastFrameFor, latestFirstFor, lengthMode, snapStep, snapToValid } from "../js/shared/timeline_math.mjs";
|
||||
import { clipLengthPlan, framesThrough, lastFrameFor, latestFirstFor, latestInFor, lengthMode, snapStep, snapToValid } from "../js/shared/timeline_math.mjs";
|
||||
|
||||
test("one mode sets the length: a wired input, an old fixed count, a Length, or OUT", () => {
|
||||
assert.equal(lengthMode({}), "free");
|
||||
@@ -214,6 +214,16 @@ test("OUT lands on a frame the run keeps", () => {
|
||||
assert.equal(latestFirstFor(info, 20), 77);
|
||||
assert.equal(latestFirstFor(info, 97), 0);
|
||||
assert.equal(latestFirstFor(info, 200), 0);
|
||||
// A Length that fits stops IN where OUT meets the end; one as long as the
|
||||
// clip or longer only caps it, so IN reaches every frame (a 240-frame
|
||||
// Length on a 116-frame clip used to pin IN at 0).
|
||||
assert.equal(latestInFor(info, 20), 77);
|
||||
assert.equal(latestInFor(info, 97), 96);
|
||||
assert.equal(latestInFor(info, 200), 96);
|
||||
const short = clipInfo({ fps: 24, frame_count: 116, duration: 116 / 24 });
|
||||
assert.equal(latestInFor(short, 240), 115);
|
||||
const late = clipLengthPlan(short, { start: windowSeconds(short, 40, 40).start_seconds, end: 0, maxFrames: 240 });
|
||||
assert.deepEqual([late.first, late.last, late.frames, late.truncated], [40, 115, 76, true]);
|
||||
});
|
||||
|
||||
test("free trim: the handles are IN and the last frame the run keeps", () => {
|
||||
@@ -305,3 +315,19 @@ test("a wired 49-frame selection stops at IN 48 on the 97-frame pier clip", () =
|
||||
assert.equal(clipLengthPlan(info, { ...values, resampled: true, outputFps: 12 }).latestStart, 0);
|
||||
assert.equal(clipLengthPlan(info, { ...values, wired: "fixed_frames", outputFps: 24 }).latestStart, 48);
|
||||
});
|
||||
|
||||
test('a linked 24 fps rate on a 60 fps clip: 48 frames from 1 s end at 3 s', () => {
|
||||
const info = clipInfo({ fps: 60, frame_count: 247, duration: 247 / 60 });
|
||||
const values = { start: 1, end: 0, everyNth: 1, frameSnap: 'free', maxFrames: 48, fixedFrames: 0, wired: null, wiredFrames: null, outputFps: 24, resampled: true };
|
||||
const plan = clipLengthPlan(info, values);
|
||||
assert.equal(plan.frames, 48);
|
||||
assert.equal(plan.endSeconds, 3);
|
||||
assert.equal(plan.last, 177);
|
||||
assert.equal(plan.latestStart, 129);
|
||||
// A 240-frame Length (10 s) only caps a 4.1 s clip: the source ends first.
|
||||
const capped = clipLengthPlan(info, { ...values, maxFrames: 240 });
|
||||
assert.equal(capped.truncated, true);
|
||||
assert.equal(capped.frames, 75);
|
||||
// Still unknown without a rate.
|
||||
assert.equal(clipLengthPlan(info, { ...values, outputFps: null }).last, null);
|
||||
});
|
||||
|
||||
@@ -943,7 +943,7 @@ test("a name is shown only when SAM 3 is sure of it, and surer still for a big t
|
||||
});
|
||||
|
||||
test("the pack's own picture loaders are the ones the node runs by itself", () => {
|
||||
assert.deepEqual([...OWN_LOADERS].sort(), ["AUSBOSS_NODES_ImageCropRotatePad", "AUSBOSS_NODES_LoadImagePad"]);
|
||||
assert.deepEqual([...OWN_LOADERS].sort(), ["AUSBOSS_NODES_ImageCropRotatePad", "AUSBOSS_NODES_LoadImage", "AUSBOSS_NODES_LoadImagePad"]);
|
||||
// A core Load Image is not in the list: its file is the picture, and the node shows it without a run.
|
||||
assert.equal(OWN_LOADERS.has("LoadImage"), false);
|
||||
});
|
||||
|
||||
@@ -106,3 +106,14 @@ test("hideInputsInDef never throws on frozen definitions", () => {
|
||||
const frozenAll = Object.freeze({ input: Object.freeze({ required: Object.freeze({ seed: Object.freeze(["INT", Object.freeze({})]) }) }) });
|
||||
assert.equal(hideInputsInDef(frozenAll, ["seed"]), 0);
|
||||
});
|
||||
|
||||
test("show leaves no paint hooks behind that the widget never had", () => {
|
||||
// Left as own `undefined` properties, the frontend took the widget for a
|
||||
// custom-drawn one and App mode drew an empty row for it.
|
||||
const widget = makeWidget();
|
||||
hideWidget(widget);
|
||||
showWidget(widget);
|
||||
for (const key of ["computeSize", "computeLayoutSize", "draw"]) {
|
||||
assert.equal(Object.prototype.hasOwnProperty.call(widget, key), false, key);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
groupModels,
|
||||
hostLabel,
|
||||
matchInstalled,
|
||||
onlyCopy,
|
||||
noteFit,
|
||||
noteIsEmpty,
|
||||
noteShowsTileFace,
|
||||
@@ -332,3 +333,15 @@ test("note panels stand down the frontend image preview", () => {
|
||||
assert.match(source, /import \{ suppressCoreImagePreview \} from "\.\.\/shared\/core_preview\.mjs";/, "the note imports the pack's preview suppression");
|
||||
assert.match(source, /suppressCoreImagePreview\(node\);/, "building a note panel stands the core image preview down");
|
||||
});
|
||||
|
||||
test("onlyCopy picks a file without asking only when there is one copy", () => {
|
||||
const files = ["minimax-h3/model.safetensors", "a/lora.safetensors", "b/lora.safetensors", "vae.safetensors", "a\\Win.safetensors"];
|
||||
assert.equal(onlyCopy("model.safetensors", files), "minimax-h3/model.safetensors");
|
||||
assert.equal(onlyCopy("MODEL.safetensors", files), "minimax-h3/model.safetensors");
|
||||
assert.equal(onlyCopy("lora.safetensors", files), null); // two copies: the user picks
|
||||
assert.equal(onlyCopy("b/lora.safetensors", files), "b/lora.safetensors"); // the exact path wins
|
||||
assert.equal(onlyCopy("vae.safetensors", files), "vae.safetensors");
|
||||
assert.equal(onlyCopy("win.safetensors", files), "a/Win.safetensors");
|
||||
assert.equal(onlyCopy("missing.safetensors", files), null);
|
||||
assert.equal(onlyCopy("model.safetensors", []), null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user