LayerUtility: XY to Percent
XY to Percent — turn a pixel position into a resolution-proof percentage
- background_image
- layer_image
- x_percent
- y_percent
A coordinate converter: give it a pixel position you eyeballed at one resolution, and it hands back the equivalent percentage position - the kind of value that still lines up correctly if the canvas size changes later. A lot of this pack's compositing and paste nodes accept position as a percent instead of raw pixels precisely because percent survives a resize and pixels don't; this is the node that does that conversion for you instead of making you do the math by hand.
How it works
You feed it background_image and layer_image - the two images the placement is actually happening between - plus x and y, the absolute pixel offset you're converting. It divides that pixel position against the background's real dimensions and returns the equivalent x_percent/y_percent. Because it takes both images rather than just numbers, the conversion is grounded in your actual canvas and layer sizes rather than assumed ones.
The practical case this solves: you've dragged a logo or a text layer to a spot that looks right at, say, 512×512, using pixel coordinates. If you then need the same relative placement at 2048×2048, those pixel numbers don't scale - you'd have to redo the math. Convert once with this node, and the percentage output plugs into any position input elsewhere in the pack that accepts percent, staying correct regardless of the final resolution.
The inputs and outputs that matter
background_image/layer_image- the two images placement is being computed against.x/y- the absolute pixel offset you're converting to a percentage.
Outputs: x_percent and y_percent - floats you wire into any downstream node whose position input takes a percentage rather than raw pixels.
How to install it
Ships with LayerStyle. ComfyUI Manager: search ComfyUI Layer Style, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt
Restart, find it under 😺dzNodes → LayerUtility → Data. Pure math, nothing to download.
Common issues
The position doesn't line up the way you expected after a resize. The percentage this node computes is only correct relative to the exact background_image you fed it at the time. If you later swap in a differently-sized or differently-cropped background without recomputing, the percent you locked in earlier won't represent the same relative spot anymore - feed in the actual final-resolution background when you compute the percentage, not a placeholder.
Percent looks flipped or off-center. Double-check you haven't swapped background_image and layer_image - the percentage math is relative to the background's dimensions specifically, so getting the two reversed will throw the numbers off.
Pack-wide: if XY to Percent is missing from your menu entirely, LayerStyle failed to import as a whole, not this node. Usual cause is a transformers/tensorflow version conflict from another custom node pack sharing your environment, especially on installs from before the pack split into base LayerStyle and the heavier LayerStyle Advance repo. Reinstall clean or use Manager's "Try Fix" and check the actual traceback before assuming this node is the problem.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| background_image | IMAGE | — | |
| layer_image | IMAGE | — | |
| x | INT | 0-99999–99999 | — |
| y | INT | 0-99999–99999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| x_percent | FLOAT | — |
| y_percent | FLOAT | — |